Page MenuHomePhabricator

D11702.diff
No OneTemporary

D11702.diff

diff --git a/src/applications/people/application/PhabricatorPeopleApplication.php b/src/applications/people/application/PhabricatorPeopleApplication.php
--- a/src/applications/people/application/PhabricatorPeopleApplication.php
+++ b/src/applications/people/application/PhabricatorPeopleApplication.php
@@ -164,12 +164,23 @@
public function getQuickCreateItems(PhabricatorUser $viewer) {
$items = array();
- if ($viewer->getIsAdmin()) {
+ $can_create = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $this,
+ PeopleCreateUsersCapability::CAPABILITY);
+
+ if ($can_create) {
$item = id(new PHUIListItemView())
->setName(pht('User Account'))
->setIcon('fa-users')
->setHref($this->getBaseURI().'create/');
$items[] = $item;
+ } else if ($viewer->getIsAdmin()) {
+ $item = id(new PHUIListItemView())
+ ->setName(pht('Bot Account'))
+ ->setIcon('fa-android')
+ ->setHref($this->getBaseURI().'new/bot/');
+ $items[] = $item;
}
return $items;
diff --git a/src/applications/people/capability/PeopleCreateUsersCapability.php b/src/applications/people/capability/PeopleCreateUsersCapability.php
--- a/src/applications/people/capability/PeopleCreateUsersCapability.php
+++ b/src/applications/people/capability/PeopleCreateUsersCapability.php
@@ -6,7 +6,7 @@
const CAPABILITY = 'people.create.users';
public function getCapabilityName() {
- return pht('Can Create Users');
+ return pht('Can Create (non-bot) Users');
}
public function describeCapabilityRejection() {
diff --git a/src/applications/people/controller/PhabricatorPeopleListController.php b/src/applications/people/controller/PhabricatorPeopleListController.php
--- a/src/applications/people/controller/PhabricatorPeopleListController.php
+++ b/src/applications/people/controller/PhabricatorPeopleListController.php
@@ -35,12 +35,19 @@
$can_create = $this->hasApplicationCapability(
PeopleCreateUsersCapability::CAPABILITY);
- $crumbs->addAction(
- id(new PHUIListItemView())
- ->setName(pht('Create New User'))
- ->setHref($this->getApplicationURI('create/'))
- ->setDisabled(!$can_create)
- ->setIcon('fa-plus-square'));
+ if ($can_create) {
+ $crumbs->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('Create New User'))
+ ->setHref($this->getApplicationURI('create/'))
+ ->setIcon('fa-plus-square'));
+ } else if ($viewer->getIsAdmin()) {
+ $crumbs->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('Create New Bot'))
+ ->setHref($this->getApplicationURI('new/bot/'))
+ ->setIcon('fa-plus-square'));
+ }
return $crumbs;
}
diff --git a/src/applications/people/controller/PhabricatorPeopleNewController.php b/src/applications/people/controller/PhabricatorPeopleNewController.php
--- a/src/applications/people/controller/PhabricatorPeopleNewController.php
+++ b/src/applications/people/controller/PhabricatorPeopleNewController.php
@@ -4,13 +4,13 @@
extends PhabricatorPeopleController {
public function handleRequest(AphrontRequest $request) {
- $this->requireApplicationCapability(
- PeopleCreateUsersCapability::CAPABILITY);
$type = $request->getURIData('type');
$admin = $request->getUser();
switch ($type) {
case 'standard':
+ $this->requireApplicationCapability(
+ PeopleCreateUsersCapability::CAPABILITY);
$is_bot = false;
break;
case 'bot':

File Metadata

Mime Type
text/plain
Expires
Oct 19 2024, 12:43 AM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722105
Default Alt Text
D11702.diff (3 KB)

Event Timeline