From dc5397b2db5d26da2b7850776fb92b5fdb453fe8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 Dec 2015 16:29:06 -0800 Subject: [PATCH] Trivial fixes from D14467 Summary: See D14467. Just teasing this apart so I can be a little more confident in my commandeering. These are the unambiguous cleanup changes from D14467. Test Plan: inspection / clicked stuff / no impact Reviewers: chad, joshuaspence Reviewed By: joshuaspence Differential Revision: https://secure.phabricator.com/D14868 --- .../policy/rule/PhabricatorPolicyRule.php | 19 +++++++++++-------- .../PhabricatorProjectProfileController.php | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/applications/policy/rule/PhabricatorPolicyRule.php b/src/applications/policy/rule/PhabricatorPolicyRule.php index 59fcc954c7..bd5af9a1b8 100644 --- a/src/applications/policy/rule/PhabricatorPolicyRule.php +++ b/src/applications/policy/rule/PhabricatorPolicyRule.php @@ -11,10 +11,6 @@ abstract class PhabricatorPolicyRule extends Phobject { const CONTROL_TYPE_NONE = 'none'; abstract public function getRuleDescription(); - abstract public function applyRule( - PhabricatorUser $viewer, - $value, - PhabricatorPolicyInterface $object); public function willApplyRules( PhabricatorUser $viewer, @@ -23,6 +19,11 @@ abstract class PhabricatorPolicyRule extends Phobject { return; } + abstract public function applyRule( + PhabricatorUser $viewer, + $value, + PhabricatorPolicyInterface $object); + public function getValueControlType() { return self::CONTROL_TYPE_TEXT; } @@ -35,7 +36,7 @@ abstract class PhabricatorPolicyRule extends Phobject { * Return `true` if this rule can be applied to the given object. * * Some policy rules may only operation on certain kinds of objects. For - * example, a "task author" rule + * example, a "task author" rule can only operate on tasks. */ public function canApplyToObject(PhabricatorPolicyInterface $object) { return true; @@ -43,6 +44,7 @@ abstract class PhabricatorPolicyRule extends Phobject { protected function getDatasourceTemplate( PhabricatorTypeaheadDatasource $datasource) { + return array( 'markup' => new AphrontTokenizerTemplateView(), 'uri' => $datasource->getDatasourceURI(), @@ -65,6 +67,7 @@ abstract class PhabricatorPolicyRule extends Phobject { public function getRequiredHandlePHIDsForSummary($value) { $phids = array(); + switch ($this->getValueControlType()) { case self::CONTROL_TYPE_TOKENIZER: $phids = $value; @@ -86,7 +89,7 @@ abstract class PhabricatorPolicyRule extends Phobject { } /** - * Return true if the given value creates a rule with a meaningful effect. + * Return `true` if the given value creates a rule with a meaningful effect. * An example of a rule with no meaningful effect is a "users" rule with no * users specified. * @@ -131,7 +134,7 @@ abstract class PhabricatorPolicyRule extends Phobject { $cache->setKey(self::getObjectPolicyCacheKey($object, $rule), $hint); } - protected function getTransactionHint( + final protected function getTransactionHint( PhabricatorPolicyInterface $object) { $cache = PhabricatorCaches::getRequestCache(); @@ -164,7 +167,7 @@ abstract class PhabricatorPolicyRule extends Phobject { return null; } - public function getObjectPolicyFullKey() { + final public function getObjectPolicyFullKey() { $key = $this->getObjectPolicyKey(); if (!$key) { diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index e45da78fc8..89880bdd1a 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -91,7 +91,8 @@ final class PhabricatorProjectProfileController ->setName(pht('Edit Details')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI("details/{$id}/")) - ->setDisabled(!$can_edit)); + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit)); $view->addAction( id(new PhabricatorActionView())