Changeset View
Changeset View
Standalone View
Standalone View
src/applications/policy/storage/PhabricatorPolicy.php
Show First 20 Lines • Show All 411 Lines • ▼ Show 20 Lines | public function isStrongerThan(PhabricatorPolicy $other) { | ||||
$strengths = array( | $strengths = array( | ||||
PhabricatorPolicies::POLICY_PUBLIC => -2, | PhabricatorPolicies::POLICY_PUBLIC => -2, | ||||
PhabricatorPolicies::POLICY_USER => -1, | PhabricatorPolicies::POLICY_USER => -1, | ||||
// (Default policies have strength 0.) | // (Default policies have strength 0.) | ||||
PhabricatorPolicies::POLICY_NOONE => 1, | PhabricatorPolicies::POLICY_NOONE => 1, | ||||
); | ); | ||||
$this_strength = idx($strengths, $this->getPHID(), 0); | $this_strength = idx($strengths, $this_policy, 0); | ||||
$other_strength = idx($strengths, $other->getPHID(), 0); | $other_strength = idx($strengths, $other_policy, 0); | ||||
return ($this_strength > $other_strength); | return ($this_strength > $other_strength); | ||||
} | } | ||||
public function isStrongerThanOrEqualTo(PhabricatorPolicy $other) { | |||||
$this_policy = $this->getPHID(); | |||||
$other_policy = $other->getPHID(); | |||||
if ($this_policy === $other_policy) { | |||||
return true; | |||||
} | |||||
return $this->isStrongerThan($other); | |||||
} | |||||
public function isValidPolicyForEdit() { | public function isValidPolicyForEdit() { | ||||
return $this->getType() !== PhabricatorPolicyType::TYPE_MASKED; | return $this->getType() !== PhabricatorPolicyType::TYPE_MASKED; | ||||
} | } | ||||
public static function getSpecialRules( | public static function getSpecialRules( | ||||
PhabricatorPolicyInterface $object, | PhabricatorPolicyInterface $object, | ||||
PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
$capability, | $capability, | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |