@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a 'create' policy to Project

Summary: UX on this could probably be better 'disabled' crumbs don't appear to have any visible difference, and the policy error has to load the /create page rather than being a modal - not sure on the way to fix these.

Test Plan: Tried to create a project with and without access, saw suitable error.

Reviewers: epriestley, #blessed_reviewers

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7279

authored by

Asher Baker and committed by
epriestley
8cc64a96 c39b10aa

+38 -1
+2
src/__phutil_library_map__.php
··· 2018 2018 'PonderVote' => 'applications/ponder/constants/PonderVote.php', 2019 2019 'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php', 2020 2020 'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php', 2021 + 'ProjectCapabilityCreateProjects' => 'applications/project/capability/ProjectCapabilityCreateProjects.php', 2021 2022 'ProjectRemarkupRule' => 'applications/project/remarkup/ProjectRemarkupRule.php', 2022 2023 'QueryFormattingTestCase' => 'infrastructure/storage/__tests__/QueryFormattingTestCase.php', 2023 2024 'ReleephAuthorFieldSpecification' => 'applications/releeph/field/specification/ReleephAuthorFieldSpecification.php', ··· 4309 4310 'PonderVote' => 'PonderConstants', 4310 4311 'PonderVoteEditor' => 'PhabricatorEditor', 4311 4312 'PonderVoteSaveController' => 'PonderController', 4313 + 'ProjectCapabilityCreateProjects' => 'PhabricatorPolicyCapability', 4312 4314 'ProjectRemarkupRule' => 'PhabricatorRemarkupRuleObject', 4313 4315 'QueryFormattingTestCase' => 'PhabricatorTestCase', 4314 4316 'ReleephAuthorFieldSpecification' => 'ReleephFieldSpecification',
+7
src/applications/project/application/PhabricatorApplicationProject.php
··· 49 49 ); 50 50 } 51 51 52 + protected function getCustomCapabilities() { 53 + return array( 54 + ProjectCapabilityCreateProjects::CAPABILITY => array( 55 + ), 56 + ); 57 + } 58 + 52 59 }
+20
src/applications/project/capability/ProjectCapabilityCreateProjects.php
··· 1 + <?php 2 + 3 + final class ProjectCapabilityCreateProjects 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'project.create'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Can Create Projects'); 14 + } 15 + 16 + public function describeCapabilityRejection() { 17 + return pht('You do not have permission to create new projects.'); 18 + } 19 + 20 + }
+6 -1
src/applications/project/controller/PhabricatorProjectController.php
··· 24 24 public function buildApplicationCrumbs() { 25 25 $crumbs = parent::buildApplicationCrumbs(); 26 26 27 + $can_create = $this->hasApplicationCapability( 28 + ProjectCapabilityCreateProjects::CAPABILITY); 29 + 27 30 $crumbs->addAction( 28 31 id(new PHUIListItemView()) 29 32 ->setName(pht('Create Project')) 30 33 ->setHref($this->getApplicationURI('create/')) 31 - ->setIcon('create')); 34 + ->setIcon('create') 35 + ->setWorkflow(!$can_create) 36 + ->setDisabled(!$can_create)); 32 37 33 38 return $crumbs; 34 39 }
+3
src/applications/project/controller/PhabricatorProjectCreateController.php
··· 9 9 $request = $this->getRequest(); 10 10 $user = $request->getUser(); 11 11 12 + $this->requireApplicationCapability( 13 + ProjectCapabilityCreateProjects::CAPABILITY); 14 + 12 15 $project = new PhabricatorProject(); 13 16 $project->setAuthorPHID($user->getPHID()); 14 17 $project->attachMemberPHIDs(array());