Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / controller / PhabricatorPeopleProfileController.php
blob1d6f0fc74cfcc0a16e446700d2541798dc6acd02
1 <?php
3 abstract class PhabricatorPeopleProfileController
4 extends PhabricatorPeopleController {
6 private $user;
8 public function shouldRequireAdmin() {
9 return false;
12 public function setUser(PhabricatorUser $user) {
13 $this->user = $user;
14 return $this;
17 public function getUser() {
18 return $this->user;
21 protected function buildApplicationCrumbs() {
22 $crumbs = parent::buildApplicationCrumbs();
24 $user = $this->getUser();
25 if ($user) {
26 $crumbs->addTextCrumb(
27 $user->getUsername(),
28 urisprintf('/p/%s/', $user->getUsername()));
31 return $crumbs;
34 public function buildProfileHeader() {
35 $user = $this->user;
36 $viewer = $this->getViewer();
38 $profile = $user->loadUserProfile();
39 $picture = $user->getProfileImageURI();
41 $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
42 $profile_title = $profile->getDisplayTitle();
45 $tag = id(new PHUITagView())
46 ->setType(PHUITagView::TYPE_SHADE);
48 $tags = array();
49 if ($user->getIsAdmin()) {
50 $tags[] = id(clone $tag)
51 ->setName(pht('Administrator'))
52 ->setColor('blue');
55 // "Disabled" gets a stronger status tag below.
57 if (!$user->getIsApproved()) {
58 $tags[] = id(clone $tag)
59 ->setName('Not Approved')
60 ->setColor('yellow');
63 if ($user->getIsSystemAgent()) {
64 $tags[] = id(clone $tag)
65 ->setName(pht('Bot'))
66 ->setColor('orange');
69 if ($user->getIsMailingList()) {
70 $tags[] = id(clone $tag)
71 ->setName(pht('Mailing List'))
72 ->setColor('orange');
75 if (!$user->getIsEmailVerified()) {
76 $tags[] = id(clone $tag)
77 ->setName(pht('Email Not Verified'))
78 ->setColor('violet');
81 $header = id(new PHUIHeaderView())
82 ->setHeader($user->getFullName())
83 ->setImage($picture)
84 ->setProfileHeader(true)
85 ->addClass('people-profile-header');
87 foreach ($tags as $tag) {
88 $header->addTag($tag);
91 require_celerity_resource('project-view-css');
93 if ($user->getIsDisabled()) {
94 $header->setStatus('fa-ban', 'red', pht('Disabled'));
95 } else {
96 $header->setStatus($profile_icon, 'bluegrey', $profile_title);
99 $can_edit = PhabricatorPolicyFilter::hasCapability(
100 $viewer,
101 $user,
102 PhabricatorPolicyCapability::CAN_EDIT);
104 if ($can_edit) {
105 $id = $user->getID();
106 $header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));
109 return $header;
112 final protected function newNavigation(
113 PhabricatorUser $user,
114 $item_identifier) {
116 $viewer = $this->getViewer();
118 $engine = id(new PhabricatorPeopleProfileMenuEngine())
119 ->setViewer($viewer)
120 ->setController($this)
121 ->setProfileObject($user);
123 $view_list = $engine->newProfileMenuItemViewList();
125 $view_list->setSelectedViewWithItemIdentifier($item_identifier);
127 $navigation = $view_list->newNavigationView();
129 return $navigation;