Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/codex/PhrictionDocumentPolicyCodex.php
Show All 35 Lines | public function getDefaultPolicy() { | ||||
$root_policy_phid = $root->getPolicy($this->getCapability()); | $root_policy_phid = $root->getPolicy($this->getCapability()); | ||||
return id(new PhabricatorPolicyQuery()) | return id(new PhabricatorPolicyQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs(array($root_policy_phid)) | ->withPHIDs(array($root_policy_phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
} | } | ||||
public function compareToDefaultPolicy(PhabricatorPolicy $policy) { | |||||
$root_policy = $this->getDefaultPolicy(); | |||||
$strongest_policy = $this->getStrongestPolicy(); | |||||
// Note that we never return 'weaker', because Phriction documents can | |||||
// never have weaker permissions than their parents. If this object has | |||||
// been set to weaker permissions anyway, return 'adjusted'. | |||||
if ($root_policy == $strongest_policy) { | |||||
$strength = null; | |||||
} else if ($strongest_policy->isStrongerThan($root_policy)) { | |||||
$strength = PhabricatorPolicyStrengthConstants::STRONGER; | |||||
} else { | |||||
$strength = PhabricatorPolicyStrengthConstants::ADJUSTED; | |||||
} | |||||
return $strength; | |||||
} | |||||
private function getStrongestPolicy() { | private function getStrongestPolicy() { | ||||
$ancestors = $this->getObject()->getAncestors(); | $ancestors = $this->getObject()->getAncestors(); | ||||
$ancestors[] = $this->getObject(); | $ancestors[] = $this->getObject(); | ||||
$strongest_policy = $this->getDefaultPolicy(); | $strongest_policy = $this->getDefaultPolicy(); | ||||
foreach ($ancestors as $ancestor) { | foreach ($ancestors as $ancestor) { | ||||
$ancestor_policy_phid = $ancestor->getPolicy($this->getCapability()); | $ancestor_policy_phid = $ancestor->getPolicy($this->getCapability()); | ||||
Show All 14 Lines |