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)));
 }
 public function render()
 {
     $logs = $this->logs;
     $handles = $this->handles;
     $viewer = $this->getUser();
     $action_map = PhabricatorUserLog::getActionTypeMap();
     $base_uri = $this->searchBaseURI;
     $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=' . $log->getRemoteAddr() . '#R'), $ip);
             $session = phutil_tag('a', array('href' => $base_uri . '?sessions=' . $log->getSession() . '#R'), $session);
         }
         $action = $log->getAction();
         $action_name = idx($action_map, $action, $action);
         $rows[] = array(phabricator_date($log->getDateCreated(), $viewer), phabricator_time($log->getDateCreated(), $viewer), $action_name, $log->getActorPHID() ? $handles[$log->getActorPHID()]->getName() : null, $handles[$log->getUserPHID()]->getName(), $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;
 }