Page MenuHomePhabricator

D10890.id.diff
No OneTemporary

D10890.id.diff

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

Mime Type
text/plain
Expires
Oct 19 2024, 9:59 AM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731533
Default Alt Text
D10890.id.diff (5 KB)

Event Timeline