Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/people/view/PhabricatorUserLogView.php b/src/applications/people/view/PhabricatorUserLogView.php
index 309540c611..72a9378a1a 100644
--- a/src/applications/people/view/PhabricatorUserLogView.php
+++ b/src/applications/people/view/PhabricatorUserLogView.php
@@ -1,87 +1,121 @@
<?php
final class PhabricatorUserLogView extends AphrontView {
private $logs;
private $searchBaseURI;
public function setSearchBaseURI($search_base_uri) {
$this->searchBaseURI = $search_base_uri;
return $this;
}
public function setLogs(array $logs) {
assert_instances_of($logs, 'PhabricatorUserLog');
$this->logs = $logs;
return $this;
}
public function render() {
$logs = $this->logs;
$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;
+ $viewer_phid = $viewer->getPHID();
+
$rows = array();
foreach ($logs as $log) {
- $ip = $log->getRemoteAddr();
$session = substr($log->getSession(), 0, 6);
- if ($base_uri) {
- $ip = phutil_tag(
- 'a',
- array(
- 'href' => $base_uri.'?ip='.$ip.'#R',
- ),
- $ip);
+ $actor_phid = $log->getActorPHID();
+ $user_phid = $log->getUserPHID();
+
+ if ($viewer->getIsAdmin()) {
+ $can_see_ip = true;
+ } else if ($viewer_phid == $actor_phid) {
+ // You can see the address if you took the action.
+ $can_see_ip = true;
+ } else if (!$actor_phid && ($viewer_phid == $user_phid)) {
+ // You can see the address if it wasn't authenticated and applied
+ // to you (partial login).
+ $can_see_ip = true;
+ } else {
+ // You can't see the address when an administrator disables your
+ // account, since it's their address.
+ $can_see_ip = false;
+ }
+
+ if ($can_see_ip) {
+ $ip = $log->getRemoteAddr();
+ if ($base_uri) {
+ $ip = phutil_tag(
+ 'a',
+ array(
+ 'href' => $base_uri.'?ip='.$ip.'#R',
+ ),
+ $ip);
+ }
+ } else {
+ $ip = null;
}
$action = $log->getAction();
$action_name = idx($action_map, $action, $action);
+ if ($actor_phid) {
+ $actor_name = $handles[$actor_phid]->renderLink();
+ } else {
+ $actor_name = null;
+ }
+
+ if ($user_phid) {
+ $user_name = $handles[$user_phid]->renderLink();
+ } else {
+ $user_name = null;
+ }
+
$rows[] = array(
phabricator_date($log->getDateCreated(), $viewer),
phabricator_time($log->getDateCreated(), $viewer),
$action_name,
- $log->getActorPHID()
- ? $handles[$log->getActorPHID()]->getName()
- : null,
- $username = $handles[$log->getUserPHID()]->renderLink(),
+ $actor_name,
+ $user_name,
$ip,
$session,
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
pht('Date'),
pht('Time'),
pht('Action'),
pht('Actor'),
pht('User'),
pht('IP'),
pht('Session'),
));
$table->setColumnClasses(
array(
'',
'right',
'wide',
'',
'',
'',
'n',
));
return $table;
}
}
diff --git a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
index eeeca27663..2759f3a26c 100644
--- a/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorActivitySettingsPanel.php
@@ -1,61 +1,46 @@
<?php
final class PhabricatorActivitySettingsPanel extends PhabricatorSettingsPanel {
public function getPanelKey() {
return 'activity';
}
public function getPanelName() {
return pht('Activity Logs');
}
public function getPanelGroupKey() {
return PhabricatorSettingsLogsPanelGroup::PANELGROUPKEY;
}
public function processRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$user = $this->getUser();
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$logs = id(new PhabricatorPeopleLogQuery())
->setViewer($viewer)
->withRelatedPHIDs(array($user->getPHID()))
->executeWithCursorPager($pager);
- $phids = array();
- foreach ($logs as $log) {
- $phids[] = $log->getUserPHID();
- $phids[] = $log->getActorPHID();
- }
-
- if ($phids) {
- $handles = id(new PhabricatorHandleQuery())
- ->setViewer($viewer)
- ->withPHIDs($phids)
- ->execute();
- } else {
- $handles = array();
- }
-
$table = id(new PhabricatorUserLogView())
->setUser($viewer)
->setLogs($logs);
$panel = $this->newBox(pht('Account Activity Logs'), $table);
$pager_box = id(new PHUIBoxView())
->addMargin(PHUI::MARGIN_LARGE)
->appendChild($pager);
return array($panel, $pager_box);
}
public function isManagementPanel() {
return true;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Apr 28, 6:56 PM (14 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108112
Default Alt Text
(5 KB)

Event Timeline