Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/badges/controller/PhabricatorBadgesProfileController.php
12262 views
1
<?php
2
3
abstract class PhabricatorBadgesProfileController
4
extends PhabricatorController {
5
6
private $badge;
7
8
public function setBadge(PhabricatorBadgesBadge $badge) {
9
$this->badge = $badge;
10
return $this;
11
}
12
13
public function getBadge() {
14
return $this->badge;
15
}
16
17
public function buildApplicationMenu() {
18
return $this->buildSideNavView()->getMenu();
19
}
20
21
protected function buildHeaderView() {
22
$viewer = $this->getViewer();
23
$badge = $this->getBadge();
24
$id = $badge->getID();
25
26
if ($badge->isArchived()) {
27
$status_icon = 'fa-ban';
28
$status_color = 'dark';
29
} else {
30
$status_icon = 'fa-check';
31
$status_color = 'bluegrey';
32
}
33
$status_name = idx(
34
PhabricatorBadgesBadge::getStatusNameMap(),
35
$badge->getStatus());
36
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');
43
}
44
45
protected function buildApplicationCrumbs() {
46
$badge = $this->getBadge();
47
$id = $badge->getID();
48
$badge_uri = $this->getApplicationURI("/view/{$id}/");
49
50
$crumbs = parent::buildApplicationCrumbs();
51
$crumbs->addTextCrumb($badge->getName(), $badge_uri);
52
$crumbs->setBorder(true);
53
return $crumbs;
54
}
55
56
protected function buildSideNavView($filter = null) {
57
$viewer = $this->getViewer();
58
$badge = $this->getBadge();
59
$id = $badge->getID();
60
61
$can_edit = PhabricatorPolicyFilter::hasCapability(
62
$viewer,
63
$badge,
64
PhabricatorPolicyCapability::CAN_EDIT);
65
66
$nav = id(new AphrontSideNavFilterView())
67
->setBaseURI(new PhutilURI($this->getApplicationURI()));
68
69
$nav->addLabel(pht('Badge'));
70
71
$nav->addFilter(
72
'view',
73
pht('View Badge'),
74
$this->getApplicationURI("/view/{$id}/"),
75
'fa-trophy');
76
77
$nav->addFilter(
78
'recipients',
79
pht('View Recipients'),
80
$this->getApplicationURI("/recipients/{$id}/"),
81
'fa-group');
82
83
$nav->selectFilter($filter);
84
85
return $nav;
86
}
87
88
}
89
90