Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / management / PhabricatorAuthManagementUnlimitWorkflow.php
blob843a5f70cf80e9bb02db2b5c3f4f57e0b7354603
1 <?php
3 final class PhabricatorAuthManagementUnlimitWorkflow
4 extends PhabricatorAuthManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('unlimit')
9 ->setExamples('**unlimit** --user __username__ --all')
10 ->setSynopsis(
11 pht(
12 'Reset action counters so a user can continue taking '.
13 'rate-limited actions.'))
14 ->setArguments(
15 array(
16 array(
17 'name' => 'user',
18 'param' => 'username',
19 'help' => pht('Reset action counters for this user.'),
21 array(
22 'name' => 'all',
23 'help' => pht('Reset all counters.'),
25 ));
28 public function execute(PhutilArgumentParser $args) {
29 $username = $args->getArg('user');
30 if (!strlen($username)) {
31 throw new PhutilArgumentUsageException(
32 pht(
33 'Use %s to choose a user to reset actions for.', '--user'));
36 $user = id(new PhabricatorPeopleQuery())
37 ->setViewer($this->getViewer())
38 ->withUsernames(array($username))
39 ->executeOne();
40 if (!$user) {
41 throw new PhutilArgumentUsageException(
42 pht(
43 'No user exists with username "%s".',
44 $username));
47 $all = $args->getArg('all');
48 if (!$all) {
49 // TODO: Eventually, let users reset specific actions. For now, we
50 // require `--all` so that usage won't change when you can reset in a
51 // more tailored way.
52 throw new PhutilArgumentUsageException(
53 pht(
54 'Specify %s to reset all action counters.', '--all'));
57 $count = PhabricatorSystemActionEngine::resetActions(
58 array(
59 $user->getPHID(),
60 ));
62 echo pht('Reset %s action(s).', new PhutilNumber($count))."\n";
64 return 0;