Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14028141
D9136.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D9136.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 11:59 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720760
Default Alt Text
D9136.diff (4 KB)
Attached To
Mode
D9136: Move activity log rendering to a dashboard panel
Attached
Detach File
Event Timeline
Log In to Comment