1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

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
This commit is contained in:
epriestley 2018-01-25 17:48:42 -08:00
parent a79bb55f3f
commit 0ec83132a8
5 changed files with 47 additions and 7 deletions

View file

@ -623,7 +623,7 @@ abstract class PhabricatorApplication
}
protected function getQueryRoutePattern($base = null) {
return $base.'(?:query/(?P<queryKey>[^/]+)/(?:(?P<queryAction>[^/]+)/))?';
return $base.'(?:query/(?P<queryKey>[^/]+)/(?:(?P<queryAction>[^/]+)/)?)?';
}
protected function getProfileMenuRouting($controller) {

View file

@ -41,7 +41,7 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
public function getRoutes() {
return array(
'/people/' => array(
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorPeopleListController',
$this->getQueryRoutePattern() => 'PhabricatorPeopleListController',
'logs/(?:query/(?P<queryKey>[^/]+)/)?'
=> 'PhabricatorPeopleLogsController',
'invite/' => array(

View file

@ -16,7 +16,7 @@ final class PhabricatorPeopleListController
PeopleBrowseUserDirectoryCapability::CAPABILITY);
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($request->getURIData('key'))
->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine(new PhabricatorPeopleSearchEngine())
->setNavigation($this->buildSideNavView());

View file

@ -320,4 +320,41 @@ final class PhabricatorPeopleSearchEngine
return $result;
}
protected function newExportFields() {
return array(
id(new PhabricatorIDExportField())
->setKey('id')
->setLabel(pht('ID')),
id(new PhabricatorPHIDExportField())
->setKey('phid')
->setLabel(pht('PHID')),
id(new PhabricatorStringExportField())
->setKey('username')
->setLabel(pht('Username')),
id(new PhabricatorStringExportField())
->setKey('realName')
->setLabel(pht('Real Name')),
id(new PhabricatorEpochExportField())
->setKey('created')
->setLabel(pht('Date Created')),
);
}
public function newExport(array $users) {
$viewer = $this->requireViewer();
$export = array();
foreach ($users as $user) {
$export[] = array(
'id' => $user->getID(),
'phid' => $user->getPHID(),
'username' => $user->getUsername(),
'realName' => $user->getRealName(),
'created' => $user->getDateCreated(),
);
}
return $export;
}
}

View file

@ -396,10 +396,13 @@ final class PhabricatorApplicationSearchController
->setViewer($viewer)
->withQueryKeys(array($query_key))
->executeOne();
} else {
$saved_query = null;
}
if (!$saved_query) {
return new Aphront404Response();
}
}
$cancel_uri = $engine->getQueryResultsPageURI($query_key);