Changeset View
Changeset View
Standalone View
Standalone View
src/applications/policy/storage/PhabricatorPolicy.php
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | switch ($this->getType()) { | ||||
return pht('Other: %s', $this->getName()); | return pht('Other: %s', $this->getName()); | ||||
case PhabricatorPolicyType::TYPE_USER: | case PhabricatorPolicyType::TYPE_USER: | ||||
return pht('Only User: %s', $this->getName()); | return pht('Only User: %s', $this->getName()); | ||||
default: | default: | ||||
return $this->getName(); | return $this->getName(); | ||||
} | } | ||||
} | } | ||||
public function renderDescription() { | public function newRef(PhabricatorUser $viewer) { | ||||
if ($this->getHref()) { | return id(new PhabricatorPolicyRef()) | ||||
$desc = javelin_tag( | ->setViewer($viewer) | ||||
'a', | ->setPolicy($this); | ||||
array( | |||||
'href' => $this->getHref(), | |||||
'class' => 'policy-link', | |||||
'sigil' => $this->getWorkflow() ? 'workflow' : null, | |||||
), | |||||
$this->getName()); | |||||
} else { | |||||
$desc = $this->getName(); | |||||
} | } | ||||
switch ($this->getType()) { | public function isProjectPolicy() { | ||||
case PhabricatorPolicyType::TYPE_PROJECT: | return ($this->getType() === PhabricatorPolicyType::TYPE_PROJECT); | ||||
return pht('%s (Project)', $desc); | |||||
case PhabricatorPolicyType::TYPE_CUSTOM: | |||||
return $desc; | |||||
case PhabricatorPolicyType::TYPE_MASKED: | |||||
return pht( | |||||
'%s (You do not have permission to view policy details.)', | |||||
$desc); | |||||
default: | |||||
return $desc; | |||||
} | } | ||||
public function isCustomPolicy() { | |||||
return ($this->getType() === PhabricatorPolicyType::TYPE_CUSTOM); | |||||
} | |||||
public function isMaskedPolicy() { | |||||
return ($this->getType() === PhabricatorPolicyType::TYPE_MASKED); | |||||
} | } | ||||
/** | /** | ||||
* Return a list of custom rule classes (concrete subclasses of | * Return a list of custom rule classes (concrete subclasses of | ||||
* @{class:PhabricatorPolicyRule}) this policy uses. | * @{class:PhabricatorPolicyRule}) this policy uses. | ||||
* | * | ||||
* @return list<string> List of class names. | * @return list<string> List of class names. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |