Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101359540
UserEnableConduitAPIMethod.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
Sat, Feb 8, 18:30
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Feb 10, 18:30 (2 d)
Engine
blob
Format
Raw Data
Handle
24144079
Attached To
rPH Phabricator
UserEnableConduitAPIMethod.php
View Options
<?php
final
class
UserEnableConduitAPIMethod
extends
UserConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'user.enable'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Re-enable specified users (admin only).'
);
}
public
function
getMethodStatus
()
{
return
self
::
METHOD_STATUS_DEPRECATED
;
}
public
function
getMethodStatusDescription
()
{
return
pht
(
'Obsoleted by method "user.edit".'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'phids'
=>
'required list<phid>'
,
);
}
protected
function
defineReturnType
()
{
return
'void'
;
}
protected
function
defineErrorTypes
()
{
return
array
(
'ERR-PERMISSIONS'
=>
pht
(
'Only admins can call this method.'
),
'ERR-BAD-PHID'
=>
pht
(
'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
(
$phids
as
$phid
)
{
$params
=
array
(
'transactions'
=>
array
(
array
(
'type'
=>
'disabled'
,
'value'
=>
false
,
),
),
'objectIdentifier'
=>
$phid
,
);
id
(
new
ConduitCall
(
'user.edit'
,
$params
))
->
setUser
(
$actor
)
->
execute
();
}
return
null
;
}
}
Event Timeline
Log In to Comment