Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / engineextension / PeopleMainMenuBarExtension.php
blobe19cedd3052b34ca9705cbd06b1858ca09ac3bee
1 <?php
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() {
13 return false;
16 public function getExtensionOrder() {
17 return 1200;
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(
28 'user-menu',
29 array(
30 'menuID' => $menu_id,
31 'menu' => $dropdown_menu->getDropdownMenuMetadata(),
32 ));
34 $image = $viewer->getProfileImageURI();
35 $profile_image = id(new PHUIIconView())
36 ->setImage($image)
37 ->setHeadSize(PHUIIconView::HEAD_SMALL);
39 $user_menu = id(new PHUIButtonView())
40 ->setID($menu_id)
41 ->setTag('a')
42 ->setHref('/p/'.$viewer->getUsername().'/')
43 ->setIcon($profile_image)
44 ->addClass('phabricator-core-user-menu')
45 ->setHasCaret(true)
46 ->setNoCSS(true)
47 ->setAuralLabel(pht('Account Menu'));
49 return array(
50 $user_menu,
54 private function newDropdown(
55 PhabricatorUser $viewer,
56 $application) {
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())
64 ->setViewer($viewer)
65 ->setFlush(true)
66 ->setSimple(true)
67 ->addItem($person_to_show)
68 ->addClass('phabricator-core-user-profile-object');
70 $view = id(new PhabricatorActionListView())
71 ->setViewer($viewer);
73 if ($this->getIsFullSession()) {
74 $view->addAction(
75 id(new PhabricatorActionView())
76 ->appendChild($user_view));
78 $view->addAction(
79 id(new PhabricatorActionView())
80 ->setType(PhabricatorActionView::TYPE_DIVIDER));
82 $view->addAction(
83 id(new PhabricatorActionView())
84 ->setName(pht('Profile'))
85 ->setHref('/p/'.$viewer->getUsername().'/'));
87 $view->addAction(
88 id(new PhabricatorActionView())
89 ->setName(pht('Settings'))
90 ->setHref('/settings/user/'.$viewer->getUsername().'/'));
92 $view->addAction(
93 id(new PhabricatorActionView())
94 ->setName(pht('Manage'))
95 ->setHref('/people/manage/'.$viewer->getID().'/'));
97 if ($application) {
98 $help_links = $application->getHelpMenuItems($viewer);
99 if ($help_links) {
100 foreach ($help_links as $link) {
101 $view->addAction($link);
106 $view->addAction(
107 id(new PhabricatorActionView())
108 ->addSigil('logout-item')
109 ->setType(PhabricatorActionView::TYPE_DIVIDER));
112 $view->addAction(
113 id(new PhabricatorActionView())
114 ->setName(pht('Log Out %s', $viewer->getUsername()))
115 ->addSigil('logout-item')
116 ->setHref('/logout/')
117 ->setWorkflow(true));
119 return $view;