@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.

Support basic export of user accounts

Summary:
Depends on D18934. Ref T13046. Add support for the new export flow to a second application.

My goal here is mostly just to make sure that this is general enough to work in more than one place, and exporting user accounts seems plausible as a useful feature, although we do see occasional requests for this feature exactly (like <https://discourse.phabricator-community.org/t/users-export-to-csv/968>).

The exported data may not truly be useful for much (no disabled/admin/verified/MFA flags, no external account data, no email addresses for policy reasons) but we can expand it as use cases arise.

Test Plan: Exported user accounts in several formats.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13046

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

+47 -7
+1 -1
src/applications/base/PhabricatorApplication.php
··· 623 623 } 624 624 625 625 protected function getQueryRoutePattern($base = null) { 626 - return $base.'(?:query/(?P<queryKey>[^/]+)/(?:(?P<queryAction>[^/]+)/))?'; 626 + return $base.'(?:query/(?P<queryKey>[^/]+)/(?:(?P<queryAction>[^/]+)/)?)?'; 627 627 } 628 628 629 629 protected function getProfileMenuRouting($controller) {
+2 -2
src/applications/people/application/PhabricatorPeopleApplication.php
··· 41 41 public function getRoutes() { 42 42 return array( 43 43 '/people/' => array( 44 - '(query/(?P<key>[^/]+)/)?' => 'PhabricatorPeopleListController', 44 + $this->getQueryRoutePattern() => 'PhabricatorPeopleListController', 45 45 'logs/(?:query/(?P<queryKey>[^/]+)/)?' 46 46 => 'PhabricatorPeopleLogsController', 47 47 'invite/' => array( ··· 76 76 'PhabricatorPeopleProfilePictureController', 77 77 'manage/(?P<id>[1-9]\d*)/' => 78 78 'PhabricatorPeopleProfileManageController', 79 - ), 79 + ), 80 80 '/p/(?P<username>[\w._-]+)/' => array( 81 81 '' => 'PhabricatorPeopleProfileViewController', 82 82 'item/' => $this->getProfileMenuRouting(
+1 -1
src/applications/people/controller/PhabricatorPeopleListController.php
··· 16 16 PeopleBrowseUserDirectoryCapability::CAPABILITY); 17 17 18 18 $controller = id(new PhabricatorApplicationSearchController()) 19 - ->setQueryKey($request->getURIData('key')) 19 + ->setQueryKey($request->getURIData('queryKey')) 20 20 ->setSearchEngine(new PhabricatorPeopleSearchEngine()) 21 21 ->setNavigation($this->buildSideNavView()); 22 22
+37
src/applications/people/query/PhabricatorPeopleSearchEngine.php
··· 320 320 return $result; 321 321 } 322 322 323 + protected function newExportFields() { 324 + return array( 325 + id(new PhabricatorIDExportField()) 326 + ->setKey('id') 327 + ->setLabel(pht('ID')), 328 + id(new PhabricatorPHIDExportField()) 329 + ->setKey('phid') 330 + ->setLabel(pht('PHID')), 331 + id(new PhabricatorStringExportField()) 332 + ->setKey('username') 333 + ->setLabel(pht('Username')), 334 + id(new PhabricatorStringExportField()) 335 + ->setKey('realName') 336 + ->setLabel(pht('Real Name')), 337 + id(new PhabricatorEpochExportField()) 338 + ->setKey('created') 339 + ->setLabel(pht('Date Created')), 340 + ); 341 + } 342 + 343 + public function newExport(array $users) { 344 + $viewer = $this->requireViewer(); 345 + 346 + $export = array(); 347 + foreach ($users as $user) { 348 + $export[] = array( 349 + 'id' => $user->getID(), 350 + 'phid' => $user->getPHID(), 351 + 'username' => $user->getUsername(), 352 + 'realName' => $user->getRealName(), 353 + 'created' => $user->getDateCreated(), 354 + ); 355 + } 356 + 357 + return $export; 358 + } 359 + 323 360 }
+6 -3
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 396 396 ->setViewer($viewer) 397 397 ->withQueryKeys(array($query_key)) 398 398 ->executeOne(); 399 - if (!$saved_query) { 400 - return new Aphront404Response(); 401 - } 399 + } else { 400 + $saved_query = null; 401 + } 402 + 403 + if (!$saved_query) { 404 + return new Aphront404Response(); 402 405 } 403 406 404 407 $cancel_uri = $engine->getQueryResultsPageURI($query_key);