Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97237325
UserDisableConduitAPIMethod.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, Jan 3, 16:57
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jan 5, 16:57 (2 d)
Engine
blob
Format
Raw Data
Handle
23361773
Attached To
rPH Phabricator
UserDisableConduitAPIMethod.php
View Options
<?php
final
class
UserDisableConduitAPIMethod
extends
UserConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'user.disable'
;
}
public
function
getMethodDescription
()
{
return
'Permanently disable specified users (admin only).'
;
}
public
function
defineParamTypes
()
{
return
array
(
'phids'
=>
'required list<phid>'
,
);
}
public
function
defineReturnType
()
{
return
'void'
;
}
public
function
defineErrorTypes
()
{
return
array
(
'ERR-PERMISSIONS'
=>
'Only admins can call this method.'
,
'ERR-BAD-PHID'
=>
'Non existent user PHID.'
,
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$actor
=
$request
->
getUser
();
if
(!
$actor
->
getIsAdmin
())
{
throw
new
ConduitException
(
'ERR-PERMISSIONS'
);
}
$phids
=
$request
->
getValue
(
'phids'
);
$users
=
id
(
new
PhabricatorUser
())->
loadAllWhere
(
'phid IN (%Ls)'
,
$phids
);
if
(
count
(
$phids
)
!=
count
(
$users
))
{
throw
new
ConduitException
(
'ERR-BAD-PHID'
);
}
foreach
(
$users
as
$user
)
{
id
(
new
PhabricatorUserEditor
())
->
setActor
(
$actor
)
->
disableUser
(
$user
,
true
);
}
}
}
Event Timeline
Log In to Comment