Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / people / conduit / UserQueryConduitAPIMethod.php
blobdf0ec65841e377be7896c67f0a73fcb9c79438c4
1 <?php
3 final class UserQueryConduitAPIMethod extends UserConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'user.query';
9 public function getMethodDescription() {
10 return pht('Query users.');
13 public function getMethodStatus() {
14 return self::METHOD_STATUS_FROZEN;
17 public function getMethodStatusDescription() {
18 return pht(
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "user.search" instead.');
23 protected function defineParamTypes() {
24 return array(
25 'usernames' => 'optional list<string>',
26 'emails' => 'optional list<string>',
27 'realnames' => 'optional list<string>',
28 'phids' => 'optional list<phid>',
29 'ids' => 'optional list<uint>',
30 'offset' => 'optional int',
31 'limit' => 'optional int (default = 100)',
35 protected function defineReturnType() {
36 return 'list<dict>';
39 protected function defineErrorTypes() {
40 return array(
41 'ERR-INVALID-PARAMETER' => pht('Missing or malformed parameter.'),
45 protected function execute(ConduitAPIRequest $request) {
46 $usernames = $request->getValue('usernames', array());
47 $emails = $request->getValue('emails', array());
48 $realnames = $request->getValue('realnames', array());
49 $phids = $request->getValue('phids', array());
50 $ids = $request->getValue('ids', array());
51 $offset = $request->getValue('offset', 0);
52 $limit = $request->getValue('limit', 100);
54 $query = id(new PhabricatorPeopleQuery())
55 ->setViewer($request->getUser())
56 ->needProfileImage(true)
57 ->needAvailability(true);
59 if ($usernames) {
60 $query->withUsernames($usernames);
62 if ($emails) {
63 $query->withEmails($emails);
65 if ($realnames) {
66 $query->withRealnames($realnames);
68 if ($phids) {
69 $query->withPHIDs($phids);
71 if ($ids) {
72 $query->withIDs($ids);
74 if ($limit) {
75 $query->setLimit($limit);
77 if ($offset) {
78 $query->setOffset($offset);
80 $users = $query->execute();
82 $results = array();
83 foreach ($users as $user) {
84 $results[] = $this->buildUserInformationDictionary(
85 $user,
86 $with_email = false,
87 $with_availability = true);
89 return $results;