Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13968327
D14467.id35020.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D14467.id35020.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2757,6 +2757,7 @@
'PhabricatorProjectMemberOfProjectEdgeType' => 'applications/project/edge/PhabricatorProjectMemberOfProjectEdgeType.php',
'PhabricatorProjectMembersDatasource' => 'applications/project/typeahead/PhabricatorProjectMembersDatasource.php',
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
+ 'PhabricatorProjectMembersPolicyRule' => 'applications/project/policyrule/PhabricatorProjectMembersOfProjectPolicyRule.php',
'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php',
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
'PhabricatorProjectNoProjectsDatasource' => 'applications/project/typeahead/PhabricatorProjectNoProjectsDatasource.php',
@@ -2767,6 +2768,7 @@
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
'PhabricatorProjectProjectHasMemberEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php',
'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php',
+ 'PhabricatorProjectProjectMembersPolicyRule' => 'applications/project/policyrule/PhabricatorProjectProjectMembersPolicyRule.php',
'PhabricatorProjectProjectPHIDType' => 'applications/project/phid/PhabricatorProjectProjectPHIDType.php',
'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php',
'PhabricatorProjectRemoveHeraldAction' => 'applications/project/herald/PhabricatorProjectRemoveHeraldAction.php',
@@ -2787,7 +2789,6 @@
'PhabricatorProjectViewController' => 'applications/project/controller/PhabricatorProjectViewController.php',
'PhabricatorProjectWatchController' => 'applications/project/controller/PhabricatorProjectWatchController.php',
'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php',
- 'PhabricatorProjectsPolicyRule' => 'applications/policy/rule/PhabricatorProjectsPolicyRule.php',
'PhabricatorProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorProtocolAdapter.php',
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
@@ -6957,6 +6958,7 @@
'PhabricatorProjectMemberOfProjectEdgeType' => 'PhabricatorEdgeType',
'PhabricatorProjectMembersDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController',
+ 'PhabricatorProjectMembersPolicyRule' => 'PhabricatorPolicyRule',
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
'PhabricatorProjectNoProjectsDatasource' => 'PhabricatorTypeaheadDatasource',
@@ -6967,6 +6969,7 @@
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
'PhabricatorProjectProjectHasMemberEdgeType' => 'PhabricatorEdgeType',
'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType',
+ 'PhabricatorProjectProjectMembersPolicyRule' => 'PhabricatorPolicyRule',
'PhabricatorProjectProjectPHIDType' => 'PhabricatorPHIDType',
'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorProjectRemoveHeraldAction' => 'PhabricatorProjectHeraldAction',
@@ -6990,7 +6993,6 @@
'PhabricatorProjectViewController' => 'PhabricatorProjectController',
'PhabricatorProjectWatchController' => 'PhabricatorProjectController',
'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
- 'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
'PhabricatorProtocolAdapter' => 'Phobject',
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorQuery' => 'Phobject',
diff --git a/src/applications/policy/rule/PhabricatorPolicyRule.php b/src/applications/policy/rule/PhabricatorPolicyRule.php
--- a/src/applications/policy/rule/PhabricatorPolicyRule.php
+++ b/src/applications/policy/rule/PhabricatorPolicyRule.php
@@ -11,10 +11,6 @@
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 @@
return;
}
+ abstract public function applyRule(
+ PhabricatorUser $viewer,
+ $value,
+ PhabricatorPolicyInterface $object);
+
public function getValueControlType() {
return self::CONTROL_TYPE_TEXT;
}
@@ -35,7 +36,7 @@
* 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.
*/
public function canApplyToObject(PhabricatorPolicyInterface $object) {
return true;
@@ -43,6 +44,7 @@
protected function getDatasourceTemplate(
PhabricatorTypeaheadDatasource $datasource) {
+
return array(
'markup' => new AphrontTokenizerTemplateView(),
'uri' => $datasource->getDatasourceURI(),
@@ -65,6 +67,7 @@
public function getRequiredHandlePHIDsForSummary($value) {
$phids = array();
+
switch ($this->getValueControlType()) {
case self::CONTROL_TYPE_TOKENIZER:
$phids = $value;
@@ -86,7 +89,7 @@
}
/**
- * 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 @@
$cache->setKey(self::getObjectPolicyCacheKey($object, $rule), $hint);
}
- protected function getTransactionHint(
+ final protected function getTransactionHint(
PhabricatorPolicyInterface $object) {
$cache = PhabricatorCaches::getRequestCache();
@@ -164,7 +167,7 @@
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
--- a/src/applications/project/controller/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -92,7 +92,8 @@
->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())
diff --git a/src/applications/project/policyrule/PhabricatorProjectMembersPolicyRule.php b/src/applications/project/policyrule/PhabricatorProjectMembersPolicyRule.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/policyrule/PhabricatorProjectMembersPolicyRule.php
@@ -0,0 +1,50 @@
+<?php
+
+final class PhabricatorProjectMembersPolicyRule extends PhabricatorPolicyRule {
+
+ public function getRuleDescription() {
+ return pht('members of project');
+ }
+
+ public function applyRule(
+ PhabricatorUser $viewer,
+ $value,
+ PhabricatorPolicyInterface $object) {
+
+ $edge_query = id(new PhabricatorEdgeQuery())
+ ->withSourcePHIDs(array($viewer->getPHID()))
+ ->withDestinationPHIDs(array($object->getPHID()))
+ ->withEdgeTypes(
+ array(
+ PhabricatorProjectMemberOfProjectEdgeType::EDGECONST,
+ ));
+ $edge_query->execute();
+
+ return (bool)$edge_query->getDestinationPHIDs();
+ }
+
+ public function getValueControlType() {
+ return self::CONTROL_TYPE_NONE;
+ }
+
+ public function canApplyToObject(PhabricatorPolicyInterface $object) {
+ return $object instanceof PhabricatorProject;
+ }
+
+ public function getObjectPolicyKey() {
+ return 'project.members';
+ }
+
+ public function getObjectPolicyName() {
+ return pht('Members');
+ }
+
+ public function getObjectPolicyIcon() {
+ return 'fa-users';
+ }
+
+ public function getPolicyExplanation() {
+ return pht('Members can take this action.');
+ }
+
+}
diff --git a/src/applications/policy/rule/PhabricatorProjectsPolicyRule.php b/src/applications/project/policyrule/PhabricatorProjectProjectMembersPolicyRule.php
rename from src/applications/policy/rule/PhabricatorProjectsPolicyRule.php
rename to src/applications/project/policyrule/PhabricatorProjectProjectMembersPolicyRule.php
--- a/src/applications/policy/rule/PhabricatorProjectsPolicyRule.php
+++ b/src/applications/project/policyrule/PhabricatorProjectProjectMembersPolicyRule.php
@@ -1,6 +1,7 @@
<?php
-final class PhabricatorProjectsPolicyRule extends PhabricatorPolicyRule {
+final class PhabricatorProjectProjectMembersPolicyRule
+ extends PhabricatorPolicyRule {
private $memberships = array();
diff --git a/src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php b/src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
--- a/src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
+++ b/src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
@@ -6,26 +6,10 @@
private $subscribed = array();
private $sourcePHIDs = array();
- public function getObjectPolicyKey() {
- return 'subscriptions.subscribers';
- }
-
- public function getObjectPolicyName() {
- return pht('Subscribers');
- }
-
- public function getPolicyExplanation() {
- return pht('Subscribers can take this action.');
- }
-
public function getRuleDescription() {
return pht('subscribers');
}
- public function canApplyToObject(PhabricatorPolicyInterface $object) {
- return ($object instanceof PhabricatorSubscribableInterface);
- }
-
public function willApplyRules(
PhabricatorUser $viewer,
array $values,
@@ -118,4 +102,20 @@
return self::CONTROL_TYPE_NONE;
}
+ public function canApplyToObject(PhabricatorPolicyInterface $object) {
+ return $object instanceof PhabricatorSubscribableInterface;
+ }
+
+ public function getObjectPolicyKey() {
+ return 'subscriptions.subscribers';
+ }
+
+ public function getObjectPolicyName() {
+ return pht('Subscribers');
+ }
+
+ public function getPolicyExplanation() {
+ return pht('Subscribers can take this action.');
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 17, 8:07 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723267
Default Alt Text
D14467.id35020.diff (10 KB)
Attached To
Mode
D14467: Add a "members of project" policy rule
Attached
Detach File
Event Timeline
Log In to Comment