Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102526453
PhabricatorAuthManagementUnlimitWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 21, 16:03
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 23, 16:03 (2 d)
Engine
blob
Format
Raw Data
Handle
24342919
Attached To
rPH Phabricator
PhabricatorAuthManagementUnlimitWorkflow.php
View Options
<?php
final
class
PhabricatorAuthManagementUnlimitWorkflow
extends
PhabricatorAuthManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'unlimit'
)
->
setExamples
(
'**unlimit** --user __username__ --all'
)
->
setSynopsis
(
pht
(
'Reset action counters so a user can continue taking '
.
'rate-limited actions.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'user'
,
'param'
=>
'username'
,
'help'
=>
pht
(
'Reset action counters for this user.'
),
),
array
(
'name'
=>
'all'
,
'help'
=>
pht
(
'Reset all counters.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$username
=
$args
->
getArg
(
'user'
);
if
(!
strlen
(
$username
))
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Use %s to choose a user to reset actions for.'
,
'--user'
));
}
$user
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withUsernames
(
array
(
$username
))
->
executeOne
();
if
(!
$user
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'No user exists with username "%s".'
,
$username
));
}
$all
=
$args
->
getArg
(
'all'
);
if
(!
$all
)
{
// TODO: Eventually, let users reset specific actions. For now, we
// require `--all` so that usage won't change when you can reset in a
// more tailored way.
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify %s to reset all action counters.'
,
'--all'
));
}
$count
=
PhabricatorSystemActionEngine
::
resetActions
(
array
(
$user
->
getPHID
(),
));
echo
pht
(
'Reset %s action(s).'
,
new
PhutilNumber
(
$count
)).
"
\n
"
;
return
0
;
}
}
Event Timeline
Log In to Comment