Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13995163
D10890.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D10890.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
@@ -2848,6 +2848,9 @@
'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php',
'ProjectCreateConduitAPIMethod' => 'applications/project/conduit/ProjectCreateConduitAPIMethod.php',
'ProjectCreateProjectsCapability' => 'applications/project/capability/ProjectCreateProjectsCapability.php',
+ 'ProjectDefaultEditCapability' => 'applications/project/capability/ProjectDefaultEditCapability.php',
+ 'ProjectDefaultJoinCapability' => 'applications/project/capability/ProjectDefaultJoinCapability.php',
+ 'ProjectDefaultViewCapability' => 'applications/project/capability/ProjectDefaultViewCapability.php',
'ProjectQueryConduitAPIMethod' => 'applications/project/conduit/ProjectQueryConduitAPIMethod.php',
'ProjectRemarkupRule' => 'applications/project/remarkup/ProjectRemarkupRule.php',
'ProjectRemarkupRuleTestCase' => 'applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php',
@@ -6090,6 +6093,9 @@
'ProjectConduitAPIMethod' => 'ConduitAPIMethod',
'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod',
'ProjectCreateProjectsCapability' => 'PhabricatorPolicyCapability',
+ 'ProjectDefaultEditCapability' => 'PhabricatorPolicyCapability',
+ 'ProjectDefaultJoinCapability' => 'PhabricatorPolicyCapability',
+ 'ProjectDefaultViewCapability' => 'PhabricatorPolicyCapability',
'ProjectQueryConduitAPIMethod' => 'ProjectConduitAPIMethod',
'ProjectRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'ProjectRemarkupRuleTestCase' => 'PhabricatorTestCase',
diff --git a/src/applications/project/application/PhabricatorProjectApplication.php b/src/applications/project/application/PhabricatorProjectApplication.php
--- a/src/applications/project/application/PhabricatorProjectApplication.php
+++ b/src/applications/project/application/PhabricatorProjectApplication.php
@@ -98,6 +98,18 @@
ProjectCanLockProjectsCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_ADMIN,
),
+ ProjectDefaultViewCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default view policy for newly created projects.'),
+ ),
+ ProjectDefaultEditCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default edit policy for newly created projects.'),
+ ),
+ ProjectDefaultJoinCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default join policy for newly created projects.'),
+ ),
);
}
diff --git a/src/applications/project/capability/ProjectDefaultEditCapability.php b/src/applications/project/capability/ProjectDefaultEditCapability.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/capability/ProjectDefaultEditCapability.php
@@ -0,0 +1,12 @@
+<?php
+
+final class ProjectDefaultEditCapability
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'project.default.edit';
+
+ public function getCapabilityName() {
+ return pht('Default Edit Policy');
+ }
+
+}
diff --git a/src/applications/project/capability/ProjectDefaultJoinCapability.php b/src/applications/project/capability/ProjectDefaultJoinCapability.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/capability/ProjectDefaultJoinCapability.php
@@ -0,0 +1,12 @@
+<?php
+
+final class ProjectDefaultJoinCapability
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'project.default.join';
+
+ public function getCapabilityName() {
+ return pht('Default Join Policy');
+ }
+
+}
diff --git a/src/applications/project/capability/ProjectDefaultViewCapability.php b/src/applications/project/capability/ProjectDefaultViewCapability.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/capability/ProjectDefaultViewCapability.php
@@ -0,0 +1,15 @@
+<?php
+
+final class ProjectDefaultViewCapability
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'project.default.view';
+
+ public function getCapabilityName() {
+ return pht('Default View Policy');
+ }
+
+ public function shouldAllowPublicPolicySetting() {
+ return true;
+ }
+}
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -36,14 +36,26 @@
const TABLE_DATASOURCE_TOKEN = 'project_datasourcetoken';
public static function initializeNewProject(PhabricatorUser $actor) {
+ $app = id(new PhabricatorApplicationQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withClasses(array('PhabricatorProjectApplication'))
+ ->executeOne();
+
+ $view_policy = $app->getPolicy(
+ ProjectDefaultViewCapability::CAPABILITY);
+ $edit_policy = $app->getPolicy(
+ ProjectDefaultEditCapability::CAPABILITY);
+ $join_policy = $app->getPolicy(
+ ProjectDefaultJoinCapability::CAPABILITY);
+
return id(new PhabricatorProject())
->setName('')
->setAuthorPHID($actor->getPHID())
->setIcon(self::DEFAULT_ICON)
->setColor(self::DEFAULT_COLOR)
- ->setViewPolicy(PhabricatorPolicies::POLICY_USER)
- ->setEditPolicy(PhabricatorPolicies::POLICY_USER)
- ->setJoinPolicy(PhabricatorPolicies::POLICY_USER)
+ ->setViewPolicy($view_policy)
+ ->setEditPolicy($edit_policy)
+ ->setJoinPolicy($join_policy)
->setIsMembershipLocked(0)
->attachMemberPHIDs(array())
->attachSlugs(array());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 24, 11:03 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731533
Default Alt Text
D10890.diff (5 KB)
Attached To
Mode
D10890: Add default View, Edit, and Join Policies to Projects
Attached
Detach File
Event Timeline
Log In to Comment