Changeset View
Changeset View
Standalone View
Standalone View
src/applications/base/PhabricatorApplication.php
| Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | /* -( Application Management )--------------------------------------------- */ | ||||
| * @param PhabricatorUser Viewing user. | * @param PhabricatorUser Viewing user. | ||||
| * @return bool True if the class is installed for the viewer. | * @return bool True if the class is installed for the viewer. | ||||
| * @task meta | * @task meta | ||||
| */ | */ | ||||
| final public static function isClassInstalledForViewer( | final public static function isClassInstalledForViewer( | ||||
| $class, | $class, | ||||
| PhabricatorUser $viewer) { | PhabricatorUser $viewer) { | ||||
| if (!self::isClassInstalled($class)) { | $cache = PhabricatorCaches::getRequestCache(); | ||||
| return false; | $viewer_phid = $viewer->getPHID(); | ||||
| } | $key = 'app.'.$class.'.installed.'.$viewer_phid; | ||||
| return PhabricatorPolicyFilter::hasCapability( | $result = $cache->getKey($key); | ||||
| if ($result === null) { | |||||
| if (!self::isClassInstalled($class)) { | |||||
| $result = false; | |||||
| } else { | |||||
| $result = PhabricatorPolicyFilter::hasCapability( | |||||
| $viewer, | $viewer, | ||||
| self::getByClass($class), | self::getByClass($class), | ||||
| PhabricatorPolicyCapability::CAN_VIEW); | PhabricatorPolicyCapability::CAN_VIEW); | ||||
| } | } | ||||
| $cache->setKey($key, $result); | |||||
| } | |||||
| return $result; | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array_merge( | return array_merge( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| ▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines | |||||