Path: blob/master/src/applications/auth/management/PhabricatorAuthManagementUnlimitWorkflow.php
12256 views
<?php12final class PhabricatorAuthManagementUnlimitWorkflow3extends PhabricatorAuthManagementWorkflow {45protected function didConstruct() {6$this7->setName('unlimit')8->setExamples('**unlimit** --user __username__ --all')9->setSynopsis(10pht(11'Reset action counters so a user can continue taking '.12'rate-limited actions.'))13->setArguments(14array(15array(16'name' => 'user',17'param' => 'username',18'help' => pht('Reset action counters for this user.'),19),20array(21'name' => 'all',22'help' => pht('Reset all counters.'),23),24));25}2627public function execute(PhutilArgumentParser $args) {28$username = $args->getArg('user');29if (!strlen($username)) {30throw new PhutilArgumentUsageException(31pht(32'Use %s to choose a user to reset actions for.', '--user'));33}3435$user = id(new PhabricatorPeopleQuery())36->setViewer($this->getViewer())37->withUsernames(array($username))38->executeOne();39if (!$user) {40throw new PhutilArgumentUsageException(41pht(42'No user exists with username "%s".',43$username));44}4546$all = $args->getArg('all');47if (!$all) {48// TODO: Eventually, let users reset specific actions. For now, we49// require `--all` so that usage won't change when you can reset in a50// more tailored way.51throw new PhutilArgumentUsageException(52pht(53'Specify %s to reset all action counters.', '--all'));54}5556$count = PhabricatorSystemActionEngine::resetActions(57array(58$user->getPHID(),59));6061echo pht('Reset %s action(s).', new PhutilNumber($count))."\n";6263return 0;64}6566}676869