Index: src/applications/policy/constants/PhabricatorPolicyType.php =================================================================== --- src/applications/policy/constants/PhabricatorPolicyType.php +++ src/applications/policy/constants/PhabricatorPolicyType.php @@ -3,13 +3,15 @@ final class PhabricatorPolicyType extends PhabricatorPolicyConstants { const TYPE_GLOBAL = 'global'; + const TYPE_CUSTOM = 'custom'; const TYPE_PROJECT = 'project'; const TYPE_MASKED = 'masked'; public static function getPolicyTypeOrder($type) { static $map = array( self::TYPE_GLOBAL => 0, - self::TYPE_PROJECT => 1, + self::TYPE_CUSTOM => 1, + self::TYPE_PROJECT => 2, self::TYPE_MASKED => 9, ); return idx($map, $type, 9); @@ -19,6 +21,8 @@ switch ($type) { case self::TYPE_GLOBAL: return pht('Basic Policies'); + case self::TYPE_CUSTOM: + return pht('Advanced'); case self::TYPE_PROJECT: return pht('Members of Project...'); case self::TYPE_MASKED: Index: src/applications/policy/storage/PhabricatorPolicy.php =================================================================== --- src/applications/policy/storage/PhabricatorPolicy.php +++ src/applications/policy/storage/PhabricatorPolicy.php @@ -64,6 +64,12 @@ $policy->setType(PhabricatorPolicyType::TYPE_PROJECT); $policy->setName($handle->getName()); break; + case PhabricatorPolicyPHIDTypePolicy::TYPECONST: + // TODO: This creates a weird handle-based version of a rule policy. + // It behaves correctly, but can't be applied since it doesn't have + // any rules. It is used to render transactions, and might need some + // cleanup. + break; default: $policy->setType(PhabricatorPolicyType::TYPE_MASKED); $policy->setName($handle->getFullName()); @@ -81,6 +87,9 @@ } public function getType() { + if (!$this->type) { + return PhabricatorPolicyType::TYPE_CUSTOM; + } return $this->type; } @@ -90,6 +99,9 @@ } public function getName() { + if (!$this->name) { + return pht('Custom Policy'); + } return $this->name; } @@ -116,6 +128,7 @@ case PhabricatorPolicyType::TYPE_PROJECT: return 'policy-project'; break; + case PhabricatorPolicyType::TYPE_CUSTOM: case PhabricatorPolicyType::TYPE_MASKED: return 'policy-custom'; break; @@ -173,6 +186,10 @@ return pht( '%s can take this action.', $handle->getFullName()); + } else if ($type == PhabricatorPolicyPHIDTypePolicy::TYPECONST) { + return pht( + 'This object has a custom policy controlling who can take this '. + 'action.'); } else { return pht( 'This object has an unknown or invalid policy setting ("%s").', @@ -222,6 +239,8 @@ switch ($this->getType()) { case PhabricatorPolicyType::TYPE_PROJECT: return pht('%s (Project)', $desc); + case PhabricatorPolicyType::TYPE_CUSTOM: + return pht('Custom Policy'); case PhabricatorPolicyType::TYPE_MASKED: return pht( '%s (You do not have permission to view policy details.)',