Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F69070
D7279.diff
All Users
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
D7279.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
@@ -2018,6 +2018,7 @@
'PonderVote' => 'applications/ponder/constants/PonderVote.php',
'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php',
'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php',
+ 'ProjectCapabilityCreateProjects' => 'applications/project/capability/ProjectCapabilityCreateProjects.php',
'ProjectRemarkupRule' => 'applications/project/remarkup/ProjectRemarkupRule.php',
'QueryFormattingTestCase' => 'infrastructure/storage/__tests__/QueryFormattingTestCase.php',
'ReleephAuthorFieldSpecification' => 'applications/releeph/field/specification/ReleephAuthorFieldSpecification.php',
@@ -4309,6 +4310,7 @@
'PonderVote' => 'PonderConstants',
'PonderVoteEditor' => 'PhabricatorEditor',
'PonderVoteSaveController' => 'PonderController',
+ 'ProjectCapabilityCreateProjects' => 'PhabricatorPolicyCapability',
'ProjectRemarkupRule' => 'PhabricatorRemarkupRuleObject',
'QueryFormattingTestCase' => 'PhabricatorTestCase',
'ReleephAuthorFieldSpecification' => 'ReleephFieldSpecification',
diff --git a/src/applications/project/application/PhabricatorApplicationProject.php b/src/applications/project/application/PhabricatorApplicationProject.php
--- a/src/applications/project/application/PhabricatorApplicationProject.php
+++ b/src/applications/project/application/PhabricatorApplicationProject.php
@@ -49,4 +49,11 @@
);
}
+ protected function getCustomCapabilities() {
+ return array(
+ ProjectCapabilityCreateProjects::CAPABILITY => array(
+ ),
+ );
+ }
+
}
diff --git a/src/applications/project/capability/ProjectCapabilityCreateProjects.php b/src/applications/project/capability/ProjectCapabilityCreateProjects.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/capability/ProjectCapabilityCreateProjects.php
@@ -0,0 +1,20 @@
+<?php
+
+final class ProjectCapabilityCreateProjects
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'project.create';
+
+ public function getCapabilityKey() {
+ return self::CAPABILITY;
+ }
+
+ public function getCapabilityName() {
+ return pht('Can Create Projects');
+ }
+
+ public function describeCapabilityRejection() {
+ return pht('You do not have permission to create new projects.');
+ }
+
+}
diff --git a/src/applications/project/controller/PhabricatorProjectController.php b/src/applications/project/controller/PhabricatorProjectController.php
--- a/src/applications/project/controller/PhabricatorProjectController.php
+++ b/src/applications/project/controller/PhabricatorProjectController.php
@@ -24,11 +24,16 @@
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
+ $can_create = $this->hasApplicationCapability(
+ ProjectCapabilityCreateProjects::CAPABILITY);
+
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Project'))
->setHref($this->getApplicationURI('create/'))
- ->setIcon('create'));
+ ->setIcon('create')
+ ->setWorkflow(!$can_create)
+ ->setDisabled(!$can_create));
return $crumbs;
}
diff --git a/src/applications/project/controller/PhabricatorProjectCreateController.php b/src/applications/project/controller/PhabricatorProjectCreateController.php
--- a/src/applications/project/controller/PhabricatorProjectCreateController.php
+++ b/src/applications/project/controller/PhabricatorProjectCreateController.php
@@ -9,6 +9,9 @@
$request = $this->getRequest();
$user = $request->getUser();
+ $this->requireApplicationCapability(
+ ProjectCapabilityCreateProjects::CAPABILITY);
+
$project = new PhabricatorProject();
$project->setAuthorPHID($user->getPHID());
$project->attachMemberPHIDs(array());
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/ui/z4/pxmrtkxgeavnsbrq
Default Alt Text
D7279.diff (3 KB)
Attached To
Mode
D7279: Add a 'create' policy to Project
Attached
Detach File
Event Timeline
Log In to Comment