Path: blob/master/src/applications/people/view/PhabricatorUserLogView.php
12256 views
<?php12final class PhabricatorUserLogView extends AphrontView {34private $logs;5private $searchBaseURI;67public function setSearchBaseURI($search_base_uri) {8$this->searchBaseURI = $search_base_uri;9return $this;10}1112public function setLogs(array $logs) {13assert_instances_of($logs, 'PhabricatorUserLog');14$this->logs = $logs;15return $this;16}1718public function render() {19$logs = $this->logs;20$viewer = $this->getUser();2122$phids = array();23foreach ($logs as $log) {24$phids[] = $log->getActorPHID();25$phids[] = $log->getUserPHID();26}27$handles = $viewer->loadHandles($phids);2829$types = PhabricatorUserLogType::getAllLogTypes();30$types = mpull($types, 'getLogTypeName', 'getLogTypeKey');3132$base_uri = $this->searchBaseURI;3334$viewer_phid = $viewer->getPHID();3536$rows = array();37foreach ($logs as $log) {38// Events such as "Login Failure" will not have an associated session.39$session = $log->getSession();40if ($session === null) {41$session = '';42}43$session = substr($session, 0, 6);4445$actor_phid = $log->getActorPHID();46$user_phid = $log->getUserPHID();4748$remote_address = $log->getRemoteAddressForViewer($viewer);49if ($remote_address !== null) {50if ($base_uri) {51$remote_address = phutil_tag(52'a',53array(54'href' => $base_uri.'?ip='.$remote_address.'#R',55),56$remote_address);57}58}5960$action = $log->getAction();61$action_name = idx($types, $action, $action);6263if ($actor_phid) {64$actor_name = $handles[$actor_phid]->renderLink();65} else {66$actor_name = null;67}6869if ($user_phid) {70$user_name = $handles[$user_phid]->renderLink();71} else {72$user_name = null;73}7475$action_link = phutil_tag(76'a',77array(78'href' => $log->getURI(),79),80$action_name);8182$rows[] = array(83$log->getID(),84$action_link,85$actor_name,86$user_name,87$remote_address,88$session,89phabricator_date($log->getDateCreated(), $viewer),90phabricator_time($log->getDateCreated(), $viewer),91);92}9394$table = new AphrontTableView($rows);95$table->setHeaders(96array(97pht('ID'),98pht('Action'),99pht('Actor'),100pht('User'),101pht('IP'),102pht('Session'),103pht('Date'),104pht('Time'),105));106$table->setColumnClasses(107array(108'',109'wide',110'',111'',112'',113'n',114'',115'right',116));117118return $table;119}120}121122123