Page MenuHomePhabricator

D9136.id21704.diff
No OneTemporary

D9136.id21704.diff

diff --git a/src/applications/people/controller/PhabricatorPeopleLogsController.php b/src/applications/people/controller/PhabricatorPeopleLogsController.php
--- a/src/applications/people/controller/PhabricatorPeopleLogsController.php
+++ b/src/applications/people/controller/PhabricatorPeopleLogsController.php
@@ -1,7 +1,7 @@
<?php
-final class PhabricatorPeopleLogsController extends PhabricatorPeopleController
- implements PhabricatorApplicationSearchResultsControllerInterface {
+final class PhabricatorPeopleLogsController
+ extends PhabricatorPeopleController {
private $queryKey;
@@ -19,34 +19,6 @@
return $this->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
--- 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 @@
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 @@
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
--- a/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php
+++ b/src/applications/settings/panel/PhabricatorSettingsPanelActivity.php
@@ -27,10 +27,13 @@
$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 @@
->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);
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 1, 4:43 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720760
Default Alt Text
D9136.id21704.diff (4 KB)

Event Timeline