Page MenuHomePhabricator

D21587.diff
No OneTemporary

D21587.diff

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
@@ -4164,6 +4164,7 @@
'PhabricatorPeopleMailEngine' => 'applications/people/mail/PhabricatorPeopleMailEngine.php',
'PhabricatorPeopleMailEngineException' => 'applications/people/mail/PhabricatorPeopleMailEngineException.php',
'PhabricatorPeopleManageProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php',
+ 'PhabricatorPeopleManagementApproveWorkflow' => 'applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php',
'PhabricatorPeopleManagementEmpowerWorkflow' => 'applications/people/management/PhabricatorPeopleManagementEmpowerWorkflow.php',
'PhabricatorPeopleManagementEnableWorkflow' => 'applications/people/management/PhabricatorPeopleManagementEnableWorkflow.php',
'PhabricatorPeopleManagementWorkflow' => 'applications/people/management/PhabricatorPeopleManagementWorkflow.php',
@@ -10807,6 +10808,7 @@
'PhabricatorPeopleMailEngine' => 'Phobject',
'PhabricatorPeopleMailEngineException' => 'Exception',
'PhabricatorPeopleManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
+ 'PhabricatorPeopleManagementApproveWorkflow' => 'PhabricatorPeopleManagementWorkflow',
'PhabricatorPeopleManagementEmpowerWorkflow' => 'PhabricatorPeopleManagementWorkflow',
'PhabricatorPeopleManagementEnableWorkflow' => 'PhabricatorPeopleManagementWorkflow',
'PhabricatorPeopleManagementWorkflow' => 'PhabricatorManagementWorkflow',
diff --git a/src/applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php b/src/applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php
@@ -0,0 +1,44 @@
+<?php
+
+
+final class PhabricatorPeopleManagementApproveWorkflow
+ extends PhabricatorPeopleManagementWorkflow {
+
+ protected function didConstruct() {
+ $arguments = array_merge(
+ $this->getUserSelectionArguments(),
+ array());
+
+ $this
+ ->setName('approve')
+ ->setExamples('**approve** --user __username__')
+ ->setSynopsis(pht('Approves a user.'))
+ ->setArguments($arguments);
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $user = $this->selectUser($args);
+ $display_name = $user->getUsername();
+
+ if ($user->getIsApproved()) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'User account "%s" is already approved. You can only '.
+ 'approve accounts that are not yet approved.',
+ $display_name));
+ }
+
+ $xactions = array();
+ $xactions[] = $user->getApplicationTransactionTemplate()
+ ->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE)
+ ->setNewValue(true);
+
+ $this->applyTransactions($user, $xactions);
+
+ $this->logOkay(
+ pht('DONE'),
+ pht('Approved user account "%s".', $display_name));
+
+ return 0;
+ }
+}
diff --git a/src/applications/people/xaction/PhabricatorUserApproveTransaction.php b/src/applications/people/xaction/PhabricatorUserApproveTransaction.php
--- a/src/applications/people/xaction/PhabricatorUserApproveTransaction.php
+++ b/src/applications/people/xaction/PhabricatorUserApproveTransaction.php
@@ -71,7 +71,10 @@
continue;
}
- if (!$actor->getIsAdmin()) {
+ $is_admin = $actor->getIsAdmin();
+ $is_omnipotent = $actor->isOmnipotent();
+
+ if (!$is_admin && !$is_omnipotent) {
$errors[] = $this->newInvalidError(
pht('You must be an administrator to approve users.'));
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 22, 10:26 AM (6 h, 5 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7030301
Default Alt Text
D21587.diff (3 KB)

Event Timeline