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 @@ -2670,6 +2670,7 @@ 'PhabricatorPhurlURL' => 'applications/phurl/storage/PhabricatorPhurlURL.php', 'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php', 'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php', + 'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php', 'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php', 'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php', 'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php', @@ -6848,6 +6849,7 @@ ), 'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController', 'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController', + 'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability', 'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController', 'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController', diff --git a/src/applications/phurl/application/PhabricatorPhurlApplication.php b/src/applications/phurl/application/PhabricatorPhurlApplication.php --- a/src/applications/phurl/application/PhabricatorPhurlApplication.php +++ b/src/applications/phurl/application/PhabricatorPhurlApplication.php @@ -60,4 +60,12 @@ ); } + protected function getCustomCapabilities() { + return array( + PhabricatorPhurlURLCreateCapability::CAPABILITY => array( + 'default' => PhabricatorPolicies::POLICY_USER, + ), + ); + } + } diff --git a/src/applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php b/src/applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php new file mode 100644 --- /dev/null +++ b/src/applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php @@ -0,0 +1,16 @@ +hasApplicationCapability( + PhabricatorPhurlURLCreateCapability::CAPABILITY); + $crumbs = parent::buildApplicationCrumbs(); $crumbs->addAction( id(new PHUIListItemView()) ->setName(pht('Shorten URL')) ->setHref($this->getApplicationURI().'url/create/') - ->setIcon('fa-plus-square')); + ->setIcon('fa-plus-square') + ->setDisabled(!$can_create) + ->setWorkflow(!$can_create)); return $crumbs; } diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php b/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php --- a/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php +++ b/src/applications/phurl/controller/PhabricatorPhurlURLEditController.php @@ -17,6 +17,9 @@ $uri_query = $request->getStr('query'); if ($is_create) { + $this->requireApplicationCapability( + PhabricatorPhurlURLCreateCapability::CAPABILITY); + $url = PhabricatorPhurlURL::initializeNewPhurlURL( $viewer); $submit_label = pht('Create');