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