Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/view/PhabricatorUserLogView.php
| Show All 35 Lines | public function render() { | ||||
| $rows = array(); | $rows = array(); | ||||
| foreach ($logs as $log) { | foreach ($logs as $log) { | ||||
| $session = substr($log->getSession(), 0, 6); | $session = substr($log->getSession(), 0, 6); | ||||
| $actor_phid = $log->getActorPHID(); | $actor_phid = $log->getActorPHID(); | ||||
| $user_phid = $log->getUserPHID(); | $user_phid = $log->getUserPHID(); | ||||
| if ($viewer->getIsAdmin()) { | $remote_address = $log->getRemoteAddressForViewer($viewer); | ||||
| $can_see_ip = true; | if ($remote_address !== null) { | ||||
| } 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) { | if ($base_uri) { | ||||
| $ip = phutil_tag( | $remote_address = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $base_uri.'?ip='.$ip.'#R', | 'href' => $base_uri.'?ip='.$remote_address.'#R', | ||||
| ), | ), | ||||
| $ip); | $remote_address); | ||||
| } | } | ||||
| } else { | |||||
| $ip = null; | |||||
| } | } | ||||
| $action = $log->getAction(); | $action = $log->getAction(); | ||||
| $action_name = idx($types, $action, $action); | $action_name = idx($types, $action, $action); | ||||
| if ($actor_phid) { | if ($actor_phid) { | ||||
| $actor_name = $handles[$actor_phid]->renderLink(); | $actor_name = $handles[$actor_phid]->renderLink(); | ||||
| } else { | } else { | ||||
| $actor_name = null; | $actor_name = null; | ||||
| } | } | ||||
| if ($user_phid) { | if ($user_phid) { | ||||
| $user_name = $handles[$user_phid]->renderLink(); | $user_name = $handles[$user_phid]->renderLink(); | ||||
| } else { | } else { | ||||
| $user_name = null; | $user_name = null; | ||||
| } | } | ||||
| $action_link = phutil_tag( | |||||
| 'a', | |||||
| array( | |||||
| 'href' => $log->getURI(), | |||||
| ), | |||||
| $action_name); | |||||
| $rows[] = array( | $rows[] = array( | ||||
| phabricator_date($log->getDateCreated(), $viewer), | $log->getID(), | ||||
| phabricator_time($log->getDateCreated(), $viewer), | $action_link, | ||||
| $action_name, | |||||
| $actor_name, | $actor_name, | ||||
| $user_name, | $user_name, | ||||
| $ip, | $remote_address, | ||||
| $session, | $session, | ||||
| phabricator_date($log->getDateCreated(), $viewer), | |||||
| phabricator_time($log->getDateCreated(), $viewer), | |||||
| ); | ); | ||||
| } | } | ||||
| $table = new AphrontTableView($rows); | $table = new AphrontTableView($rows); | ||||
| $table->setHeaders( | $table->setHeaders( | ||||
| array( | array( | ||||
| pht('Date'), | pht('ID'), | ||||
| pht('Time'), | |||||
| pht('Action'), | pht('Action'), | ||||
| pht('Actor'), | pht('Actor'), | ||||
| pht('User'), | pht('User'), | ||||
| pht('IP'), | pht('IP'), | ||||
| pht('Session'), | pht('Session'), | ||||
| pht('Date'), | |||||
| pht('Time'), | |||||
| )); | )); | ||||
| $table->setColumnClasses( | $table->setColumnClasses( | ||||
| array( | array( | ||||
| '', | '', | ||||
| 'right', | |||||
| 'wide', | 'wide', | ||||
| '', | '', | ||||
| '', | '', | ||||
| '', | '', | ||||
| 'n', | 'n', | ||||
| '', | |||||
| 'right', | |||||
| )); | )); | ||||
| return $table; | return $table; | ||||
| } | } | ||||
| } | } | ||||