Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13979114
D14467.id34987.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14467.id34987.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',
+ 'PhabricatorProjectMembersOfProjectPolicyRule' => 'applications/project/policyrule/PhabricatorProjectMembersOfProjectPolicyRule.php',
'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php',
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
'PhabricatorProjectNoProjectsDatasource' => 'applications/project/typeahead/PhabricatorProjectNoProjectsDatasource.php',
@@ -6957,6 +6958,7 @@
'PhabricatorProjectMemberOfProjectEdgeType' => 'PhabricatorEdgeType',
'PhabricatorProjectMembersDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController',
+ 'PhabricatorProjectMembersOfProjectPolicyRule' => 'PhabricatorPolicyRule',
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
'PhabricatorProjectNoProjectsDatasource' => 'PhabricatorTypeaheadDatasource',
diff --git a/src/applications/project/policyrule/PhabricatorProjectMembersOfProjectPolicyRule.php b/src/applications/project/policyrule/PhabricatorProjectMembersOfProjectPolicyRule.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/policyrule/PhabricatorProjectMembersOfProjectPolicyRule.php
@@ -0,0 +1,47 @@
+<?php
+
+final class PhabricatorProjectMembersOfProjectPolicyRule
+ extends PhabricatorPolicyRule {
+
+ public function getObjectPolicyKey() {
+ return 'project.members';
+ }
+
+ public function getObjectPolicyName() {
+ return pht('Members');
+ }
+
+ public function getPolicyExplanation() {
+ return pht('Members can take this action.');
+ }
+
+ public function getRuleDescription() {
+ return pht('members of project');
+ }
+
+ public function canApplyToObject(PhabricatorPolicyInterface $object) {
+ return $object instanceof PhabricatorProject;
+ }
+
+ 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;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 2:45 AM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6734819
Default Alt Text
D14467.id34987.diff (3 KB)
Attached To
Mode
D14467: Add a "members of project" policy rule
Attached
Detach File
Event Timeline
Log In to Comment