Path: blob/master/src/applications/people/management/PhabricatorPeopleManagementEmpowerWorkflow.php
12256 views
<?php12final class PhabricatorPeopleManagementEmpowerWorkflow3extends PhabricatorPeopleManagementWorkflow {45protected function didConstruct() {6$arguments = array_merge(7$this->getUserSelectionArguments(),8array());910$this11->setName('empower')12->setExamples('**empower** --user __username__')13->setSynopsis(pht('Turn a user account into an administrator account.'))14->setArguments($arguments);15}1617public function execute(PhutilArgumentParser $args) {18$user = $this->selectUser($args);19$display_name = $user->getUsername();2021if ($user->getIsAdmin()) {22throw new PhutilArgumentUsageException(23pht(24'User account "%s" is already an administrator. You can only '.25'empower accounts that are not yet administrators.',26$display_name));27}2829$xactions = array();30$xactions[] = $user->getApplicationTransactionTemplate()31->setTransactionType(PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE)32->setNewValue(true);3334$this->applyTransactions($user, $xactions);3536$this->logOkay(37pht('DONE'),38pht('Empowered user account "%s".', $display_name));3940return 0;41}4243}444546