diff --git a/src/applications/people/controller/PhabricatorPeopleLogsController.php b/src/applications/people/controller/PhabricatorPeopleLogsController.php index 2ec8d62639..be05cc3481 100644 --- a/src/applications/people/controller/PhabricatorPeopleLogsController.php +++ b/src/applications/people/controller/PhabricatorPeopleLogsController.php @@ -1,7 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $logs, - PhabricatorSavedQuery $query) { - assert_instances_of($logs, 'PhabricatorUserLog'); - - $request = $this->getRequest(); - $viewer = $request->getUser(); - - $phids = array(); - foreach ($logs as $log) { - $phids[$log->getActorPHID()] = true; - $phids[$log->getUserPHID()] = true; - } - $phids = array_keys($phids); - $handles = $this->loadViewerHandles($phids); - - $table = id(new PhabricatorUserLogView()) - ->setUser($viewer) - ->setLogs($logs) - ->setSearchBaseURI($this->getApplicationURI('logs/')) - ->setHandles($handles); - - return id(new PHUIObjectBoxView()) - ->setHeaderText(pht('User Activity Logs')) - ->appendChild($table); - } - - public function buildSideNavView() { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); diff --git a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php index e3f207ff69..37ef51947e 100644 --- a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php +++ b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorPeopleLogSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationPeople'; + } + public function getPageSize(PhabricatorSavedQuery $saved) { return 500; } @@ -36,6 +40,16 @@ final class PhabricatorPeopleLogSearchEngine public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { $query = id(new PhabricatorPeopleLogQuery()); + // NOTE: If the viewer isn't an administrator, always restrict the query to + // related records. This echoes the policy logic of these logs. This is + // mostly a performance optimization, to prevent us from having to pull + // large numbers of logs that the user will not be able to see and filter + // them in-process. + $viewer = $this->requireViewer(); + if (!$viewer->getIsAdmin()) { + $query->withRelatedPHIDs(array($viewer->getPHID())); + } + $actor_phids = $saved->getParameter('actorPHIDs', array()); if ($actor_phids) { $query->withActorPHIDs($actor_phids); @@ -154,4 +168,38 @@ final class PhabricatorPeopleLogSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $logs, + PhabricatorSavedQuery $query) { + + $phids = array(); + foreach ($logs as $log) { + $phids[$log->getActorPHID()] = true; + $phids[$log->getUserPHID()] = true; + } + + return array_keys($phids); + } + + protected function renderResultList( + array $logs, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($logs, 'PhabricatorUserLog'); + + $viewer = $this->requireViewer(); + + $table = id(new PhabricatorUserLogView()) + ->setUser($viewer) + ->setLogs($logs) + ->setHandles($handles); + + if ($viewer->getIsAdmin()) { + $table->setSearchBaseURI($this->getApplicationURI('logs/')); + } + + return id(new PHUIObjectBoxView()) + ->setHeaderText(pht('User Activity Logs')) + ->appendChild($table); + } } diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php b/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php index 3a31d5d713..220af6afce 100644 --- a/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php +++ b/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php @@ -27,10 +27,13 @@ final class PhabricatorSettingsPanelActivity $viewer = $request->getUser(); $user = $this->getUser(); + $pager = id(new AphrontCursorPagerView()) + ->readFromRequest($request); + $logs = id(new PhabricatorPeopleLogQuery()) ->setViewer($viewer) ->withRelatedPHIDs(array($user->getPHID())) - ->execute(); + ->executeWithCursorPager($pager); $phids = array(); foreach ($logs as $log) { @@ -56,7 +59,11 @@ final class PhabricatorSettingsPanelActivity ->setHeaderText(pht('Account Activity Logs')) ->appendChild($table); - return $panel; + $pager_box = id(new PHUIBoxView()) + ->addMargin(PHUI::MARGIN_LARGE) + ->appendChild($pager); + + return array($panel, $pager_box); } }