Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/controller/PhabricatorPeopleProfileController.php
12256 views
1
<?php
2
3
abstract class PhabricatorPeopleProfileController
4
extends PhabricatorPeopleController {
5
6
private $user;
7
8
public function shouldRequireAdmin() {
9
return false;
10
}
11
12
public function setUser(PhabricatorUser $user) {
13
$this->user = $user;
14
return $this;
15
}
16
17
public function getUser() {
18
return $this->user;
19
}
20
21
protected function buildApplicationCrumbs() {
22
$crumbs = parent::buildApplicationCrumbs();
23
24
$user = $this->getUser();
25
if ($user) {
26
$crumbs->addTextCrumb(
27
$user->getUsername(),
28
urisprintf('/p/%s/', $user->getUsername()));
29
}
30
31
return $crumbs;
32
}
33
34
public function buildProfileHeader() {
35
$user = $this->user;
36
$viewer = $this->getViewer();
37
38
$profile = $user->loadUserProfile();
39
$picture = $user->getProfileImageURI();
40
41
$profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
42
$profile_title = $profile->getDisplayTitle();
43
44
45
$tag = id(new PHUITagView())
46
->setType(PHUITagView::TYPE_SHADE);
47
48
$tags = array();
49
if ($user->getIsAdmin()) {
50
$tags[] = id(clone $tag)
51
->setName(pht('Administrator'))
52
->setColor('blue');
53
}
54
55
// "Disabled" gets a stronger status tag below.
56
57
if (!$user->getIsApproved()) {
58
$tags[] = id(clone $tag)
59
->setName('Not Approved')
60
->setColor('yellow');
61
}
62
63
if ($user->getIsSystemAgent()) {
64
$tags[] = id(clone $tag)
65
->setName(pht('Bot'))
66
->setColor('orange');
67
}
68
69
if ($user->getIsMailingList()) {
70
$tags[] = id(clone $tag)
71
->setName(pht('Mailing List'))
72
->setColor('orange');
73
}
74
75
if (!$user->getIsEmailVerified()) {
76
$tags[] = id(clone $tag)
77
->setName(pht('Email Not Verified'))
78
->setColor('violet');
79
}
80
81
$header = id(new PHUIHeaderView())
82
->setHeader($user->getFullName())
83
->setImage($picture)
84
->setProfileHeader(true)
85
->addClass('people-profile-header');
86
87
foreach ($tags as $tag) {
88
$header->addTag($tag);
89
}
90
91
require_celerity_resource('project-view-css');
92
93
if ($user->getIsDisabled()) {
94
$header->setStatus('fa-ban', 'red', pht('Disabled'));
95
} else {
96
$header->setStatus($profile_icon, 'bluegrey', $profile_title);
97
}
98
99
$can_edit = PhabricatorPolicyFilter::hasCapability(
100
$viewer,
101
$user,
102
PhabricatorPolicyCapability::CAN_EDIT);
103
104
if ($can_edit) {
105
$id = $user->getID();
106
$header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));
107
}
108
109
return $header;
110
}
111
112
final protected function newNavigation(
113
PhabricatorUser $user,
114
$item_identifier) {
115
116
$viewer = $this->getViewer();
117
118
$engine = id(new PhabricatorPeopleProfileMenuEngine())
119
->setViewer($viewer)
120
->setController($this)
121
->setProfileObject($user);
122
123
$view_list = $engine->newProfileMenuItemViewList();
124
125
$view_list->setSelectedViewWithItemIdentifier($item_identifier);
126
127
$navigation = $view_list->newNavigationView();
128
129
return $navigation;
130
}
131
132
}
133
134