Changeset View
Changeset View
Standalone View
Standalone View
src/applications/base/PhabricatorApplication.php
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public function isInstalled() { | ||||
| } | } | ||||
| $uninstalled = PhabricatorEnv::getEnvConfig( | $uninstalled = PhabricatorEnv::getEnvConfig( | ||||
| 'phabricator.uninstalled-applications'); | 'phabricator.uninstalled-applications'); | ||||
| return empty($uninstalled[get_class($this)]); | return empty($uninstalled[get_class($this)]); | ||||
| } | } | ||||
| public static function isClassInstalled($class) { | |||||
| return self::getByClass($class)->isInstalled(); | |||||
| } | |||||
| public function isBeta() { | public function isBeta() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Return true if this application should not appear in application lists in | * Return true if this application should not appear in application lists in | ||||
| * the UI. Primarily intended for unit test applications or other | * the UI. Primarily intended for unit test applications or other | ||||
| * pseudo-applications. | * pseudo-applications. | ||||
| ▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | /* -( UI Integration )----------------------------------------------------- */ | ||||
| */ | */ | ||||
| public function getQuickCreateItems(PhabricatorUser $viewer) { | public function getQuickCreateItems(PhabricatorUser $viewer) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| /* -( Application Management )--------------------------------------------- */ | /* -( Application Management )--------------------------------------------- */ | ||||
| public static function getByClass($class_name) { | public static function getByClass($class_name) { | ||||
| $selected = null; | $selected = null; | ||||
| $applications = PhabricatorApplication::getAllApplications(); | $applications = PhabricatorApplication::getAllApplications(); | ||||
| foreach ($applications as $application) { | foreach ($applications as $application) { | ||||
| if (get_class($application) == $class_name) { | if (get_class($application) == $class_name) { | ||||
| $selected = $application; | $selected = $application; | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | foreach ($all_applications as $app) { | ||||
| $apps[] = $app; | $apps[] = $app; | ||||
| } | } | ||||
| return $apps; | return $apps; | ||||
| } | } | ||||
| /** | |||||
| * 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); | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array_merge( | return array_merge( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||