Path: blob/master/src/applications/people/controller/PhabricatorPeopleProfileController.php
12256 views
<?php12abstract class PhabricatorPeopleProfileController3extends PhabricatorPeopleController {45private $user;67public function shouldRequireAdmin() {8return false;9}1011public function setUser(PhabricatorUser $user) {12$this->user = $user;13return $this;14}1516public function getUser() {17return $this->user;18}1920protected function buildApplicationCrumbs() {21$crumbs = parent::buildApplicationCrumbs();2223$user = $this->getUser();24if ($user) {25$crumbs->addTextCrumb(26$user->getUsername(),27urisprintf('/p/%s/', $user->getUsername()));28}2930return $crumbs;31}3233public function buildProfileHeader() {34$user = $this->user;35$viewer = $this->getViewer();3637$profile = $user->loadUserProfile();38$picture = $user->getProfileImageURI();3940$profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());41$profile_title = $profile->getDisplayTitle();424344$tag = id(new PHUITagView())45->setType(PHUITagView::TYPE_SHADE);4647$tags = array();48if ($user->getIsAdmin()) {49$tags[] = id(clone $tag)50->setName(pht('Administrator'))51->setColor('blue');52}5354// "Disabled" gets a stronger status tag below.5556if (!$user->getIsApproved()) {57$tags[] = id(clone $tag)58->setName('Not Approved')59->setColor('yellow');60}6162if ($user->getIsSystemAgent()) {63$tags[] = id(clone $tag)64->setName(pht('Bot'))65->setColor('orange');66}6768if ($user->getIsMailingList()) {69$tags[] = id(clone $tag)70->setName(pht('Mailing List'))71->setColor('orange');72}7374if (!$user->getIsEmailVerified()) {75$tags[] = id(clone $tag)76->setName(pht('Email Not Verified'))77->setColor('violet');78}7980$header = id(new PHUIHeaderView())81->setHeader($user->getFullName())82->setImage($picture)83->setProfileHeader(true)84->addClass('people-profile-header');8586foreach ($tags as $tag) {87$header->addTag($tag);88}8990require_celerity_resource('project-view-css');9192if ($user->getIsDisabled()) {93$header->setStatus('fa-ban', 'red', pht('Disabled'));94} else {95$header->setStatus($profile_icon, 'bluegrey', $profile_title);96}9798$can_edit = PhabricatorPolicyFilter::hasCapability(99$viewer,100$user,101PhabricatorPolicyCapability::CAN_EDIT);102103if ($can_edit) {104$id = $user->getID();105$header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));106}107108return $header;109}110111final protected function newNavigation(112PhabricatorUser $user,113$item_identifier) {114115$viewer = $this->getViewer();116117$engine = id(new PhabricatorPeopleProfileMenuEngine())118->setViewer($viewer)119->setController($this)120->setProfileObject($user);121122$view_list = $engine->newProfileMenuItemViewList();123124$view_list->setSelectedViewWithItemIdentifier($item_identifier);125126$navigation = $view_list->newNavigationView();127128return $navigation;129}130131}132133134