1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/src/applications/people/engine/PhabricatorPeopleProfileMenuEngine.php
epriestley 42896f9f90 Rename all ProfilePanels into ProfileMenuItems
Summary: Ref T11957.

Test Plan:
  - Viewed an existing project profile.
  - Viewed a user profile.
  - Created a new project.
  - Edited a profile menu.
  - Added new profile items.
  - Grepped for renamed symbols.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11957

Differential Revision: https://secure.phabricator.com/D17028
2016-12-11 11:44:38 -08:00

84 lines
2.5 KiB
PHP

<?php
final class PhabricatorPeopleProfileMenuEngine
extends PhabricatorProfileMenuEngine {
const ITEM_PROFILE = 'people.profile';
const ITEM_MANAGE = 'people.manage';
protected function isMenuEngineConfigurable() {
return false;
}
protected function getItemURI($path) {
$user = $this->getProfileObject();
$username = $user->getUsername();
$username = phutil_escape_uri($username);
return "/p/{$username}/item/{$path}";
}
protected function getBuiltinProfileItems($object) {
$viewer = $this->getViewer();
$items = array();
$items[] = $this->newItem()
->setBuiltinKey(self::ITEM_PROFILE)
->setMenuItemKey(PhabricatorPeopleDetailsProfileMenuItem::MENUITEMKEY);
$have_maniphest = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorManiphestApplication',
$viewer);
if ($have_maniphest) {
$uri = urisprintf(
'/maniphest/?statuses=open()&assigned=%s#R',
$object->getPHID());
$items[] = $this->newItem()
->setBuiltinKey('tasks')
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
->setMenuItemProperty('icon', 'maniphest')
->setMenuItemProperty('name', pht('Open Tasks'))
->setMenuItemProperty('uri', $uri);
}
$have_differential = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDifferentialApplication',
$viewer);
if ($have_differential) {
$uri = urisprintf(
'/differential/?authors=%s#R',
$object->getPHID());
$items[] = $this->newItem()
->setBuiltinKey('revisions')
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
->setMenuItemProperty('icon', 'differential')
->setMenuItemProperty('name', pht('Revisions'))
->setMenuItemProperty('uri', $uri);
}
$have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDiffusionApplication',
$viewer);
if ($have_diffusion) {
$uri = urisprintf(
'/audit/?authors=%s#R',
$object->getPHID());
$items[] = $this->newItem()
->setBuiltinKey('commits')
->setMenuItemKey(PhabricatorLinkProfileMenuItem::MENUITEMKEY)
->setMenuItemProperty('icon', 'diffusion')
->setMenuItemProperty('name', pht('Commits'))
->setMenuItemProperty('uri', $uri);
}
$items[] = $this->newItem()
->setBuiltinKey(self::ITEM_MANAGE)
->setMenuItemKey(PhabricatorPeopleManageProfileMenuItem::MENUITEMKEY);
return $items;
}
}