3 final class PeopleMainMenuBarExtension
4 extends PhabricatorMainMenuBarExtension
{
6 const MAINMENUBARKEY
= 'user';
8 public function isExtensionEnabledForViewer(PhabricatorUser
$viewer) {
9 return $viewer->isLoggedIn();
12 public function shouldRequireFullSession() {
16 public function getExtensionOrder() {
20 public function buildMainMenus() {
21 $viewer = $this->getViewer();
22 $application = $this->getApplication();
23 $dropdown_menu = $this->newDropdown($viewer, $application);
25 $menu_id = celerity_generate_unique_node_id();
27 Javelin
::initBehavior(
31 'menu' => $dropdown_menu->getDropdownMenuMetadata(),
34 $image = $viewer->getProfileImageURI();
35 $profile_image = id(new PHUIIconView())
37 ->setHeadSize(PHUIIconView
::HEAD_SMALL
);
39 $user_menu = id(new PHUIButtonView())
42 ->setHref('/p/'.$viewer->getUsername().'/')
43 ->setIcon($profile_image)
44 ->addClass('phabricator-core-user-menu')
47 ->setAuralLabel(pht('Account Menu'));
54 private function newDropdown(
55 PhabricatorUser
$viewer,
58 $person_to_show = id(new PHUIObjectItemView())
59 ->setObjectName($viewer->getRealName())
60 ->setSubHead($viewer->getUsername())
61 ->setImageURI($viewer->getProfileImageURI());
63 $user_view = id(new PHUIObjectItemListView())
67 ->addItem($person_to_show)
68 ->addClass('phabricator-core-user-profile-object');
70 $view = id(new PhabricatorActionListView())
73 if ($this->getIsFullSession()) {
75 id(new PhabricatorActionView())
76 ->appendChild($user_view));
79 id(new PhabricatorActionView())
80 ->setType(PhabricatorActionView
::TYPE_DIVIDER
));
83 id(new PhabricatorActionView())
84 ->setName(pht('Profile'))
85 ->setHref('/p/'.$viewer->getUsername().'/'));
88 id(new PhabricatorActionView())
89 ->setName(pht('Settings'))
90 ->setHref('/settings/user/'.$viewer->getUsername().'/'));
93 id(new PhabricatorActionView())
94 ->setName(pht('Manage'))
95 ->setHref('/people/manage/'.$viewer->getID().'/'));
98 $help_links = $application->getHelpMenuItems($viewer);
100 foreach ($help_links as $link) {
101 $view->addAction($link);
107 id(new PhabricatorActionView())
108 ->addSigil('logout-item')
109 ->setType(PhabricatorActionView
::TYPE_DIVIDER
));
113 id(new PhabricatorActionView())
114 ->setName(pht('Log Out %s', $viewer->getUsername()))
115 ->addSigil('logout-item')
116 ->setHref('/logout/')
117 ->setWorkflow(true));