diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5ca6db4847..513ab86945 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2018,6 +2018,7 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index 9ef71d2a6b..22d8faa7f1 100644 --- a/src/applications/project/application/PhabricatorApplicationProject.php +++ b/src/applications/project/application/PhabricatorApplicationProject.php @@ -49,4 +49,11 @@ final class PhabricatorApplicationProject extends PhabricatorApplication { ); } + 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 index 0000000000..b46f40b749 --- /dev/null +++ b/src/applications/project/capability/ProjectCapabilityCreateProjects.php @@ -0,0 +1,20 @@ +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 index 137c1ae086..9c3b214101 100644 --- a/src/applications/project/controller/PhabricatorProjectCreateController.php +++ b/src/applications/project/controller/PhabricatorProjectCreateController.php @@ -9,6 +9,9 @@ final class PhabricatorProjectCreateController $request = $this->getRequest(); $user = $request->getUser(); + $this->requireApplicationCapability( + ProjectCapabilityCreateProjects::CAPABILITY); + $project = new PhabricatorProject(); $project->setAuthorPHID($user->getPHID()); $project->attachMemberPHIDs(array());