Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15389093
D18966.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D18966.diff
View Options
diff --git a/src/applications/people/query/PhabricatorPeopleLogQuery.php b/src/applications/people/query/PhabricatorPeopleLogQuery.php
--- a/src/applications/people/query/PhabricatorPeopleLogQuery.php
+++ b/src/applications/people/query/PhabricatorPeopleLogQuery.php
@@ -40,70 +40,61 @@
return $this;
}
+ public function newResultObject() {
+ return new PhabricatorUserLog();
+ }
+
protected function loadPage() {
- $table = new PhabricatorUserLog();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage($this->newResultObject());
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->actorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'actorPHID IN (%Ls)',
$this->actorPHIDs);
}
if ($this->userPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'userPHID IN (%Ls)',
$this->userPHIDs);
}
if ($this->relatedPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
- 'actorPHID IN (%Ls) OR userPHID IN (%Ls)',
+ $conn,
+ '(actorPHID IN (%Ls) OR userPHID IN (%Ls))',
$this->relatedPHIDs,
$this->relatedPHIDs);
}
if ($this->sessionKeys !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'session IN (%Ls)',
$this->sessionKeys);
}
if ($this->actions !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'action IN (%Ls)',
$this->actions);
}
if ($this->remoteAddressPrefix !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'remoteAddr LIKE %>',
$this->remoteAddressPrefix);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
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
@@ -15,34 +15,8 @@
return 500;
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'userPHIDs',
- $this->readUsersFromRequest($request, 'users'));
-
- $saved->setParameter(
- 'actorPHIDs',
- $this->readUsersFromRequest($request, 'actors'));
-
- $saved->setParameter(
- 'actions',
- $this->readListFromRequest($request, 'actions'));
-
- $saved->setParameter(
- 'ip',
- $request->getStr('ip'));
-
- $saved->setParameter(
- 'sessions',
- $this->readListFromRequest($request, 'sessions'));
-
- return $saved;
- }
-
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PhabricatorPeopleLogQuery());
+ public function newQuery() {
+ $query = 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
@@ -54,82 +28,61 @@
$query->withRelatedPHIDs(array($viewer->getPHID()));
}
- $actor_phids = $saved->getParameter('actorPHIDs', array());
- if ($actor_phids) {
- $query->withActorPHIDs($actor_phids);
+ return $query;
+ }
+
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+
+ if ($map['userPHIDs']) {
+ $query->withUserPHIDs($map['userPHIDs']);
}
- $user_phids = $saved->getParameter('userPHIDs', array());
- if ($user_phids) {
- $query->withUserPHIDs($user_phids);
+ if ($map['actorPHIDs']) {
+ $query->withActorPHIDs($map['actorPHIDs']);
}
- $actions = $saved->getParameter('actions', array());
- if ($actions) {
- $query->withActions($actions);
+ if ($map['actions']) {
+ $query->withActions($map['actions']);
}
- $remote_prefix = $saved->getParameter('ip');
- if (strlen($remote_prefix)) {
- $query->withRemoteAddressprefix($remote_prefix);
+ if (strlen($map['ip'])) {
+ $query->withRemoteAddressPrefix($map['ip']);
}
- $sessions = $saved->getParameter('sessions', array());
- if ($sessions) {
- $query->withSessionKeys($sessions);
+ if ($map['sessions']) {
+ $query->withSessionKeys($map['sessions']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {
-
- $actor_phids = $saved->getParameter('actorPHIDs', array());
- $user_phids = $saved->getParameter('userPHIDs', array());
-
- $actions = $saved->getParameter('actions', array());
- $remote_prefix = $saved->getParameter('ip');
- $sessions = $saved->getParameter('sessions', array());
-
- $actions = array_fuse($actions);
- $action_control = id(new AphrontFormCheckboxControl())
- ->setLabel(pht('Actions'));
- $action_types = PhabricatorUserLog::getActionTypeMap();
- foreach ($action_types as $type => $label) {
- $action_control->addCheckbox(
- 'actions[]',
- $type,
- $label,
- isset($actions[$label]));
- }
-
- $form
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('actors')
- ->setLabel(pht('Actors'))
- ->setValue($actor_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('users')
- ->setLabel(pht('Users'))
- ->setValue($user_phids))
- ->appendChild($action_control)
- ->appendChild(
- id(new AphrontFormTextControl())
- ->setLabel(pht('Filter IP'))
- ->setName('ip')
- ->setValue($remote_prefix))
- ->appendChild(
- id(new AphrontFormTextControl())
- ->setLabel(pht('Sessions'))
- ->setName('sessions')
- ->setValue(implode(', ', $sessions)));
-
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorUsersSearchField())
+ ->setKey('userPHIDs')
+ ->setAliases(array('users', 'user', 'userPHID'))
+ ->setLabel(pht('Users'))
+ ->setDescription(pht('Search for activity affecting specific users.')),
+ id(new PhabricatorUsersSearchField())
+ ->setKey('actorPHIDs')
+ ->setAliases(array('actors', 'actor', 'actorPHID'))
+ ->setLabel(pht('Actors'))
+ ->setDescription(pht('Search for activity by specific users.')),
+ id(new PhabricatorSearchCheckboxesField())
+ ->setKey('actions')
+ ->setLabel(pht('Actions'))
+ ->setDescription(pht('Search for particular types of activity.'))
+ ->setOptions(PhabricatorUserLog::getActionTypeMap()),
+ id(new PhabricatorSearchTextField())
+ ->setKey('ip')
+ ->setLabel(pht('Filter IP'))
+ ->setDescription(pht('Search for actions by remote address.')),
+ id(new PhabricatorSearchStringListField())
+ ->setKey('sessions')
+ ->setLabel(pht('Sessions'))
+ ->setDescription(pht('Search for activity in particular sessions.')),
+ );
}
protected function getURI($path) {
@@ -156,19 +109,6 @@
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,
@@ -179,16 +119,13 @@
$table = id(new PhabricatorUserLogView())
->setUser($viewer)
- ->setLogs($logs)
- ->setHandles($handles);
+ ->setLogs($logs);
if ($viewer->getIsAdmin()) {
$table->setSearchBaseURI($this->getApplicationURI('logs/'));
}
- $result = new PhabricatorApplicationSearchResultView();
- $result->setTable($table);
-
- return $result;
+ return id(new PhabricatorApplicationSearchResultView())
+ ->setTable($table);
}
}
diff --git a/src/applications/people/view/PhabricatorUserLogView.php b/src/applications/people/view/PhabricatorUserLogView.php
--- a/src/applications/people/view/PhabricatorUserLogView.php
+++ b/src/applications/people/view/PhabricatorUserLogView.php
@@ -3,7 +3,6 @@
final class PhabricatorUserLogView extends AphrontView {
private $logs;
- private $handles;
private $searchBaseURI;
public function setSearchBaseURI($search_base_uri) {
@@ -17,17 +16,17 @@
return $this;
}
- public function setHandles(array $handles) {
- assert_instances_of($handles, 'PhabricatorObjectHandle');
- $this->handles = $handles;
- return $this;
- }
-
public function render() {
$logs = $this->logs;
- $handles = $this->handles;
$viewer = $this->getUser();
+ $phids = array();
+ foreach ($logs as $log) {
+ $phids[] = $log->getActorPHID();
+ $phids[] = $log->getUserPHID();
+ }
+ $handles = $viewer->loadHandles($phids);
+
$action_map = PhabricatorUserLog::getActionTypeMap();
$base_uri = $this->searchBaseURI;
diff --git a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
@@ -43,8 +43,7 @@
$table = id(new PhabricatorUserLogView())
->setUser($viewer)
- ->setLogs($logs)
- ->setHandles($handles);
+ ->setLogs($logs);
$panel = $this->newBox(pht('Account Activity Logs'), $table);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 4:53 AM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705857
Default Alt Text
D18966.diff (10 KB)
Attached To
Mode
D18966: Upgrade user account activity logs to modern construction
Attached
Detach File
Event Timeline
Log In to Comment