public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
 public function render()
 {
     $request = $this->getDiffusionRequest();
     $repository = $request->getRepository();
     $base_path = trim($request->getPath(), '/');
     if ($base_path) {
         $base_path = $base_path . '/';
     }
     $need_pull = array();
     $rows = array();
     $show_edit = false;
     foreach ($this->paths as $path) {
         $full_path = $base_path . $path->getPath();
         $dir_slash = null;
         $file_type = $path->getFileType();
         if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
             $browse_text = $path->getPath() . '/';
             $dir_slash = '/';
             $browse_link = phutil_tag('strong', array(), $this->linkBrowse($full_path . $dir_slash, array('type' => $file_type, 'name' => $browse_text)));
             $history_path = $full_path . '/';
         } else {
             if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {
                 $browse_text = $path->getPath() . '/';
                 $browse_link = phutil_tag('strong', array(), $this->linkBrowse(null, array('type' => $file_type, 'name' => $browse_text, 'hash' => $path->getHash(), 'external' => $path->getExternalURI())));
                 $history_path = $full_path . '/';
             } else {
                 $browse_text = $path->getPath();
                 $browse_link = $this->linkBrowse($full_path, array('type' => $file_type, 'name' => $browse_text));
                 $history_path = $full_path;
             }
         }
         $history_link = $this->linkHistory($history_path);
         $dict = array('lint' => celerity_generate_unique_node_id(), 'commit' => celerity_generate_unique_node_id(), 'date' => celerity_generate_unique_node_id(), 'author' => celerity_generate_unique_node_id(), 'details' => celerity_generate_unique_node_id());
         $need_pull[$full_path . $dir_slash] = $dict;
         foreach ($dict as $k => $uniq) {
             $dict[$k] = phutil_tag('span', array('id' => $uniq), '');
         }
         $rows[] = array($history_link, $browse_link, idx($dict, 'lint'), $dict['commit'], $dict['details'], $dict['date']);
     }
     if ($need_pull) {
         Javelin::initBehavior('diffusion-pull-lastmodified', array('uri' => (string) $request->generateURI(array('action' => 'lastmodified', 'stable' => true)), 'map' => $need_pull));
     }
     $branch = $this->getDiffusionRequest()->loadBranch();
     $show_lint = $branch && $branch->getLintCommit();
     $lint = $request->getLint();
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, pht('Path'), $lint ? $lint : pht('Lint'), pht('Modified'), pht('Details'), pht('Committed')));
     $view->setColumnClasses(array('nudgeright', '', '', '', 'wide', 'right'));
     $view->setColumnVisibility(array(true, true, $show_lint, true, true, true));
     $view->setDeviceVisibility(array(true, true, false, false, true, false));
     return $view->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $is_admin = $user->getIsAdmin();
     $repos = id(new PhabricatorRepositoryQuery())->setViewer($user)->execute();
     $repos = msort($repos, 'getName');
     $rows = array();
     foreach ($repos as $repo) {
         if ($repo->isTracked()) {
             $diffusion_link = phutil_tag('a', array('href' => '/diffusion/' . $repo->getCallsign() . '/'), 'View in Diffusion');
         } else {
             $diffusion_link = phutil_tag('em', array(), 'Not Tracked');
         }
         $rows[] = array($repo->getCallsign(), $repo->getName(), PhabricatorRepositoryType::getNameForRepositoryType($repo->getVersionControlSystem()), $diffusion_link, phutil_tag('a', array('class' => 'button small grey', 'href' => '/diffusion/' . $repo->getCallsign() . '/edit/'), 'Edit'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Callsign', 'Repository', 'Type', 'Diffusion', ''));
     $table->setColumnClasses(array(null, 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('Repositories');
     if ($is_admin) {
         $panel->setCreateButton('Create New Repository', '/diffusion/new/');
     }
     $panel->appendChild($table);
     $panel->setNoBackground();
     $projects = id(new PhabricatorRepositoryArcanistProject())->loadAll();
     $rows = array();
     foreach ($projects as $project) {
         $repo = idx($repos, $project->getRepositoryID());
         if ($repo) {
             $repo_name = $repo->getName();
         } else {
             $repo_name = '-';
         }
         $rows[] = array($project->getName(), $repo_name, phutil_tag('a', array('href' => '/repository/project/edit/' . $project->getID() . '/', 'class' => 'button grey small'), 'Edit'), javelin_tag('a', array('href' => '/repository/project/delete/' . $project->getID() . '/', 'class' => 'button grey small', 'sigil' => 'workflow'), 'Delete'));
     }
     $project_table = new AphrontTableView($rows);
     $project_table->setHeaders(array('Project ID', 'Repository', '', ''));
     $project_table->setColumnClasses(array('', 'wide', 'action', 'action'));
     $project_table->setColumnVisibility(array(true, true, $is_admin, $is_admin));
     $project_panel = new AphrontPanelView();
     $project_panel->setHeader('Arcanist Projects');
     $project_panel->appendChild($project_table);
     $project_panel->setNoBackground();
     return $this->buildStandardPageResponse(array($panel, $project_panel), array('title' => 'Repository List'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorUser())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     $rows = array();
     foreach ($users as $user) {
         $status = '';
         if ($user->getIsDisabled()) {
             $status = 'Disabled';
         } else {
             if ($user->getIsAdmin()) {
                 $status = 'Admin';
             } else {
                 $status = '-';
             }
         }
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Status', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
     }
     return $this->buildStandardPageResponse($panel, array('title' => 'People', 'tab' => 'directory'));
 }
 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()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = date('M j, Y', $epoch);
             $time = date('g:i A', $epoch);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($history->getAuthorName());
         }
         $rows[] = array($this->linkBrowse($drequest->getPath(), array('commit' => $history->getCommitIdentifier())), $graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $this->linkChange($history->getChangeType(), $history->getFileType(), null, $history->getCommitIdentifier()), $date, $time, $author, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($history->getSummary())));
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('Browse', '', 'Commit', 'Change', 'Date', 'Time', 'Author', 'Details'));
     $view->setColumnClasses(array('', 'threads', 'n', '', '', 'right', '', 'wide'));
     $view->setColumnVisibility(array(true, $graph ? true : false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $viewer = $this->getUser();
     $buildables = $this->loadBuildables(mpull($this->history, 'getCommit'));
     $has_any_build = false;
     $show_revisions = PhabricatorApplication::isClassInstalledForViewer('PhabricatorDifferentialApplication', $viewer);
     $handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $committed = phabricator_datetime($epoch, $viewer);
         } else {
             $committed = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), pht("Importing…"));
         }
         $build = null;
         if ($show_builds) {
             $buildable = idx($buildables, $commit->getPHID());
             if ($buildable !== null) {
                 $build = $this->renderBuildable($buildable);
                 $has_any_build = true;
             }
         }
         $browse = $this->linkBrowse($history->getPath(), array('commit' => $history->getCommitIdentifier(), 'branch' => $drequest->getBranch(), 'type' => $history->getFileType()));
         $rows[] = array($graph ? $graph[$ii++] : null, $browse, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $committed);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, null, pht('Commit'), null, null, pht('Author/Committer'), pht('Details'), pht('Committed')));
     $view->setColumnClasses(array('threads', 'nudgeright', '', 'icon', '', '', 'wide', ''));
     $view->setColumnVisibility(array($graph ? true : false, true, true, $has_any_build, $show_revisions));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, true, false, true, false));
     return $view->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = phabricator_date($epoch, $this->user);
             $time = phabricator_time($epoch, $this->user);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), "Importing…");
         }
         $build = null;
         if ($show_builds) {
             $buildable_lookup = $this->loadBuildablesOnDemand();
             $buildable = idx($buildable_lookup, $commit->getPHID());
             if ($buildable !== null) {
                 $icon = HarbormasterBuildable::getBuildableStatusIcon($buildable->getBuildableStatus());
                 $color = HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus());
                 $name = HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus());
                 $icon_view = id(new PHUIIconView())->setIconFont($icon . ' ' . $color);
                 $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view);
                 Javelin::initBehavior('phabricator-tooltips');
                 $href_view = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view);
                 $build = $href_view;
                 $has_any_build = true;
             }
         }
         $rows[] = array($graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $date, $time);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('', pht('Commit'), '', pht('Revision'), pht('Author/Committer'), pht('Details'), pht('Date'), pht('Time')));
     $view->setColumnClasses(array('threads', 'n', 'icon', 'n', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array($graph ? true : false));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, false, true, false, false));
     return $view->render();
 }
 public function processRequest(AphrontRequest $request)
 {
     $user = $this->getUser();
     $editable = PhabricatorEnv::getEnvConfig('account.editable');
     $uri = $request->getRequestURI();
     $uri->setQueryParams(array());
     if ($editable) {
         $new = $request->getStr('new');
         if ($new) {
             return $this->returnNewAddressResponse($request, $uri, $new);
         }
         $delete = $request->getInt('delete');
         if ($delete) {
             return $this->returnDeleteAddressResponse($request, $uri, $delete);
         }
     }
     $verify = $request->getInt('verify');
     if ($verify) {
         return $this->returnVerifyAddressResponse($request, $uri, $verify);
     }
     $primary = $request->getInt('primary');
     if ($primary) {
         return $this->returnPrimaryAddressResponse($request, $uri, $primary);
     }
     $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
     $rowc = array();
     $rows = array();
     foreach ($emails as $email) {
         $button_verify = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('verify', $email->getID()), 'sigil' => 'workflow'), pht('Verify'));
         $button_make_primary = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('primary', $email->getID()), 'sigil' => 'workflow'), pht('Make Primary'));
         $button_remove = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), pht('Remove'));
         $button_primary = phutil_tag('a', array('class' => 'button small disabled'), pht('Primary'));
         if (!$email->getIsVerified()) {
             $action = $button_verify;
         } else {
             if ($email->getIsPrimary()) {
                 $action = $button_primary;
             } else {
                 $action = $button_make_primary;
             }
         }
         if ($email->getIsPrimary()) {
             $remove = $button_primary;
             $rowc[] = 'highlighted';
         } else {
             $remove = $button_remove;
             $rowc[] = null;
         }
         $rows[] = array($email->getAddress(), $action, $remove);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array(pht('Email'), pht('Status'), pht('Remove')));
     $table->setColumnClasses(array('wide', 'action', 'action'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array(true, true, $editable));
     $view = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $header->setHeader(pht('Email Addresses'));
     if ($editable) {
         $button = new PHUIButtonView();
         $button->setText(pht('Add New Address'));
         $button->setTag('a');
         $button->setHref($uri->alter('new', 'true'));
         $button->setIcon('fa-plus');
         $button->addSigil('workflow');
         $header->addActionLink($button);
     }
     $view->setHeader($header);
     $view->setTable($table);
     return $view;
 }
 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()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = date('M j, Y', $epoch);
             $time = date('g:i A', $epoch);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author .= '/' . $committer;
         }
         $commit = $history->getCommit();
         if ($commit && !$commit->getIsUnparsed() && $data) {
             $change = $this->linkChange($history->getChangeType(), $history->getFileType(), $path = null, $history->getCommitIdentifier());
         } else {
             $change = "<em>Importing…</em>";
         }
         $rows[] = array($this->linkBrowse($drequest->getPath(), array('commit' => $history->getCommitIdentifier())), $graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $change, $date, $time, $author, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($history->getSummary())));
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('Browse', '', 'Commit', 'Revision', 'Change', 'Date', 'Time', 'Author/Committer', 'Details'));
     $view->setColumnClasses(array('', 'threads', 'n', 'n', '', '', 'right', '', 'wide'));
     $view->setColumnVisibility(array(true, $graph ? true : false));
     return $view->render();
 }
 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 render()
 {
     $drequest = $this->getDiffusionRequest();
     $current_branch = $drequest->getBranch();
     $repository = $drequest->getRepository();
     $commits = $this->commits;
     $viewer = $this->getUser();
     $buildables = $this->loadBuildables($commits);
     $have_builds = false;
     $can_close_branches = $repository->isHg();
     Javelin::initBehavior('phabricator-tooltips');
     $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
     $rows = array();
     $rowc = array();
     foreach ($this->branches as $branch) {
         $commit = idx($commits, $branch->getCommitIdentifier());
         if ($commit) {
             $details = $commit->getSummary();
             $datetime = $viewer->formatShortDateTime($commit->getEpoch());
             $buildable = idx($buildables, $commit->getPHID());
             if ($buildable) {
                 $build_status = $this->renderBuildable($buildable);
                 $have_builds = true;
             } else {
                 $build_status = null;
             }
         } else {
             $datetime = null;
             $details = null;
             $build_status = null;
         }
         switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) {
             case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Importing');
                 break;
             case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Repository Autoclose Disabled');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Untracked');
                 break;
             case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE:
                 $icon = 'fa-times bluegrey';
                 $tip = pht('Branch Autoclose Disabled');
                 break;
             case null:
                 $icon = 'fa-check bluegrey';
                 $tip = pht('Autoclose Enabled');
                 break;
             default:
                 $icon = 'fa-question';
                 $tip = pht('Status Unknown');
                 break;
         }
         $status_icon = id(new PHUIIconView())->setIcon($icon)->addSigil('has-tooltip')->setHref($doc_href)->setMetadata(array('tip' => $tip, 'size' => 200));
         $fields = $branch->getRawFields();
         $closed = idx($fields, 'closed');
         if ($closed) {
             $status = pht('Closed');
         } else {
             $status = pht('Open');
         }
         $rows[] = array($this->linkBranchHistory($branch->getShortName()), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()), self::linkCommit($drequest->getRepository(), $branch->getCommitIdentifier()), $build_status, $status, AphrontTableView::renderSingleDisplayLine($details), $status_icon, $datetime);
         if ($branch->getShortName() == $current_branch) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array(null, pht('Branch'), pht('Head'), null, pht('State'), pht('Details'), null, pht('Committed')));
     $view->setColumnClasses(array('', 'pri', '', 'icon', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array(true, true, true, $have_builds, $can_close_branches));
     $view->setRowClasses($rowc);
     return $view->render();
 }
 public function render()
 {
     $request = $this->getDiffusionRequest();
     $repository = $request->getRepository();
     $base_path = trim($request->getPath(), '/');
     if ($base_path) {
         $base_path = $base_path . '/';
     }
     $need_pull = array();
     $rows = array();
     $show_edit = false;
     foreach ($this->paths as $path) {
         $dir_slash = null;
         $file_type = $path->getFileType();
         if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
             $browse_text = $path->getPath() . '/';
             $dir_slash = '/';
             $browse_link = '<strong>' . $this->linkBrowse($base_path . $path->getPath() . $dir_slash, array('html' => $this->renderPathIcon('dir', $browse_text))) . '</strong>';
         } else {
             if ($file_type == DifferentialChangeType::FILE_SUBMODULE) {
                 $browse_text = $path->getPath() . '/';
                 $browse_link = '<strong>' . $this->linkExternal($path->getHash(), $path->getExternalURI(), $this->renderPathIcon('ext', $browse_text)) . '</strong>';
             } else {
                 if ($file_type == DifferentialChangeType::FILE_SYMLINK) {
                     $type = 'link';
                 } else {
                     $type = 'file';
                 }
                 $browse_text = $path->getPath();
                 $browse_link = $this->linkBrowse($base_path . $path->getPath(), array('html' => $this->renderPathIcon($type, $browse_text)));
             }
         }
         $commit = $path->getLastModifiedCommit();
         if ($commit) {
             $dict = self::renderLastModifiedColumns($repository, $this->handles, $commit, $path->getLastCommitData());
         } else {
             $dict = array('commit' => celerity_generate_unique_node_id(), 'date' => celerity_generate_unique_node_id(), 'time' => celerity_generate_unique_node_id(), 'author' => celerity_generate_unique_node_id(), 'details' => celerity_generate_unique_node_id());
             $uri = (string) $request->generateURI(array('action' => 'lastmodified', 'path' => $base_path . $path->getPath()));
             $need_pull[$uri] = $dict;
             foreach ($dict as $k => $uniq) {
                 $dict[$k] = '<span id="' . $uniq . '"></span>';
             }
         }
         $editor_button = '';
         if ($this->user) {
             $editor_link = $this->user->loadEditorLink($base_path . $path->getPath(), 1, $request->getRepository()->getCallsign());
             if ($editor_link) {
                 $show_edit = true;
                 $editor_button = phutil_render_tag('a', array('href' => $editor_link), 'Edit');
             }
         }
         $rows[] = array($this->linkHistory($base_path . $path->getPath() . $dir_slash), $editor_button, $browse_link, $dict['commit'], $dict['date'], $dict['time'], $dict['author'], $dict['details']);
     }
     if ($need_pull) {
         Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('History', 'Edit', 'Path', 'Modified', 'Date', 'Time', 'Author/Committer', 'Details'));
     $view->setColumnClasses(array('', '', '', '', '', 'right', '', 'wide'));
     $view->setColumnVisibility(array(true, $show_edit, true, true, true, true, true, true));
     return $view->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $editable = $this->getAccountEditable();
     $uri = $request->getRequestURI();
     $uri->setQueryParams(array());
     if ($editable) {
         $new = $request->getStr('new');
         if ($new) {
             return $this->returnNewAddressResponse($uri, $new);
         }
         $delete = $request->getInt('delete');
         if ($delete) {
             return $this->returnDeleteAddressResponse($uri, $delete);
         }
     }
     $verify = $request->getInt('verify');
     if ($verify) {
         return $this->returnVerifyAddressResponse($uri, $verify);
     }
     $primary = $request->getInt('primary');
     if ($primary) {
         return $this->returnPrimaryAddressResponse($uri, $primary);
     }
     $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
     $rowc = array();
     $rows = array();
     foreach ($emails as $email) {
         $button_verify = javelin_render_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('verify', $email->getID()), 'sigil' => 'workflow'), 'Verify');
         $button_make_primary = javelin_render_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('primary', $email->getID()), 'sigil' => 'workflow'), 'Make Primary');
         $button_remove = javelin_render_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), 'Remove');
         $button_primary = phutil_render_tag('a', array('class' => 'button small disabled'), 'Primary');
         if (!$email->getIsVerified()) {
             $action = $button_verify;
         } else {
             if ($email->getIsPrimary()) {
                 $action = $button_primary;
             } else {
                 $action = $button_make_primary;
             }
         }
         if ($email->getIsPrimary()) {
             $remove = $button_primary;
             $rowc[] = 'highlighted';
         } else {
             $remove = $button_remove;
             $rowc[] = null;
         }
         $rows[] = array(phutil_escape_html($email->getAddress()), $action, $remove);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Email', 'Status', 'Remove'));
     $table->setColumnClasses(array('wide', 'action', 'action'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array(true, true, $editable));
     $view = new AphrontPanelView();
     if ($editable) {
         $view->addButton(javelin_render_tag('a', array('href' => $uri->alter('new', 'true'), 'class' => 'green button', 'sigil' => 'workflow'), 'Add New Address'));
     }
     $view->setHeader('Email Addresses');
     $view->appendChild($table);
     return $view;
 }