Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / badges / controller / PhabricatorBadgesProfileController.php
blob97d4b11b936f8e3619a18ee7eef81462e4fed631
1 <?php
3 abstract class PhabricatorBadgesProfileController
4 extends PhabricatorController {
6 private $badge;
8 public function setBadge(PhabricatorBadgesBadge $badge) {
9 $this->badge = $badge;
10 return $this;
13 public function getBadge() {
14 return $this->badge;
17 public function buildApplicationMenu() {
18 return $this->buildSideNavView()->getMenu();
21 protected function buildHeaderView() {
22 $viewer = $this->getViewer();
23 $badge = $this->getBadge();
24 $id = $badge->getID();
26 if ($badge->isArchived()) {
27 $status_icon = 'fa-ban';
28 $status_color = 'dark';
29 } else {
30 $status_icon = 'fa-check';
31 $status_color = 'bluegrey';
33 $status_name = idx(
34 PhabricatorBadgesBadge::getStatusNameMap(),
35 $badge->getStatus());
37 return id(new PHUIHeaderView())
38 ->setHeader($badge->getName())
39 ->setUser($viewer)
40 ->setPolicyObject($badge)
41 ->setStatus($status_icon, $status_color, $status_name)
42 ->setHeaderIcon('fa-trophy');
45 protected function buildApplicationCrumbs() {
46 $badge = $this->getBadge();
47 $id = $badge->getID();
48 $badge_uri = $this->getApplicationURI("/view/{$id}/");
50 $crumbs = parent::buildApplicationCrumbs();
51 $crumbs->addTextCrumb($badge->getName(), $badge_uri);
52 $crumbs->setBorder(true);
53 return $crumbs;
56 protected function buildSideNavView($filter = null) {
57 $viewer = $this->getViewer();
58 $badge = $this->getBadge();
59 $id = $badge->getID();
61 $can_edit = PhabricatorPolicyFilter::hasCapability(
62 $viewer,
63 $badge,
64 PhabricatorPolicyCapability::CAN_EDIT);
66 $nav = id(new AphrontSideNavFilterView())
67 ->setBaseURI(new PhutilURI($this->getApplicationURI()));
69 $nav->addLabel(pht('Badge'));
71 $nav->addFilter(
72 'view',
73 pht('View Badge'),
74 $this->getApplicationURI("/view/{$id}/"),
75 'fa-trophy');
77 $nav->addFilter(
78 'recipients',
79 pht('View Recipients'),
80 $this->getApplicationURI("/recipients/{$id}/"),
81 'fa-group');
83 $nav->selectFilter($filter);
85 return $nav;