@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a modern `user.search` Conduit API method

Summary: Ref T10512. This is fairly bare-bones but appears to work.

Test Plan: Queried all users, queried some stuff by constraints.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10512

Differential Revision: https://secure.phabricator.com/D15959

+132 -13
+3
src/__phutil_library_map__.php
··· 4135 4135 'UserEnableConduitAPIMethod' => 'applications/people/conduit/UserEnableConduitAPIMethod.php', 4136 4136 'UserFindConduitAPIMethod' => 'applications/people/conduit/UserFindConduitAPIMethod.php', 4137 4137 'UserQueryConduitAPIMethod' => 'applications/people/conduit/UserQueryConduitAPIMethod.php', 4138 + 'UserSearchConduitAPIMethod' => 'applications/people/conduit/UserSearchConduitAPIMethod.php', 4138 4139 'UserWhoAmIConduitAPIMethod' => 'applications/people/conduit/UserWhoAmIConduitAPIMethod.php', 4139 4140 ), 4140 4141 'function' => array( ··· 8313 8314 'PhabricatorFlaggableInterface', 8314 8315 'PhabricatorApplicationTransactionInterface', 8315 8316 'PhabricatorFulltextInterface', 8317 + 'PhabricatorConduitResultInterface', 8316 8318 ), 8317 8319 'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField', 8318 8320 'PhabricatorUserCardView' => 'AphrontTagView', ··· 9028 9030 'UserEnableConduitAPIMethod' => 'UserConduitAPIMethod', 9029 9031 'UserFindConduitAPIMethod' => 'UserConduitAPIMethod', 9030 9032 'UserQueryConduitAPIMethod' => 'UserConduitAPIMethod', 9033 + 'UserSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 9031 9034 'UserWhoAmIConduitAPIMethod' => 'UserConduitAPIMethod', 9032 9035 ), 9033 9036 ));
+18
src/applications/people/conduit/UserSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class UserSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'user.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new PhabricatorPeopleSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Read information about users.'); 16 + } 17 + 18 + }
+40 -12
src/applications/people/query/PhabricatorPeopleSearchEngine.php
··· 22 22 id(new PhabricatorSearchStringListField()) 23 23 ->setLabel(pht('Usernames')) 24 24 ->setKey('usernames') 25 - ->setAliases(array('username')), 25 + ->setAliases(array('username')) 26 + ->setDescription(pht('Find users by exact username.')), 26 27 id(new PhabricatorSearchTextField()) 27 28 ->setLabel(pht('Name Contains')) 28 - ->setKey('nameLike'), 29 + ->setKey('nameLike') 30 + ->setDescription( 31 + pht('Find users whose usernames contain a substring.')), 29 32 id(new PhabricatorSearchThreeStateField()) 30 33 ->setLabel(pht('Administrators')) 31 34 ->setKey('isAdmin') 32 35 ->setOptions( 33 36 pht('(Show All)'), 34 37 pht('Show Only Administrators'), 35 - pht('Hide Administrators')), 38 + pht('Hide Administrators')) 39 + ->setDescription( 40 + pht( 41 + 'Pass true to find only administrators, or false to omit '. 42 + 'administrators.')), 36 43 id(new PhabricatorSearchThreeStateField()) 37 44 ->setLabel(pht('Disabled')) 38 45 ->setKey('isDisabled') 39 46 ->setOptions( 40 47 pht('(Show All)'), 41 48 pht('Show Only Disabled Users'), 42 - pht('Hide Disabled Users')), 49 + pht('Hide Disabled Users')) 50 + ->setDescription( 51 + pht( 52 + 'Pass true to find only disabled users, or false to omit '. 53 + 'disabled users.')), 43 54 id(new PhabricatorSearchThreeStateField()) 44 55 ->setLabel(pht('Bots')) 45 - ->setKey('isSystemAgent') 56 + ->setKey('isBot') 57 + ->setAliases(array('isSystemAgent')) 46 58 ->setOptions( 47 59 pht('(Show All)'), 48 60 pht('Show Only Bots'), 49 - pht('Hide Bots')), 61 + pht('Hide Bots')) 62 + ->setDescription( 63 + pht( 64 + 'Pass true to find only bots, or false to omit bots.')), 50 65 id(new PhabricatorSearchThreeStateField()) 51 66 ->setLabel(pht('Mailing Lists')) 52 67 ->setKey('isMailingList') 53 68 ->setOptions( 54 69 pht('(Show All)'), 55 70 pht('Show Only Mailing Lists'), 56 - pht('Hide Mailing Lists')), 71 + pht('Hide Mailing Lists')) 72 + ->setDescription( 73 + pht( 74 + 'Pass true to find only mailing lists, or false to omit '. 75 + 'mailing lists.')), 57 76 id(new PhabricatorSearchThreeStateField()) 58 77 ->setLabel(pht('Needs Approval')) 59 78 ->setKey('needsApproval') 60 79 ->setOptions( 61 80 pht('(Show All)'), 62 81 pht('Show Only Unapproved Users'), 63 - pht('Hide Unappproved Users')), 82 + pht('Hide Unappproved Users')) 83 + ->setDescription( 84 + pht( 85 + 'Pass true to find only users awaiting administrative approval, '. 86 + 'or false to omit these users.')), 64 87 id(new PhabricatorSearchDateField()) 65 88 ->setKey('createdStart') 66 - ->setLabel(pht('Joined After')), 89 + ->setLabel(pht('Joined After')) 90 + ->setDescription( 91 + pht('Find user accounts created after a given time.')), 67 92 id(new PhabricatorSearchDateField()) 68 93 ->setKey('createdEnd') 69 - ->setLabel(pht('Joined Before')), 94 + ->setLabel(pht('Joined Before')) 95 + ->setDescription( 96 + pht('Find user accounts created before a given time.')), 97 + 70 98 ); 71 99 } 72 100 ··· 115 143 $query->withIsMailingList($map['isMailingList']); 116 144 } 117 145 118 - if ($map['isSystemAgent'] !== null) { 119 - $query->withIsSystemAgent($map['isSystemAgent']); 146 + if ($map['isBot'] !== null) { 147 + $query->withIsSystemAgent($map['isBot']); 120 148 } 121 149 122 150 if ($map['needsApproval'] !== null) {
+66 -1
src/applications/people/storage/PhabricatorUser.php
··· 16 16 PhabricatorSSHPublicKeyInterface, 17 17 PhabricatorFlaggableInterface, 18 18 PhabricatorApplicationTransactionInterface, 19 - PhabricatorFulltextInterface { 19 + PhabricatorFulltextInterface, 20 + PhabricatorConduitResultInterface { 20 21 21 22 const SESSION_TABLE = 'phabricator_session'; 22 23 const NAMETOKEN_TABLE = 'user_nametoken'; ··· 1388 1389 public function newFulltextEngine() { 1389 1390 return new PhabricatorUserFulltextEngine(); 1390 1391 } 1392 + 1393 + 1394 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 1395 + 1396 + 1397 + public function getFieldSpecificationsForConduit() { 1398 + return array( 1399 + id(new PhabricatorConduitSearchFieldSpecification()) 1400 + ->setKey('username') 1401 + ->setType('string') 1402 + ->setDescription(pht("The user's username.")), 1403 + id(new PhabricatorConduitSearchFieldSpecification()) 1404 + ->setKey('realName') 1405 + ->setType('string') 1406 + ->setDescription(pht("The user's real name.")), 1407 + id(new PhabricatorConduitSearchFieldSpecification()) 1408 + ->setKey('roles') 1409 + ->setType('list<string>') 1410 + ->setDescription(pht('List of acccount roles.')), 1411 + ); 1412 + } 1413 + 1414 + public function getFieldValuesForConduit() { 1415 + $roles = array(); 1416 + 1417 + if ($this->getIsDisabled()) { 1418 + $roles[] = 'disabled'; 1419 + } 1420 + 1421 + if ($this->getIsSystemAgent()) { 1422 + $roles[] = 'bot'; 1423 + } 1424 + 1425 + if ($this->getIsMailingList()) { 1426 + $roles[] = 'list'; 1427 + } 1428 + 1429 + if ($this->getIsAdmin()) { 1430 + $roles[] = 'admin'; 1431 + } 1432 + 1433 + if ($this->getIsEmailVerified()) { 1434 + $roles[] = 'verified'; 1435 + } 1436 + 1437 + if ($this->getIsApproved()) { 1438 + $roles[] = 'approved'; 1439 + } 1440 + 1441 + if ($this->isUserActivated()) { 1442 + $roles[] = 'activated'; 1443 + } 1444 + 1445 + return array( 1446 + 'username' => $this->getUsername(), 1447 + 'realName' => $this->getRealName(), 1448 + 'roles' => $roles, 1449 + ); 1450 + } 1451 + 1452 + public function getConduitSearchAttachments() { 1453 + return array(); 1454 + } 1455 + 1391 1456 1392 1457 }
+1
src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
··· 501 501 } 502 502 503 503 $table = id(new AphrontTableView($rows)) 504 + ->setNoDataString(pht('This call does not support any attachments.')) 504 505 ->setHeaders( 505 506 array( 506 507 pht('Key'),
+4
src/applications/search/field/PhabricatorSearchThreeStateField.php
··· 45 45 return null; 46 46 } 47 47 48 + protected function newConduitParameterType() { 49 + return new ConduitBoolParameterType(); 50 + } 51 + 48 52 }