Allow "Default View" policies to be set to Public
Summary: Ref T603. Currently, we hard-code defense against setting policies to "Public" in several places, and special case only the CAN_VIEW policy. In fact, other policies (like Default View) should also be able to be set to public. Instead of hard-coding this, move it to the capability definitions. Test Plan: Set default view policy in Maniphest to "Public", created a task, verified default policy. Reviewers: btrahan, asherkin Reviewed By: asherkin CC: asherkin, aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7276
This commit is contained in:
@@ -36,12 +36,16 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
|
||||
}
|
||||
|
||||
protected function getOptions() {
|
||||
$capability = $this->capability;
|
||||
|
||||
$options = array();
|
||||
foreach ($this->policies as $policy) {
|
||||
if (($policy->getPHID() == PhabricatorPolicies::POLICY_PUBLIC) &&
|
||||
($this->capability != PhabricatorPolicyCapability::CAN_VIEW)) {
|
||||
// Never expose "Public" for anything except "Can View".
|
||||
continue;
|
||||
if ($policy->getPHID() == PhabricatorPolicies::POLICY_PUBLIC) {
|
||||
// Never expose "Public" for capabilities which don't support it.
|
||||
$capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability);
|
||||
if (!$capobj || !$capobj->shouldAllowPublicPolicySetting()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$type_name = PhabricatorPolicyType::getPolicyTypeName($policy->getType());
|
||||
|
||||
Reference in New Issue
Block a user