public function render()
 {
     $rows = array();
     $rowc = array();
     // TODO: Experiment with path stack rendering.
     // TODO: Copy Away and Move Away are rendered junkily still.
     foreach ($this->pathChanges as $id => $change) {
         $path = $change->getPath();
         $hash = substr(md5($path), 0, 8);
         if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
             $path .= '/';
         }
         if (isset($this->renderingReferences[$id])) {
             $path_column = javelin_render_tag('a', array('href' => '#' . $hash, 'meta' => array('id' => 'diff-' . $hash, 'ref' => $this->renderingReferences[$id]), 'sigil' => 'differential-load'), phutil_escape_html($path));
         } else {
             $path_column = phutil_escape_html($path);
         }
         $rows[] = array($this->linkHistory($change->getPath()), $this->linkBrowse($change->getPath()), $this->linkChange($change->getChangeType(), $change->getFileType(), $change->getPath()), $path_column);
         $row_class = null;
         foreach ($this->ownersPaths as $owners_path) {
             $owners_path = $owners_path->getPath();
             if (strncmp('/' . $path, $owners_path, strlen($owners_path)) == 0) {
                 $row_class = 'highlighted';
                 break;
             }
         }
         $rowc[] = $row_class;
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('History', 'Browse', 'Change', 'Path'));
     $view->setColumnClasses(array('', '', '', 'wide'));
     $view->setRowClasses($rowc);
     $view->setNoDataString('This change has not been fully parsed yet.');
     return $view->render();
 }
 public function render()
 {
     $rows = array();
     foreach ($this->edits as $edit) {
         $name = nonempty($edit->getRuleName(), 'Unknown Rule');
         $rule_name = phutil_render_tag('strong', array(), phutil_escape_html($name));
         switch ($edit->getAction()) {
             case 'create':
                 $details = "Created rule '{$rule_name}'.";
                 break;
             case 'delete':
                 $details = "Deleted rule '{$rule_name}'.";
                 break;
             case 'edit':
             default:
                 $details = "Edited rule '{$rule_name}'.";
                 break;
         }
         $rows[] = array($edit->getRuleID(), $this->handles[$edit->getEditorPHID()]->renderLink(), $details, phabricator_datetime($edit->getDateCreated(), $this->user));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString("No edits for rule.");
     $table->setHeaders(array('Rule ID', 'Editor', 'Details', 'Edit Date'));
     $table->setColumnClasses(array('', '', 'wide', ''));
     return $table->render();
 }
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $tokens = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($viewer)->withObjectPHIDs(array($viewer->getPHID()))->execute();
     $rows = array();
     foreach ($tokens as $token) {
         if ($token->isRevocable()) {
             $button = javelin_tag('a', array('href' => '/auth/token/revoke/' . $token->getID() . '/', 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Revoke'));
         } else {
             $button = javelin_tag('a', array('class' => 'small grey button disabled'), pht('Revoke'));
         }
         if ($token->getTokenExpires() >= time()) {
             $expiry = phabricator_datetime($token->getTokenExpires(), $viewer);
         } else {
             $expiry = pht('Expired');
         }
         $rows[] = array($token->getTokenReadableTypeName(), $expiry, $button);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You don't have any active tokens."));
     $table->setHeaders(array(pht('Type'), pht('Expires'), pht('')));
     $table->setColumnClasses(array('wide', 'right', 'action'));
     $terminate_button = id(new PHUIButtonView())->setText(pht('Revoke All'))->setHref('/auth/token/revoke/all/')->setTag('a')->setWorkflow(true)->setIcon('fa-exclamation-triangle');
     $header = id(new PHUIHeaderView())->setHeader(pht('Temporary Tokens'))->addActionLink($terminate_button);
     $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
     return $panel;
 }
 public function render()
 {
     $data = $this->getData();
     $rows = array();
     $details = '';
     foreach ($data as $index => $row) {
         $file = $row['file'];
         $line = $row['line'];
         $tag = phutil_render_tag('a', array('onclick' => jsprintf('show_details(%d)', $index)), phutil_escape_html($row['str'] . ' at [' . basename($file) . ':' . $line . ']'));
         $rows[] = array($tag);
         $details .= '<div class="dark-console-panel-error-details" id="row-details-' . $index . '">' . phutil_escape_html($row['details']) . "\n" . 'Stack trace:' . "\n";
         foreach ($row['trace'] as $key => $entry) {
             $line = '';
             if (isset($entry['class'])) {
                 $line .= $entry['class'] . '::';
             }
             $line .= idx($entry, 'function', '');
             $onclick = '';
             if (isset($entry['file'])) {
                 $line .= ' called at [' . $entry['file'] . ':' . $entry['line'] . ']';
                 $onclick = jsprintf('open_file(%s, %d)', $entry['file'], $entry['line']);
             }
             $details .= phutil_render_tag('a', array('onclick' => $onclick), phutil_escape_html($line));
             $details .= "\n";
         }
         $details .= '</div>';
     }
     $table = new AphrontTableView($rows);
     $table->setClassName('error-log');
     $table->setHeaders(array('Error'));
     $table->setNoDataString('No errors.');
     return '<div>' . '<div>' . $table->render() . '</div>' . '<div class="dark-console-panel-error-separator"></div>' . '<pre class="PhabricatorMonospaced">' . $details . '</pre>' . '</div>';
 }
 public function processRequest()
 {
     $logs = id(new PhabricatorDaemonLog())->loadAllWhere('`status` != %s ORDER BY id DESC LIMIT 15', 'exit');
     $request = $this->getRequest();
     $user = $request->getUser();
     $daemon_table = new PhabricatorDaemonLogListView();
     $daemon_table->setUser($user);
     $daemon_table->setDaemonLogs($logs);
     $daemon_panel = new AphrontPanelView();
     $daemon_panel->setHeader('Recently Launched Daemons');
     $daemon_panel->appendChild($daemon_table);
     $tasks = id(new PhabricatorWorkerTask())->loadAllWhere('leaseOwner IS NOT NULL');
     $rows = array();
     foreach ($tasks as $task) {
         $rows[] = array($task->getID(), $task->getTaskClass(), $task->getLeaseOwner(), $task->getLeaseExpires() - time(), $task->getFailureCount(), phutil_render_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/', 'class' => 'button small grey'), 'View Task'));
     }
     $leased_table = new AphrontTableView($rows);
     $leased_table->setHeaders(array('ID', 'Class', 'Owner', 'Expires', 'Failures', ''));
     $leased_table->setColumnClasses(array('n', 'wide', '', '', 'n', 'action'));
     $leased_table->setNoDataString('No tasks are leased by workers.');
     $leased_panel = new AphrontPanelView();
     $leased_panel->setHeader('Leased Tasks');
     $leased_panel->appendChild($leased_table);
     $task_table = new PhabricatorWorkerTask();
     $queued = queryfx_all($task_table->establishConnection('r'), 'SELECT taskClass, count(*) N FROM %T GROUP BY taskClass
     ORDER BY N DESC', $task_table->getTableName());
     $rows = array();
     foreach ($queued as $row) {
         $rows[] = array(phutil_escape_html($row['taskClass']), number_format($row['N']));
     }
     $queued_table = new AphrontTableView($rows);
     $queued_table->setHeaders(array('Class', 'Count'));
     $queued_table->setColumnClasses(array('wide', 'n'));
     $queued_table->setNoDataString('Task queue is empty.');
     $queued_panel = new AphrontPanelView();
     $queued_panel->setHeader('Queued Tasks');
     $queued_panel->appendChild($queued_table);
     $cursors = id(new PhabricatorTimelineCursor())->loadAll();
     $rows = array();
     foreach ($cursors as $cursor) {
         $rows[] = array(phutil_escape_html($cursor->getName()), number_format($cursor->getPosition()));
     }
     $cursor_table = new AphrontTableView($rows);
     $cursor_table->setHeaders(array('Name', 'Position'));
     $cursor_table->setColumnClasses(array('wide', 'n'));
     $cursor_table->setNoDataString('No timeline cursors exist.');
     $cursor_panel = new AphrontPanelView();
     $cursor_panel->setHeader('Timeline Cursors');
     $cursor_panel->appendChild($cursor_table);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('');
     $nav->appendChild(array($daemon_panel, $cursor_panel, $queued_panel, $leased_panel));
     return $this->buildApplicationPage($nav, array('title' => 'Console'));
 }
 public function processRequest(AphrontRequest $request)
 {
     if ($request->getExists('new')) {
         return $this->processNew($request);
     }
     if ($request->getExists('edit')) {
         return $this->processEdit($request);
     }
     if ($request->getExists('delete')) {
         return $this->processDelete($request);
     }
     $user = $this->getUser();
     $viewer = $request->getUser();
     $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere('userPHID = %s', $user->getPHID());
     $rows = array();
     $rowc = array();
     $highlight_id = $request->getInt('id');
     foreach ($factors as $factor) {
         $impl = $factor->getImplementation();
         if ($impl) {
             $type = $impl->getFactorName();
         } else {
             $type = $factor->getFactorKey();
         }
         if ($factor->getID() == $highlight_id) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
         $rows[] = array(javelin_tag('a', array('href' => $this->getPanelURI('?edit=' . $factor->getID()), 'sigil' => 'workflow'), $factor->getFactorName()), $type, phabricator_datetime($factor->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $factor->getID()), 'sigil' => 'workflow', 'class' => 'small grey button'), pht('Remove')));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You haven't added any authentication factors to your account yet."));
     $table->setHeaders(array(pht('Name'), pht('Type'), pht('Created'), ''));
     $table->setColumnClasses(array('wide pri', '', 'right', 'action'));
     $table->setRowClasses($rowc);
     $table->setDeviceVisibility(array(true, false, false, true));
     $panel = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $help_uri = PhabricatorEnv::getDoclink('User Guide: Multi-Factor Authentication');
     $help_icon = id(new PHUIIconView())->setIconFont('fa-info-circle');
     $help_button = id(new PHUIButtonView())->setText(pht('Help'))->setHref($help_uri)->setTag('a')->setIcon($help_icon);
     $create_icon = id(new PHUIIconView())->setIconFont('fa-plus');
     $create_button = id(new PHUIButtonView())->setText(pht('Add Authentication Factor'))->setHref($this->getPanelURI('?new=true'))->setTag('a')->setWorkflow(true)->setIcon($create_icon);
     $header->setHeader(pht('Authentication Factors'));
     $header->addActionLink($help_button);
     $header->addActionLink($create_button);
     $panel->setHeader($header);
     $panel->setTable($table);
     return $panel;
 }
 private function buildClientList($rows, $rowc, $title)
 {
     $table = new AphrontTableView($rows);
     $table->setRowClasses($rowc);
     $table->setHeaders(array('Client', 'ID', 'Secret', 'Redirect URI', ''));
     $table->setColumnClasses(array('', '', '', '', 'action'));
     if (empty($rows)) {
         $table->setNoDataString('You have not created any clients for this OAuthServer.');
     }
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader($title);
     return $panel;
 }
 private function buildClientAuthorizationList($rows, $rowc, $title)
 {
     $table = new AphrontTableView($rows);
     $table->setRowClasses($rowc);
     $table->setHeaders(array('Client', 'Scope', 'Created', 'Updated', ''));
     $table->setColumnClasses(array('wide pri', '', '', '', 'action'));
     if (empty($rows)) {
         $table->setNoDataString('You have not authorized any clients for this OAuthServer.');
     }
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader($title);
     return $panel;
 }
 public function render()
 {
     $user = $this->user;
     require_celerity_resource('phabricator-flag-css');
     $rows = array();
     foreach ($this->flags as $flag) {
         $class = PhabricatorFlagColor::getCSSClass($flag->getColor());
         $rows[] = array(phutil_render_tag('div', array('class' => 'phabricator-flag-icon ' . $class), ''), $flag->getHandle()->renderLink(), phutil_escape_html($flag->getNote()), phabricator_datetime($flag->getDateCreated(), $user), phabricator_render_form($user, array('method' => 'POST', 'action' => '/flag/edit/' . $flag->getObjectPHID() . '/', 'sigil' => 'workflow'), phutil_render_tag('button', array('class' => 'small grey'), 'Edit Flag')), phabricator_render_form($user, array('method' => 'POST', 'action' => '/flag/delete/' . $flag->getID() . '/', 'sigil' => 'workflow'), phutil_render_tag('button', array('class' => 'small grey'), 'Remove Flag')));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('', 'Flagged Object', 'Note', 'Flagged On', '', ''));
     $table->setColumnClasses(array('', 'pri', 'wide', '', 'action', 'action'));
     $table->setNoDataString('No flags.');
     return $table->render();
 }
 public function render()
 {
     $tasks = $this->getTasks();
     $rows = array();
     foreach ($tasks as $task) {
         $rows[] = array($task->getID(), $task->getTaskClass(), $task->getLeaseOwner(), $task->getLeaseExpires() ? phutil_format_relative_time($task->getLeaseExpires() - time()) : '-', $task->getPriority(), $task->getFailureCount(), phutil_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/', 'class' => 'button small grey'), pht('View Task')));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array(pht('ID'), pht('Class'), pht('Owner'), pht('Expires'), pht('Priority'), pht('Failures'), ''));
     $table->setColumnClasses(array('n', 'wide', '', '', 'n', 'n', 'action'));
     if (strlen($this->getNoDataString())) {
         $table->setNoDataString($this->getNoDataString());
     }
     return $table;
 }
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     // TODO: It would be nice to simply disable this panel, but we can't do
     // viewer-based checks for enabled panels right now.
     $app_class = 'PhabricatorOAuthServerApplication';
     $installed = PhabricatorApplication::isClassInstalledForViewer($app_class, $viewer);
     if (!$installed) {
         $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('OAuth Not Available'))->appendParagraph(pht('You do not have access to OAuth authorizations.'))->addCancelButton('/settings/');
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     $authorizations = id(new PhabricatorOAuthClientAuthorizationQuery())->setViewer($viewer)->withUserPHIDs(array($viewer->getPHID()))->execute();
     $authorizations = mpull($authorizations, null, 'getID');
     $panel_uri = $this->getPanelURI();
     $revoke = $request->getInt('revoke');
     if ($revoke) {
         if (empty($authorizations[$revoke])) {
             return new Aphront404Response();
         }
         if ($request->isFormPost()) {
             $authorizations[$revoke]->delete();
             return id(new AphrontRedirectResponse())->setURI($panel_uri);
         }
         $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Revoke Authorization?'))->appendParagraph(pht('This application will no longer be able to access Phabricator ' . 'on your behalf.'))->addSubmitButton(pht('Revoke Authorization'))->addCancelButton($panel_uri);
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     $highlight = $request->getInt('id');
     $rows = array();
     $rowc = array();
     foreach ($authorizations as $authorization) {
         if ($highlight == $authorization->getID()) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
         $button = javelin_tag('a', array('href' => $this->getPanelURI('?revoke=' . $authorization->getID()), 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Revoke'));
         $rows[] = array(phutil_tag('a', array('href' => $authorization->getClient()->getViewURI()), $authorization->getClient()->getName()), $authorization->getScopeString(), phabricator_datetime($authorization->getDateCreated(), $viewer), phabricator_datetime($authorization->getDateModified(), $viewer), $button);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You haven't authorized any OAuth applications."));
     $table->setRowClasses($rowc);
     $table->setHeaders(array(pht('Application'), pht('Scope'), pht('Created'), pht('Updated'), null));
     $table->setColumnClasses(array('pri', 'wide', 'right', 'right', 'action'));
     $header = id(new PHUIHeaderView())->setHeader(pht('OAuth Application Authorizations'));
     $panel = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($table);
     return $panel;
 }
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $user = $this->getUser();
     $tokens = id(new PhabricatorConduitTokenQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->withExpired(false)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     $rows = array();
     foreach ($tokens as $token) {
         $rows[] = array(javelin_tag('a', array('href' => '/conduit/token/edit/' . $token->getID() . '/', 'sigil' => 'workflow'), $token->getPublicTokenName()), PhabricatorConduitToken::getTokenTypeName($token->getTokenType()), phabricator_datetime($token->getDateCreated(), $viewer), $token->getExpires() ? phabricator_datetime($token->getExpires(), $viewer) : pht('Never'), javelin_tag('a', array('class' => 'button small grey', 'href' => '/conduit/token/terminate/' . $token->getID() . '/', 'sigil' => 'workflow'), pht('Terminate')));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You don't have any active API tokens."));
     $table->setHeaders(array(pht('Token'), pht('Type'), pht('Created'), pht('Expires'), null));
     $table->setColumnClasses(array('wide pri', '', 'right', 'right', 'action'));
     $generate_button = id(new PHUIButtonView())->setText(pht('Generate API Token'))->setHref('/conduit/token/edit/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setIcon('fa-plus');
     $terminate_button = id(new PHUIButtonView())->setText(pht('Terminate All Tokens'))->setHref('/conduit/token/terminate/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setIcon('fa-exclamation-triangle');
     $header = id(new PHUIHeaderView())->setHeader(pht('Active API Tokens'))->addActionLink($generate_button)->addActionLink($terminate_button);
     $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
     return $panel;
 }
 public function render()
 {
     $rows = array();
     foreach ($this->commits as $commit) {
         $commit_name = $this->getHandle($commit->getPHID())->renderLink();
         $author_name = null;
         if ($commit->getAuthorPHID()) {
             $author_name = $this->getHandle($commit->getAuthorPHID())->renderLink();
         }
         $rows[] = array($commit_name, $author_name, phutil_escape_html($commit->getCommitData()->getSummary()), PhabricatorAuditCommitStatusConstants::getStatusName($commit->getAuditStatus()), phabricator_datetime($commit->getEpoch(), $this->user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Commit', 'Author', 'Summary', 'Audit Status', 'Date'));
     $table->setColumnClasses(array('n', '', 'wide', '', ''));
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 public function render()
 {
     $rows = array();
     // TODO: Experiment with path stack rendering.
     // TODO: Copy Away and Move Away are rendered junkily still.
     foreach ($this->pathChanges as $change) {
         $path = $change->getPath();
         $hash = substr(md5($path), 0, 8);
         if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
             $path .= '/';
         }
         $path_column = phutil_render_tag('a', array('href' => '#' . $hash), phutil_escape_html($path));
         $rows[] = array($this->linkHistory($change->getPath()), $this->linkBrowse($change->getPath()), $this->linkChange($change->getChangeType(), $change->getFileType(), $change->getPath()), $path_column);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('History', 'Browse', 'Change', 'Path'));
     $view->setColumnClasses(array('', '', '', 'wide'));
     $view->setNoDataString('This change has not been fully parsed yet.');
     return $view->render();
 }
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($viewer->getPHID()))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     $identity_phids = mpull($accounts, 'getPHID');
     $identity_phids[] = $viewer->getPHID();
     $sessions = id(new PhabricatorAuthSessionQuery())->setViewer($viewer)->withIdentityPHIDs($identity_phids)->execute();
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($identity_phids)->execute();
     $current_key = PhabricatorHash::digest($request->getCookie(PhabricatorCookies::COOKIE_SESSION));
     $rows = array();
     $rowc = array();
     foreach ($sessions as $session) {
         $is_current = phutil_hashes_are_identical($session->getSessionKey(), $current_key);
         if ($is_current) {
             $rowc[] = 'highlighted';
             $button = phutil_tag('a', array('class' => 'small grey button disabled'), pht('Current'));
         } else {
             $rowc[] = null;
             $button = javelin_tag('a', array('href' => '/auth/session/terminate/' . $session->getID() . '/', 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Terminate'));
         }
         $hisec = $session->getHighSecurityUntil() - time();
         $rows[] = array($handles[$session->getUserPHID()]->renderLink(), substr($session->getSessionKey(), 0, 6), $session->getType(), $hisec > 0 ? phutil_format_relative_time($hisec) : null, phabricator_datetime($session->getSessionStart(), $viewer), phabricator_date($session->getSessionExpires(), $viewer), $button);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You don't have any active sessions."));
     $table->setRowClasses($rowc);
     $table->setHeaders(array(pht('Identity'), pht('Session'), pht('Type'), pht('HiSec'), pht('Created'), pht('Expires'), pht('')));
     $table->setColumnClasses(array('wide', 'n', '', 'right', 'right', 'right', 'action'));
     $terminate_icon = id(new PHUIIconView())->setIconFont('fa-exclamation-triangle');
     $terminate_button = id(new PHUIButtonView())->setText(pht('Terminate All Sessions'))->setHref('/auth/session/terminate/all/')->setTag('a')->setWorkflow(true)->setIcon($terminate_icon);
     $header = id(new PHUIHeaderView())->setHeader(pht('Active Login Sessions'))->addActionLink($terminate_button);
     $hisec = $viewer->getSession()->getHighSecurityUntil() - time();
     if ($hisec > 0) {
         $hisec_icon = id(new PHUIIconView())->setIconFont('fa-lock');
         $hisec_button = id(new PHUIButtonView())->setText(pht('Leave High Security'))->setHref('/auth/session/downgrade/')->setTag('a')->setWorkflow(true)->setIcon($hisec_icon);
         $header->addActionLink($hisec_button);
     }
     $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
     return $panel;
 }
 public function render()
 {
     $type_map = HeraldRuleTypeConfig::getRuleTypeMap();
     $rows = array();
     foreach ($this->rules as $rule) {
         if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL) {
             $author = null;
         } else {
             $author = $this->handles[$rule->getAuthorPHID()]->renderLink();
         }
         $name = phutil_render_tag('a', array('href' => '/herald/rule/' . $rule->getID() . '/'), phutil_escape_html($rule->getName()));
         $edit_log = phutil_render_tag('a', array('href' => '/herald/history/' . $rule->getID() . '/'), 'View Edit Log');
         $delete = javelin_render_tag('a', array('href' => '/herald/delete/' . $rule->getID() . '/', 'sigil' => 'workflow', 'class' => 'button small grey'), 'Delete');
         $rows[] = array($type_map[$rule->getRuleType()], $author, $name, $edit_log, $delete);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString("No matching rules.");
     $table->setHeaders(array('Rule Type', 'Author', 'Rule Name', 'Edit Log', ''));
     $table->setColumnClasses(array('', '', 'wide pri', '', 'action'));
     $table->setColumnVisibility(array($this->showRuleType, $this->showAuthor, true, true, true));
     return $table->render();
 }
 public function render()
 {
     $rows = array();
     foreach ($this->rules as $rule) {
         $owner = $this->handles[$rule->getAuthorPHID()]->renderLink();
         $name = phutil_render_tag('a', array('href' => '/herald/rule/' . $rule->getID() . '/'), phutil_escape_html($rule->getName()));
         $delete = javelin_render_tag('a', array('href' => '/herald/delete/' . $rule->getID() . '/', 'sigil' => 'workflow', 'class' => 'button small grey'), 'Delete');
         $rows[] = array($this->map[$rule->getContentType()], $owner, $name, $delete);
     }
     $rules_for = phutil_escape_html($this->map[$this->view]);
     $table = new AphrontTableView($rows);
     $table->setNoDataString("No matching subscription rules for {$rules_for}.");
     $table->setHeaders(array('Type', 'Owner', 'Rule Name', ''));
     $table->setColumnClasses(array('', '', 'wide wrap pri', 'action'));
     $panel = new AphrontPanelView();
     $panel->setHeader("Herald Rules for {$rules_for}");
     if ($this->allowCreation) {
         $panel->setCreateButton('Create New Herald Rule', '/herald/new/' . $this->view . '/');
     }
     $panel->appendChild($table);
     return $panel;
 }
 public function renderPanel()
 {
     $data = $this->getData();
     $rows = array();
     $details = array();
     foreach ($data as $index => $row) {
         $file = $row['file'];
         $line = $row['line'];
         $tag = phutil_tag('a', array('onclick' => jsprintf('show_details(%d)', $index)), $row['str'] . ' at [' . basename($file) . ':' . $line . ']');
         $rows[] = array($tag);
         $details[] = hsprintf('<div class="dark-console-panel-error-details" id="row-details-%s">' . "%s\nStack trace:\n", $index, $row['details']);
         foreach ($row['trace'] as $key => $entry) {
             $line = '';
             if (isset($entry['class'])) {
                 $line .= $entry['class'] . '::';
             }
             $line .= idx($entry, 'function', '');
             $href = null;
             if (isset($entry['file'])) {
                 $line .= ' called at [' . $entry['file'] . ':' . $entry['line'] . ']';
                 try {
                     $user = $this->getRequest()->getUser();
                     $href = $user->loadEditorLink($entry['file'], $entry['line'], '');
                 } catch (Exception $ex) {
                     // The database can be inaccessible.
                 }
             }
             $details[] = phutil_tag('a', array('href' => $href), $line);
             $details[] = "\n";
         }
         $details[] = hsprintf('</div>');
     }
     $table = new AphrontTableView($rows);
     $table->setClassName('error-log');
     $table->setHeaders(array('Error'));
     $table->setNoDataString('No errors.');
     return phutil_tag('div', array(), array(phutil_tag('div', array(), $table->render()), phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details)));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $map = HeraldContentTypeConfig::getContentTypeMap();
     if (empty($map[$this->view])) {
         reset($map);
         $this->view = key($map);
     }
     $rules = id(new HeraldRule())->loadAllWhere('contentType = %s AND authorPHID = %s', $this->view, $user->getPHID());
     $need_phids = mpull($rules, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($need_phids))->loadHandles();
     $type = 'differential';
     $rows = array();
     foreach ($rules as $rule) {
         $owner = $handles[$rule->getAuthorPHID()]->renderLink();
         $name = phutil_render_tag('a', array('href' => '/herald/rule/' . $rule->getID() . '/'), phutil_escape_html($rule->getName()));
         $delete = 'delete';
         $delete = javelin_render_tag('a', array('href' => '/herald/delete/' . $rule->getID() . '/', 'sigil' => 'workflow', 'class' => 'button small grey'), 'Delete');
         $rows[] = array($map[$rule->getContentType()], $owner, $name, $delete);
     }
     $rules_for = phutil_escape_html($map[$this->view]);
     $table = new AphrontTableView($rows);
     $table->setNoDataString("No matching subscription rules for {$rules_for}.");
     $table->setHeaders(array('Type', 'Owner', 'Rule Name', ''));
     $table->setColumnClasses(array('', '', 'wide wrap pri', 'action'));
     $panel = new AphrontPanelView();
     $panel->setHeader("Herald Rules for {$rules_for}");
     $panel->setCreateButton('Create New Herald Rule', '/herald/new/' . $this->view . '/');
     $panel->appendChild($table);
     $sidenav = new AphrontSideNavView();
     $sidenav->appendChild($panel);
     foreach ($map as $key => $value) {
         $sidenav->addNavItem(phutil_render_tag('a', array('href' => '/herald/view/' . $key . '/', 'class' => $key == $this->view ? 'aphront-side-nav-selected' : null), phutil_escape_html($value)));
     }
     return $this->buildStandardPageResponse($sidenav, array('title' => 'Herald', 'tab' => 'rules'));
 }
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $this->name = $request->getURIData('name');
     $query = id(new DiffusionSymbolQuery())->setViewer($user)->setName($this->name);
     if ($request->getStr('context')) {
         $query->setContext($request->getStr('context'));
     }
     if ($request->getStr('type')) {
         $query->setType($request->getStr('type'));
     }
     if ($request->getStr('lang')) {
         $query->setLanguage($request->getStr('lang'));
     }
     if ($request->getStr('repositories')) {
         $phids = $request->getStr('repositories');
         $phids = explode(',', $phids);
         $phids = array_filter($phids);
         if ($phids) {
             $repos = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute();
             $repos = mpull($repos, 'getPHID');
             if ($repos) {
                 $query->withRepositoryPHIDs($repos);
             }
         }
     }
     $query->needPaths(true);
     $query->needRepositories(true);
     $symbols = $query->execute();
     $external_query = id(new DiffusionExternalSymbolQuery())->withNames(array($this->name));
     if ($request->getStr('context')) {
         $external_query->withContexts(array($request->getStr('context')));
     }
     if ($request->getStr('type')) {
         $external_query->withTypes(array($request->getStr('type')));
     }
     if ($request->getStr('lang')) {
         $external_query->withLanguages(array($request->getStr('lang')));
     }
     $external_sources = id(new PhutilClassMapQuery())->setAncestorClass('DiffusionExternalSymbolsSource')->execute();
     $results = array($symbols);
     foreach ($external_sources as $source) {
         $results[] = $source->executeQuery($external_query);
     }
     $symbols = array_mergev($results);
     if ($request->getBool('jump') && count($symbols) == 1) {
         // If this is a clickthrough from Differential, just jump them
         // straight to the target if we got a single hit.
         $symbol = head($symbols);
         return id(new AphrontRedirectResponse())->setIsExternal($symbol->isExternal())->setURI($symbol->getURI());
     }
     $rows = array();
     foreach ($symbols as $symbol) {
         $href = $symbol->getURI();
         if ($symbol->isExternal()) {
             $source = $symbol->getSource();
             $location = $symbol->getLocation();
         } else {
             $repo = $symbol->getRepository();
             $file = $symbol->getPath();
             $line = $symbol->getLineNumber();
             $source = $repo->getMonogram();
             $location = $file . ':' . $line;
         }
         $location = phutil_tag('a', array('href' => $href), $location);
         $rows[] = array($symbol->getSymbolType(), $symbol->getSymbolContext(), $symbol->getSymbolName(), $symbol->getSymbolLanguage(), $source, $location);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array(pht('Type'), pht('Context'), pht('Name'), pht('Language'), pht('Source'), pht('Location')));
     $table->setColumnClasses(array('', '', 'pri', '', '', ''));
     $table->setNoDataString(pht('No matching symbol could be found in any indexed repository.'));
     $panel = new PHUIObjectBoxView();
     $panel->setHeaderText(pht('Similar Symbols'));
     $panel->setTable($table);
     return $this->buildApplicationPage($panel, array('title' => pht('Find Symbol')));
 }
 public function render()
 {
     $user = $this->user;
     if (!$user) {
         throw new Exception("Call setUser() before render()!");
     }
     foreach ($this->fields as $field) {
         $field->setUser($this->user);
         $field->setHandles($this->handles);
     }
     $rows = array();
     foreach ($this->revisions as $revision) {
         $row = array();
         foreach ($this->fields as $field) {
             $row[] = $field->renderValueForRevisionList($revision);
         }
         $rows[] = $row;
     }
     $headers = array();
     $classes = array();
     foreach ($this->fields as $field) {
         $headers[] = $field->renderHeaderForRevisionList();
         $classes[] = $field->getColumnClassForRevisionList();
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders($headers);
     $table->setColumnClasses($classes);
     $table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING);
     return $table->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
     if ($shortcuts) {
         $shortcuts = msort($shortcuts, 'getSequence');
         $rows = array();
         foreach ($shortcuts as $shortcut) {
             $rows[] = array(phutil_render_tag('a', array('href' => $shortcut->getHref()), phutil_escape_html($shortcut->getName())), phutil_escape_html($shortcut->getDescription()));
         }
         $shortcut_table = new AphrontTableView($rows);
         $shortcut_table->setHeaders(array('Link', ''));
         $shortcut_table->setColumnClasses(array('pri', 'wide'));
         $shortcut_panel = new AphrontPanelView();
         $shortcut_panel->setHeader('Shortcuts');
         $shortcut_panel->appendChild($shortcut_table);
     } else {
         $shortcut_panel = null;
     }
     $repository = new PhabricatorRepository();
     $repositories = $repository->loadAll();
     foreach ($repositories as $key => $repo) {
         if (!$repo->isTracked()) {
             unset($repositories[$key]);
         }
     }
     $repository_ids = mpull($repositories, 'getID');
     $summaries = array();
     $commits = array();
     if ($repository_ids) {
         $summaries = queryfx_all($repository->establishConnection('r'), 'SELECT * FROM %T WHERE repositoryID IN (%Ld)', PhabricatorRepository::TABLE_SUMMARY, $repository_ids);
         $summaries = ipull($summaries, null, 'repositoryID');
         $commit_ids = array_filter(ipull($summaries, 'lastCommitID'));
         if ($commit_ids) {
             $commit = new PhabricatorRepositoryCommit();
             $commits = $commit->loadAllWhere('id IN (%Ld)', $commit_ids);
             $commits = mpull($commits, null, 'getRepositoryID');
         }
     }
     $rows = array();
     foreach ($repositories as $repository) {
         $id = $repository->getID();
         $commit = idx($commits, $id);
         $size = idx(idx($summaries, $id, array()), 'size', 0);
         $date = '-';
         $time = '-';
         if ($commit) {
             $date = phabricator_date($commit->getEpoch(), $user);
             $time = phabricator_time($commit->getEpoch(), $user);
         }
         $rows[] = array(phutil_render_tag('a', array('href' => '/diffusion/' . $repository->getCallsign() . '/'), phutil_escape_html($repository->getName())), phutil_escape_html($repository->getDetail('description')), PhabricatorRepositoryType::getNameForRepositoryType($repository->getVersionControlSystem()), $size ? number_format($size) : '-', $commit ? DiffusionView::linkCommit($repository, $commit->getCommitIdentifier()) : '-', $date, $time);
     }
     $repository_tool_uri = PhabricatorEnv::getProductionURI('/repository/');
     $repository_tool = phutil_render_tag('a', array('href' => $repository_tool_uri), 'repository tool');
     $no_repositories_txt = 'This instance of Phabricator does not have any ' . 'configured repositories. ';
     if ($user->getIsAdmin()) {
         $no_repositories_txt .= 'To setup one or more repositories, visit the ' . $repository_tool . '.';
     } else {
         $no_repositories_txt .= 'Ask an administrator to setup one or more ' . 'repositories via the ' . $repository_tool . '.';
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString($no_repositories_txt);
     $table->setHeaders(array('Repository', 'Description', 'VCS', 'Commits', 'Last', 'Date', 'Time'));
     $table->setColumnClasses(array('pri', 'wide', '', 'n', 'n', '', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Browse Repositories');
     $panel->appendChild($table);
     $crumbs = $this->buildCrumbs();
     return $this->buildStandardPageResponse(array($crumbs, $shortcut_panel, $panel), array('title' => 'Diffusion'));
 }
 private function buildApplyTranscriptPanel($xscript)
 {
     $handles = $this->handles;
     $action_names = HeraldActionConfig::getActionMessageMapForRuleType(null);
     $rows = array();
     foreach ($xscript->getApplyTranscripts() as $apply_xscript) {
         $target = $apply_xscript->getTarget();
         switch ($apply_xscript->getAction()) {
             case HeraldActionConfig::ACTION_NOTHING:
                 $target = '';
                 break;
             case HeraldActionConfig::ACTION_FLAG:
                 $target = PhabricatorFlagColor::getColorName($target);
                 break;
             default:
                 if ($target) {
                     foreach ($target as $k => $phid) {
                         $target[$k] = $handles[$phid]->getName();
                     }
                     $target = implode("\n", $target);
                 } else {
                     $target = '<empty>';
                 }
                 break;
         }
         $target = phutil_escape_html($target);
         if ($apply_xscript->getApplied()) {
             $outcome = '<span class="outcome-success">SUCCESS</span>';
         } else {
             $outcome = '<span class="outcome-failure">FAILURE</span>';
         }
         $outcome .= ' ' . phutil_escape_html($apply_xscript->getAppliedReason());
         $rows[] = array(phutil_escape_html($action_names[$apply_xscript->getAction()]), $target, '<strong>Taken because:</strong> ' . phutil_escape_html($apply_xscript->getReason()) . '<br />' . '<strong>Outcome:</strong> ' . $outcome);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString('No actions were taken.');
     $table->setHeaders(array('Action', 'Target', 'Details'));
     $table->setColumnClasses(array('', '', 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Actions Taken');
     $panel->appendChild($table);
     return $panel;
 }
 private function renderKeyListView(AphrontRequest $request)
 {
     $user = $request->getUser();
     $keys = id(new PhabricatorUserSSHKey())->loadAllWhere('userPHID = %s', $user->getPHID());
     $rows = array();
     foreach ($keys as $key) {
         $rows[] = array(phutil_render_tag('a', array('href' => $this->getPanelURI('?edit=' . $key->getID())), phutil_escape_html($key->getName())), phutil_escape_html($key->getKeyComment()), phutil_escape_html($key->getKeyType()), phabricator_date($key->getDateCreated(), $user), phabricator_time($key->getDateCreated(), $user), javelin_render_tag('a', array('href' => $this->getPanelURI('?delete=' . $key->getID()), 'class' => 'small grey button', 'sigil' => 'workflow'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString("You haven't added any SSH Public Keys.");
     $table->setHeaders(array('Name', 'Comment', 'Type', 'Created', 'Time', ''));
     $table->setColumnClasses(array('wide pri', '', '', '', 'right', 'action'));
     $panel = new AphrontPanelView();
     $panel->addButton(phutil_render_tag('a', array('href' => $this->getPanelURI('?edit=true'), 'class' => 'green button'), 'Add New Public Key'));
     $panel->setHeader('SSH Public Keys');
     $panel->appendChild($table);
     return $panel;
 }
 public function render()
 {
     $rowc = array();
     $last = null;
     $rows = array();
     foreach ($this->audits as $audit) {
         $commit_phid = $audit->getCommitPHID();
         $committed = null;
         if ($last == $commit_phid) {
             $commit_name = null;
             $commit_desc = null;
         } else {
             $commit_name = $this->getHandle($commit_phid)->renderLink();
             $commit_desc = $this->getCommitDescription($commit_phid);
             $commit = idx($this->commits, $commit_phid);
             if ($commit && $this->user) {
                 $committed = phabricator_datetime($commit->getEpoch(), $this->user);
             }
             $last = $commit_phid;
         }
         $reasons = $audit->getAuditReasons();
         foreach ($reasons as $key => $reason) {
             $reasons[$key] = phutil_escape_html($reason);
         }
         $reasons = implode('<br />', $reasons);
         $status_code = $audit->getAuditStatus();
         $status = PhabricatorAuditStatusConstants::getStatusName($status_code);
         $auditor_handle = $this->getHandle($audit->getAuditorPHID());
         $rows[] = array($commit_name, phutil_escape_html($commit_desc), $committed, $auditor_handle->renderLink(), phutil_escape_html($status), $reasons);
         $row_class = null;
         if (array_key_exists($audit->getID(), $this->getHighlightedAudits())) {
             $row_class = 'highlighted';
         }
         $rowc[] = $row_class;
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Commit', 'Description', 'Committed', 'Auditor', 'Status', 'Details'));
     $table->setColumnClasses(array('pri', $this->showDescriptions ? 'wide' : '', '', '', '', $this->showDescriptions ? '' : 'wide'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array($this->showDescriptions, $this->showDescriptions, $this->showDescriptions, true, true, true));
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $query = new DiffusionSymbolQuery();
     $query->setName($this->name);
     if ($request->getStr('type')) {
         $query->setType($request->getStr('type'));
     }
     if ($request->getStr('lang')) {
         $query->setLanguage($request->getStr('lang'));
     }
     if ($request->getStr('projects')) {
         $phids = $request->getStr('projects');
         $phids = explode(',', $phids);
         $phids = array_filter($phids);
         if ($phids) {
             $projects = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere('phid IN (%Ls)', $phids);
             $projects = mpull($projects, 'getID');
             if ($projects) {
                 $query->setProjectIDs($projects);
             }
         }
     }
     $query->needPaths(true);
     $query->needArcanistProjects(true);
     $query->needRepositories(true);
     $symbols = $query->execute();
     // For PHP builtins, jump to php.net documentation.
     if ($request->getBool('jump') && count($symbols) == 0) {
         if ($request->getStr('lang') == 'php') {
             if ($request->getStr('type') == 'function') {
                 if (in_array($this->name, idx(get_defined_functions(), 'internal'))) {
                     return id(new AphrontRedirectResponse())->setURI('http://www.php.net/' . $this->name);
                 }
             }
         }
     }
     $rows = array();
     foreach ($symbols as $symbol) {
         $project = $symbol->getArcanistProject();
         if ($project) {
             $project_name = $project->getName();
         } else {
             $project_name = '-';
         }
         $file = phutil_escape_html($symbol->getPath());
         $line = phutil_escape_html($symbol->getLineNumber());
         $repo = $symbol->getRepository();
         if ($repo) {
             $href = $symbol->getURI();
             if ($request->getBool('jump') && count($symbols) == 1) {
                 // If this is a clickthrough from Differential, just jump them
                 // straight to the target if we got a single hit.
                 return id(new AphrontRedirectResponse())->setURI($href);
             }
             $location = phutil_render_tag('a', array('href' => $href), phutil_escape_html($file . ':' . $line));
         } else {
             if ($file) {
                 $location = phutil_escape_html($file . ':' . $line);
             } else {
                 $location = '?';
             }
         }
         $rows[] = array(phutil_escape_html($symbol->getSymbolType()), phutil_escape_html($symbol->getSymbolName()), phutil_escape_html($symbol->getSymbolLanguage()), phutil_escape_html($project_name), $location);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Type', 'Name', 'Language', 'Project', 'File'));
     $table->setColumnClasses(array('', 'pri', '', '', '', 'n'));
     $table->setNoDataString("No matching symbol could be found in any indexed project.");
     $panel = new AphrontPanelView();
     $panel->setHeader('Similar Symbols');
     $panel->appendChild($table);
     return $this->buildStandardPageResponse(array($panel), array('title' => 'Find Symbol'));
 }
 private function buildApplyTranscriptPanel($xscript)
 {
     $handles = $this->handles;
     $action_names = HeraldActionConfig::getActionMap();
     $rows = array();
     foreach ($xscript->getApplyTranscripts() as $apply_xscript) {
         // TODO: Hacks, this is an approximate guess at the target type.
         $target = (array) $apply_xscript->getTarget();
         if (!$target) {
             if ($apply_xscript->getAction() == HeraldActionConfig::ACTION_NOTHING) {
                 $target = '';
             } else {
                 $target = '<empty>';
             }
         } else {
             foreach ($target as $k => $phid) {
                 $target[$k] = $handles[$phid]->getName();
             }
             $target = implode("\n", $target);
         }
         $target = phutil_escape_html($target);
         if ($apply_xscript->getApplied()) {
             $outcome = '<span class="outcome-success">SUCCESS</span>';
         } else {
             $outcome = '<span class="outcome-failure">FAILURE</span>';
         }
         $outcome .= ' ' . phutil_escape_html($apply_xscript->getAppliedReason());
         $rows[] = array(phutil_escape_html($action_names[$apply_xscript->getAction()]), $target, '<strong>Taken because:</strong> ' . phutil_escape_html($apply_xscript->getReason()) . '<br />' . '<strong>Outcome:</strong> ' . $outcome);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString('No actions were taken.');
     $table->setHeaders(array('Action', 'Target', 'Details'));
     $table->setColumnClasses(array('', '', 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Actions Taken');
     $panel->appendChild($table);
     return $panel;
 }
 public function render()
 {
     $rows = array();
     foreach ($this->commits as $commit) {
         $commit_name = $this->getHandle($commit->getPHID())->renderLink();
         $author_name = null;
         if ($commit->getAuthorPHID()) {
             $author_name = $this->getHandle($commit->getAuthorPHID())->renderLink();
         }
         $auditors = array();
         if ($commit->getAudits()) {
             foreach ($commit->getAudits() as $audit) {
                 $actor_phid = $audit->getActorPHID();
                 $auditors[$actor_phid] = $this->getHandle($actor_phid)->renderLink();
             }
         }
         $rows[] = array($commit_name, $author_name, phutil_escape_html($commit->getCommitData()->getSummary()), PhabricatorAuditCommitStatusConstants::getStatusName($commit->getAuditStatus()), implode(', ', $auditors), phabricator_datetime($commit->getEpoch(), $this->user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Commit', 'Author', 'Summary', 'Audit Status', 'Auditors', 'Date'));
     $table->setColumnClasses(array('n', '', 'wide', '', '', ''));
     if ($this->commits && reset($this->commits)->getAudits() === null) {
         $table->setColumnVisibility(array(true, true, true, true, false, true));
     }
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 public function render()
 {
     $user = $this->user;
     $authority = array_fill_keys($this->authorityPHIDs, true);
     $rowc = array();
     $last = null;
     $rows = array();
     foreach ($this->audits as $audit) {
         $commit_phid = $audit->getCommitPHID();
         if ($last == $commit_phid) {
             $commit_name = null;
             $commit_desc = null;
         } else {
             $commit_name = $this->getHandle($commit_phid)->renderLink();
             $commit_desc = $this->getCommitDescription($commit_phid);
             $last = $commit_phid;
         }
         $reasons = $audit->getAuditReasons();
         foreach ($reasons as $key => $reason) {
             $reasons[$key] = phutil_escape_html($reason);
         }
         $reasons = implode('<br />', $reasons);
         $status_code = $audit->getAuditStatus();
         $status = PhabricatorAuditStatusConstants::getStatusName($status_code);
         $auditor_handle = $this->getHandle($audit->getAuditorPHID());
         $rows[] = array($commit_name, phutil_escape_html($commit_desc), $auditor_handle->renderLink(), phutil_escape_html($status), $reasons);
         $row_class = null;
         $has_authority = !empty($authority[$audit->getAuditorPHID()]);
         if ($has_authority) {
             $commit_author = $this->commits[$commit_phid]->getAuthorPHID();
             // You don't have authority over package and project audits on your own
             // commits.
             $auditor_is_user = $audit->getAuditorPHID() == $user->getPHID();
             $user_is_author = $commit_author == $user->getPHID();
             if ($auditor_is_user || !$user_is_author) {
                 $row_class = 'highlighted';
             }
         }
         $rowc[] = $row_class;
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Commit', 'Description', 'Auditor', 'Status', 'Details'));
     $table->setColumnClasses(array('pri', $this->showDescriptions ? 'wide' : '', '', '', $this->showDescriptions ? '' : 'wide'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array($this->showDescriptions, $this->showDescriptions, true, true, true));
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 public function render()
 {
     $user = $this->user;
     if (!$user) {
         throw new Exception("Call setUser() before render()!");
     }
     $flags = id(new PhabricatorFlagQuery())->withOwnerPHIDs(array($user->getPHID()))->withObjectPHIDs(mpull($this->revisions, 'getPHID'))->execute();
     $flagged = mpull($flags, null, 'getObjectPHID');
     foreach ($this->fields as $field) {
         $field->setUser($this->user);
         $field->setHandles($this->handles);
     }
     $rows = array();
     foreach ($this->revisions as $revision) {
         $phid = $revision->getPHID();
         $flag = '';
         if (isset($flagged[$phid])) {
             $class = PhabricatorFlagColor::getCSSClass($flagged[$phid]->getColor());
             $note = $flagged[$phid]->getNote();
             $flag = phutil_render_tag('div', array('class' => 'phabricator-flag-icon ' . $class, 'title' => $note), '');
         }
         $row = array($flag);
         foreach ($this->fields as $field) {
             $row[] = $field->renderValueForRevisionList($revision);
         }
         $rows[] = $row;
     }
     $headers = array('');
     $classes = array('');
     foreach ($this->fields as $field) {
         $headers[] = $field->renderHeaderForRevisionList();
         $classes[] = $field->getColumnClassForRevisionList();
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders($headers);
     $table->setColumnClasses($classes);
     $table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING);
     return $table->render();
 }