Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F950499
UserQueryConduitAPIMethod.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
UserQueryConduitAPIMethod.php
View Options
<?php
final
class
UserQueryConduitAPIMethod
extends
UserConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'user.query'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Query users.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'usernames'
=>
'optional list<string>'
,
'emails'
=>
'optional list<string>'
,
'realnames'
=>
'optional list<string>'
,
'phids'
=>
'optional list<phid>'
,
'ids'
=>
'optional list<uint>'
,
'offset'
=>
'optional int'
,
'limit'
=>
'optional int (default = 100)'
,
);
}
protected
function
defineReturnType
()
{
return
'list<dict>'
;
}
protected
function
defineErrorTypes
()
{
return
array
(
'ERR-INVALID-PARAMETER'
=>
pht
(
'Missing or malformed parameter.'
),
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$usernames
=
$request
->
getValue
(
'usernames'
,
array
());
$emails
=
$request
->
getValue
(
'emails'
,
array
());
$realnames
=
$request
->
getValue
(
'realnames'
,
array
());
$phids
=
$request
->
getValue
(
'phids'
,
array
());
$ids
=
$request
->
getValue
(
'ids'
,
array
());
$offset
=
$request
->
getValue
(
'offset'
,
0
);
$limit
=
$request
->
getValue
(
'limit'
,
100
);
$query
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$request
->
getUser
())
->
needProfileImage
(
true
)
->
needAvailability
(
true
);
if
(
$usernames
)
{
$query
->
withUsernames
(
$usernames
);
}
if
(
$emails
)
{
$query
->
withEmails
(
$emails
);
}
if
(
$realnames
)
{
$query
->
withRealnames
(
$realnames
);
}
if
(
$phids
)
{
$query
->
withPHIDs
(
$phids
);
}
if
(
$ids
)
{
$query
->
withIDs
(
$ids
);
}
if
(
$limit
)
{
$query
->
setLimit
(
$limit
);
}
if
(
$offset
)
{
$query
->
setOffset
(
$offset
);
}
$users
=
$query
->
execute
();
$results
=
array
();
foreach
(
$users
as
$user
)
{
$results
[]
=
$this
->
buildUserInformationDictionary
(
$user
,
$with_email
=
false
,
$with_availability
=
true
);
}
return
$results
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 2:07 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224202
Default Alt Text
UserQueryConduitAPIMethod.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment