2012-07-30 19:43:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @task info Application Information
|
2012-08-06 21:46:51 +02:00
|
|
|
* @task ui UI Integration
|
2012-07-30 19:44:08 +02:00
|
|
|
* @task uri URI Routing
|
2012-07-30 19:43:49 +02:00
|
|
|
* @task fact Fact Integration
|
|
|
|
* @task meta Application Management
|
|
|
|
* @group apps
|
|
|
|
*/
|
2013-10-02 22:13:07 +02:00
|
|
|
abstract class PhabricatorApplication
|
|
|
|
implements PhabricatorPolicyInterface {
|
2012-07-30 19:43:49 +02:00
|
|
|
|
2012-10-04 00:46:19 +02:00
|
|
|
const GROUP_CORE = 'core';
|
|
|
|
const GROUP_COMMUNICATION = 'communication';
|
|
|
|
const GROUP_ORGANIZATION = 'organization';
|
|
|
|
const GROUP_UTILITIES = 'util';
|
|
|
|
const GROUP_ADMIN = 'admin';
|
|
|
|
const GROUP_DEVELOPER = 'developer';
|
|
|
|
const GROUP_MISC = 'misc';
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
const TILE_INVISIBLE = 'invisible';
|
|
|
|
const TILE_HIDE = 'hide';
|
|
|
|
const TILE_SHOW = 'show';
|
|
|
|
const TILE_FULL = 'full';
|
|
|
|
|
2012-10-04 00:46:19 +02:00
|
|
|
public static function getApplicationGroups() {
|
|
|
|
return array(
|
|
|
|
self::GROUP_CORE => pht('Core Applications'),
|
|
|
|
self::GROUP_COMMUNICATION => pht('Communication'),
|
|
|
|
self::GROUP_ORGANIZATION => pht('Organization'),
|
|
|
|
self::GROUP_UTILITIES => pht('Utilities'),
|
|
|
|
self::GROUP_ADMIN => pht('Administration'),
|
|
|
|
self::GROUP_DEVELOPER => pht('Developer Tools'),
|
|
|
|
self::GROUP_MISC => pht('Miscellaneous Applications'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
public static function getTileDisplayName($constant) {
|
|
|
|
$names = array(
|
|
|
|
self::TILE_INVISIBLE => pht('Invisible'),
|
|
|
|
self::TILE_HIDE => pht('Hidden'),
|
|
|
|
self::TILE_SHOW => pht('Show Small Tile'),
|
|
|
|
self::TILE_FULL => pht('Show Large Tile'),
|
|
|
|
);
|
|
|
|
return idx($names, $constant);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-30 19:43:49 +02:00
|
|
|
|
|
|
|
/* -( Application Information )-------------------------------------------- */
|
|
|
|
|
|
|
|
public function getName() {
|
2012-08-01 02:58:21 +02:00
|
|
|
return substr(get_class($this), strlen('PhabricatorApplication'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShortDescription() {
|
|
|
|
return $this->getName().' Application';
|
2012-07-30 19:43:49 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 18:14:03 +01:00
|
|
|
public function isInstalled() {
|
2013-03-13 15:09:05 +01:00
|
|
|
if (!$this->canUninstall()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-06 18:25:13 +02:00
|
|
|
$beta = PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
|
|
|
|
if (!$beta && $this->isBeta()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$uninstalled = PhabricatorEnv::getEnvConfig(
|
|
|
|
'phabricator.uninstalled-applications');
|
|
|
|
|
2013-03-13 15:09:05 +01:00
|
|
|
return empty($uninstalled[get_class($this)]);
|
2013-01-29 18:14:03 +01:00
|
|
|
}
|
|
|
|
|
2013-01-19 19:12:44 +01:00
|
|
|
public function isBeta() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-04 15:46:47 +02:00
|
|
|
/**
|
|
|
|
* Return true if this application should not appear in application lists in
|
|
|
|
* the UI. Primarily intended for unit test applications or other
|
|
|
|
* pseudo-applications.
|
|
|
|
*
|
|
|
|
* @return bool True to remove application from UI lists.
|
|
|
|
*/
|
2013-10-04 04:05:47 +02:00
|
|
|
public function isUnlisted() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
/**
|
|
|
|
* Returns true if an application is first-party (developed by Phacility)
|
|
|
|
* and false otherwise.
|
2013-10-04 15:46:47 +02:00
|
|
|
*
|
|
|
|
* @return bool True if this application is developed by Phacility.
|
2013-10-02 22:13:07 +02:00
|
|
|
*/
|
|
|
|
final public function isFirstParty() {
|
|
|
|
$where = id(new ReflectionClass($this))->getFileName();
|
|
|
|
$root = phutil_get_library_root('phabricator');
|
|
|
|
|
|
|
|
if (!Filesystem::isDescendant($where, $root)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Filesystem::isDescendant($where, $root.'/extensions')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-29 18:14:03 +01:00
|
|
|
public function canUninstall() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-01 02:58:21 +02:00
|
|
|
public function getPHID() {
|
|
|
|
return 'PHID-APPS-'.get_class($this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTypeaheadURI() {
|
|
|
|
return $this->getBaseURI();
|
|
|
|
}
|
2012-07-30 19:43:49 +02:00
|
|
|
|
2012-08-01 02:58:21 +02:00
|
|
|
public function getBaseURI() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-05-31 01:37:51 +02:00
|
|
|
public function getApplicationURI($path = '') {
|
|
|
|
return $this->getBaseURI().ltrim($path, '/');
|
|
|
|
}
|
|
|
|
|
2012-08-01 02:58:21 +02:00
|
|
|
public function getIconURI() {
|
2012-08-14 23:23:55 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
Use application icons for "Eye" menu and Crumbs
Summary:
Issues here:
- Need an application-sized "eye", or a "home" icon for "Phabricator Home".
- Some of the "apps_lb_2x" sliced images are the "_dark_" versions, not the light versions.
- If you slice an application-sized "logout" (power off) icon and application-sized "help" (questionmark in circle) icon I can replace the current menu icons and nearly get rid of "autosprite".
- To replace the icons on /applications/, the non-retina size is "4x", so we'd need "8x" for retina. Alternatively I can reduce the icon sizes by 50%.
- The "Help", "Settings" and "Logout" items currently have a "glowing" hover state, which needs a variant (or we can drop it).
- The /applications/ icons have a white hover state (or we can drop it).
- The 1x application (14x14) icons aren't used anywhere right now, should they be? Maybe in the feed in the future, etc?
- The "apps-2x" and "apps-large" sheets are the same image, but getting them to actually use the same file is a bit tricky, so I just left them separate for now.
Test Plan:
{F26698}
{F26699}
Reviewers: chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T1960
Differential Revision: https://secure.phabricator.com/D4108
2012-12-07 22:37:28 +01:00
|
|
|
public function getIconName() {
|
|
|
|
return 'application';
|
2012-08-01 02:58:21 +02:00
|
|
|
}
|
|
|
|
|
2012-08-02 23:07:21 +02:00
|
|
|
public function shouldAppearInLaunchView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-04 00:46:19 +02:00
|
|
|
public function getApplicationOrder() {
|
|
|
|
return PHP_INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationGroup() {
|
|
|
|
return self::GROUP_MISC;
|
Add basic support for new navigation menu
Summary:
Add a new left-side application menu. This menu shows which application you're in and provides a quick way to get to other applications.
On desktops, menus are always shown but the app menu can be collapsed to be very small.
On tablets, navigation buttons allow you to choose between the menus and the content.
On phones, navigation buttons allow you to choose between the app menu, the local menu, and the content.
This needs some code and UI cleanup, but has no effect yet so I think it's okay to land as-is, I'll clean it up a bit as I start integrating it. I want to play around with it a bit and see if it's good/useful or horrible anyway.
Test Plan: Will include screenshots.
Reviewers: vrana, btrahan, chad
Reviewed By: btrahan
CC: aran, alanh
Maniphest Tasks: T1569
Differential Revision: https://secure.phabricator.com/D3223
2012-08-11 16:06:12 +02:00
|
|
|
}
|
|
|
|
|
2012-08-13 04:19:46 +02:00
|
|
|
public function getTitleGlyph() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-08-14 00:28:41 +02:00
|
|
|
public function getHelpURI() {
|
2014-05-29 21:17:54 +02:00
|
|
|
return null;
|
|
|
|
}
|
2012-08-14 00:28:41 +02:00
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
public function getOverview() {
|
2012-08-14 00:28:41 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-08-24 22:19:47 +02:00
|
|
|
public function getEventListeners() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2013-01-16 18:00:11 +01:00
|
|
|
public function getDefaultTileDisplay(PhabricatorUser $user) {
|
|
|
|
switch ($this->getApplicationGroup()) {
|
|
|
|
case self::GROUP_CORE:
|
|
|
|
return self::TILE_FULL;
|
|
|
|
case self::GROUP_UTILITIES:
|
|
|
|
case self::GROUP_DEVELOPER:
|
|
|
|
return self::TILE_HIDE;
|
|
|
|
case self::GROUP_ADMIN:
|
|
|
|
if ($user->getIsAdmin()) {
|
|
|
|
return self::TILE_SHOW;
|
|
|
|
} else {
|
|
|
|
return self::TILE_INVISIBLE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return self::TILE_SHOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-26 23:59:31 +01:00
|
|
|
public function getRemarkupRules() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2012-08-01 02:58:21 +02:00
|
|
|
|
|
|
|
/* -( URI Routing )-------------------------------------------------------- */
|
2012-07-30 19:44:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
public function getRoutes() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-30 19:43:49 +02:00
|
|
|
/* -( Fact Integration )--------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getFactObjectsForAnalysis() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-06 21:46:51 +02:00
|
|
|
/* -( UI Integration )----------------------------------------------------- */
|
2012-08-02 23:07:21 +02:00
|
|
|
|
|
|
|
|
2012-10-04 00:16:26 +02:00
|
|
|
/**
|
|
|
|
* Render status elements (like "3 Waiting Reviews") for application list
|
|
|
|
* views. These provide a way to alert users to new or pending action items
|
|
|
|
* in applications.
|
|
|
|
*
|
|
|
|
* @param PhabricatorUser Viewing user.
|
|
|
|
* @return list<PhabricatorApplicationStatusView> Application status elements.
|
|
|
|
* @task ui
|
|
|
|
*/
|
2012-08-02 23:07:21 +02:00
|
|
|
public function loadStatus(PhabricatorUser $user) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2012-08-06 21:46:51 +02:00
|
|
|
|
2012-10-04 00:16:26 +02:00
|
|
|
/**
|
|
|
|
* You can provide an optional piece of flavor text for the application. This
|
|
|
|
* is currently rendered in application launch views if the application has no
|
|
|
|
* status elements.
|
|
|
|
*
|
|
|
|
* @return string|null Flavor text.
|
|
|
|
* @task ui
|
|
|
|
*/
|
|
|
|
public function getFlavorText() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-06 21:46:51 +02:00
|
|
|
/**
|
|
|
|
* Build items for the main menu.
|
|
|
|
*
|
|
|
|
* @param PhabricatorUser The viewing user.
|
|
|
|
* @param AphrontController The current controller. May be null for special
|
|
|
|
* pages like 404, exception handlers, etc.
|
2014-01-29 05:18:01 +01:00
|
|
|
* @return list<PHUIListItemView> List of menu items.
|
2012-10-04 00:16:26 +02:00
|
|
|
* @task ui
|
2012-08-06 21:46:51 +02:00
|
|
|
*/
|
2012-08-05 23:12:43 +02:00
|
|
|
public function buildMainMenuItems(
|
|
|
|
PhabricatorUser $user,
|
2012-08-06 21:46:51 +02:00
|
|
|
PhabricatorController $controller = null) {
|
2012-08-05 23:12:43 +02:00
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2012-08-02 23:07:21 +02:00
|
|
|
|
2014-01-29 05:19:20 +01:00
|
|
|
/**
|
|
|
|
* Build extra items for the main menu. Generally, this is used to render
|
|
|
|
* static dropdowns.
|
|
|
|
*
|
|
|
|
* @param PhabricatorUser The viewing user.
|
|
|
|
* @param AphrontController The current controller. May be null for special
|
|
|
|
* pages like 404, exception handlers, etc.
|
|
|
|
* @return view List of menu items.
|
|
|
|
* @task ui
|
|
|
|
*/
|
|
|
|
public function buildMainMenuExtraNodes(
|
|
|
|
PhabricatorUser $viewer,
|
|
|
|
PhabricatorController $controller = null) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-29 05:18:01 +01:00
|
|
|
/**
|
|
|
|
* Build items for the "quick create" menu.
|
|
|
|
*
|
|
|
|
* @param PhabricatorUser The viewing user.
|
|
|
|
* @return list<PHUIListItemView> List of menu items.
|
|
|
|
*/
|
|
|
|
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-30 19:43:49 +02:00
|
|
|
/* -( Application Management )--------------------------------------------- */
|
|
|
|
|
2014-03-15 19:28:02 +01:00
|
|
|
|
2013-01-30 19:53:43 +01:00
|
|
|
public static function getByClass($class_name) {
|
|
|
|
$selected = null;
|
|
|
|
$applications = PhabricatorApplication::getAllApplications();
|
|
|
|
|
|
|
|
foreach ($applications as $application) {
|
|
|
|
if (get_class($application) == $class_name) {
|
|
|
|
$selected = $application;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-14 19:57:41 +02:00
|
|
|
|
|
|
|
if (!$selected) {
|
|
|
|
throw new Exception("No application '{$class_name}'!");
|
|
|
|
}
|
|
|
|
|
2013-01-30 19:53:43 +01:00
|
|
|
return $selected;
|
|
|
|
}
|
|
|
|
|
2013-01-29 18:14:03 +01:00
|
|
|
public static function getAllApplications() {
|
2013-05-16 21:25:26 +02:00
|
|
|
static $applications;
|
2013-01-29 18:14:03 +01:00
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
if ($applications === null) {
|
|
|
|
$apps = id(new PhutilSymbolLoader())
|
|
|
|
->setAncestorClass(__CLASS__)
|
|
|
|
->loadObjects();
|
2013-01-29 18:14:03 +01:00
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
// Reorder the applications into "application order". Notably, this
|
|
|
|
// ensures their event handlers register in application order.
|
|
|
|
$apps = msort($apps, 'getApplicationOrder');
|
|
|
|
$apps = mgroup($apps, 'getApplicationGroup');
|
2013-09-30 18:38:04 +02:00
|
|
|
|
|
|
|
$group_order = array_keys(self::getApplicationGroups());
|
|
|
|
$apps = array_select_keys($apps, $group_order) + $apps;
|
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
$apps = array_mergev($apps);
|
|
|
|
|
|
|
|
$applications = $apps;
|
2013-01-29 18:14:03 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
return $applications;
|
2013-01-29 18:14:03 +01:00
|
|
|
}
|
2012-07-30 19:43:49 +02:00
|
|
|
|
|
|
|
public static function getAllInstalledApplications() {
|
2013-05-16 21:25:26 +02:00
|
|
|
$all_applications = self::getAllApplications();
|
|
|
|
$apps = array();
|
|
|
|
foreach ($all_applications as $app) {
|
|
|
|
if (!$app->isInstalled()) {
|
|
|
|
continue;
|
2012-07-30 19:43:49 +02:00
|
|
|
}
|
2013-01-29 18:14:03 +01:00
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
$apps[] = $app;
|
2012-07-30 19:43:49 +02:00
|
|
|
}
|
|
|
|
|
2013-05-16 21:25:26 +02:00
|
|
|
return $apps;
|
2012-07-30 19:43:49 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 18:14:03 +01:00
|
|
|
|
2014-03-15 19:28:02 +01:00
|
|
|
/**
|
|
|
|
* Determine if an application is installed, by application class name.
|
|
|
|
*
|
|
|
|
* To check if an application is installed //and// available to a particular
|
|
|
|
* viewer, user @{method:isClassInstalledForViewer}.
|
|
|
|
*
|
|
|
|
* @param string Application class name.
|
|
|
|
* @return bool True if the class is installed.
|
|
|
|
* @task meta
|
|
|
|
*/
|
|
|
|
public static function isClassInstalled($class) {
|
|
|
|
return self::getByClass($class)->isInstalled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if an application is installed and available to a viewer, by
|
|
|
|
* application class name.
|
|
|
|
*
|
|
|
|
* To check if an application is installed at all, use
|
|
|
|
* @{method:isClassInstalled}.
|
|
|
|
*
|
|
|
|
* @param string Application class name.
|
|
|
|
* @param PhabricatorUser Viewing user.
|
|
|
|
* @return bool True if the class is installed for the viewer.
|
|
|
|
* @task meta
|
|
|
|
*/
|
|
|
|
public static function isClassInstalledForViewer(
|
|
|
|
$class,
|
|
|
|
PhabricatorUser $viewer) {
|
|
|
|
|
|
|
|
if (!self::isClassInstalled($class)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
self::getByClass($class),
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
2013-10-03 21:40:08 +02:00
|
|
|
return array_merge(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
),
|
|
|
|
array_keys($this->getCustomCapabilities()));
|
2013-10-02 22:13:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
2013-10-03 21:40:08 +02:00
|
|
|
$default = $this->getCustomPolicySetting($capability);
|
|
|
|
if ($default) {
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
2013-10-16 19:35:52 +02:00
|
|
|
return PhabricatorPolicies::getMostOpenPolicy();
|
2013-10-02 22:13:07 +02:00
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return PhabricatorPolicies::POLICY_ADMIN;
|
2013-10-03 21:40:08 +02:00
|
|
|
default:
|
|
|
|
$spec = $this->getCustomCapabilitySpecification($capability);
|
|
|
|
return idx($spec, 'default', PhabricatorPolicies::POLICY_USER);
|
2013-10-02 22:13:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-03 21:40:08 +02:00
|
|
|
/* -( Policies )----------------------------------------------------------- */
|
|
|
|
|
|
|
|
protected function getCustomCapabilities() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getCustomPolicySetting($capability) {
|
|
|
|
if (!$this->isCapabilityEditable($capability)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$config = PhabricatorEnv::getEnvConfig('phabricator.application-settings');
|
|
|
|
|
|
|
|
$app = idx($config, $this->getPHID());
|
|
|
|
if (!$app) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$policy = idx($app, 'policy');
|
|
|
|
if (!$policy) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return idx($policy, $capability);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getCustomCapabilitySpecification($capability) {
|
|
|
|
$custom = $this->getCustomCapabilities();
|
2013-10-09 22:44:41 +02:00
|
|
|
if (!isset($custom[$capability])) {
|
2013-10-03 21:40:08 +02:00
|
|
|
throw new Exception("Unknown capability '{$capability}'!");
|
|
|
|
}
|
|
|
|
return $custom[$capability];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCapabilityLabel($capability) {
|
2013-10-09 22:44:41 +02:00
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return pht('Can Use Application');
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return pht('Can Configure Application');
|
|
|
|
}
|
2013-10-03 21:40:08 +02:00
|
|
|
|
2013-10-09 22:44:41 +02:00
|
|
|
$capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability);
|
|
|
|
if ($capobj) {
|
|
|
|
return $capobj->getCapabilityName();
|
|
|
|
}
|
2013-10-03 21:40:08 +02:00
|
|
|
|
2013-10-09 22:44:41 +02:00
|
|
|
return null;
|
2013-10-03 21:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isCapabilityEditable($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return $this->canUninstall();
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
$spec = $this->getCustomCapabilitySpecification($capability);
|
|
|
|
return idx($spec, 'edit', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCapabilityCaption($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
if (!$this->canUninstall()) {
|
|
|
|
return pht(
|
|
|
|
'This application is required for Phabricator to operate, so all '.
|
|
|
|
'users must have access to it.');
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return null;
|
|
|
|
default:
|
|
|
|
$spec = $this->getCustomCapabilitySpecification($capability);
|
|
|
|
return idx($spec, 'caption');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
}
|