public function render()
 {
     $user = $this->user;
     if (!$user) {
         throw new Exception("Call setUser() before render()!");
     }
     $rows = array();
     foreach ($this->revisions as $revision) {
         $status = $revision->getStatus();
         $status = DifferentialRevisionStatus::getNameForRevisionStatus($status);
         $reviewer_phids = $revision->getReviewers();
         if ($reviewer_phids) {
             $first = reset($reviewer_phids);
             if (count($reviewer_phids) > 1) {
                 $suffix = ' (+' . (count($reviewer_phids) - 1) . ')';
             } else {
                 $suffix = null;
             }
             $reviewers = $this->handles[$first]->renderLink() . $suffix;
         } else {
             $reviewers = '<em>None</em>';
         }
         $link = phutil_render_tag('a', array('href' => '/D' . $revision->getID()), phutil_escape_html($revision->getTitle()));
         $rows[] = array('D' . $revision->getID(), $link, phutil_escape_html($status), number_format($revision->getLineCount()), $this->handles[$revision->getAuthorPHID()]->renderLink(), $reviewers, phabricator_datetime($revision->getDateModified(), $user), phabricator_date($revision->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Revision', 'Status', 'Lines', 'Author', 'Reviewers', 'Updated', 'Created'));
     $table->setColumnClasses(array(null, 'wide pri', null, 'n', null, null, 'right', 'right'));
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $current_branch = $drequest->getBranch();
     $rows = array();
     $rowc = array();
     foreach ($this->branches as $branch) {
         $commit = idx($this->commits, $branch->getHeadCommitIdentifier());
         if ($commit) {
             $details = $commit->getCommitData()->getCommitMessage();
             $details = idx(explode("\n", $details), 0);
             $details = substr($details, 0, 80);
             $datetime = phabricator_datetime($commit->getEpoch(), $this->user);
         } else {
             $datetime = null;
             $details = null;
         }
         $rows[] = array(phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getName()))), 'History'), phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getName()))), phutil_escape_html($branch->getName())), self::linkCommit($drequest->getRepository(), $branch->getHeadCommitIdentifier()), $datetime, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($details)));
         if ($branch->getName() == $current_branch) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('History', 'Branch', 'Head', 'Modified', 'Details'));
     $view->setColumnClasses(array('', 'pri', '', '', 'wide'));
     $view->setRowClasses($rowc);
     return $view->render();
 }
 private function renderTransactionInfo()
 {
     $info = array();
     if ($this->contentSource) {
         $content_source = new PhabricatorContentSourceView();
         $content_source->setContentSource($this->contentSource);
         $content_source->setUser($this->user);
         $source = $content_source->render();
         if ($source) {
             $info[] = $source;
         }
     }
     if ($this->isPreview) {
         $info[] = 'PREVIEW';
     } else {
         if ($this->epoch) {
             $info[] = phabricator_datetime($this->epoch, $this->user);
         }
     }
     if ($this->anchorName) {
         Javelin::initBehavior('phabricator-watch-anchor');
         $anchor = id(new PhabricatorAnchorView())->setAnchorName($this->anchorName)->render();
         $info[] = hsprintf('%s%s', $anchor, phutil_tag('a', array('href' => '#' . $this->anchorName), $this->anchorText));
     }
     $info = phutil_implode_html(" · ", $info);
     return phutil_tag('span', array('class' => 'phabricator-transaction-info'), $info);
 }
 private function buildPropertyList(HarbormasterBuildStep $step, PhabricatorCustomFieldList $field_list)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($step);
     try {
         $implementation = $step->getStepImplementation();
     } catch (Exception $ex) {
         $implementation = null;
     }
     if ($implementation) {
         $type = $implementation->getName();
     } else {
         $type = phutil_tag('em', array(), pht('Invalid Implementation ("%s")!', $step->getClassName()));
     }
     $view->addProperty(pht('Step Type'), $type);
     $view->addProperty(pht('Created'), phabricator_datetime($step->getDateCreated(), $viewer));
     $field_list->appendFieldsToPropertyList($step, $viewer, $view);
     $view->invokeWillRenderEvent();
     $description = $step->getDescription();
     if (strlen($description)) {
         $view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent(new PHUIRemarkupView($viewer, $description));
     }
     return $view;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('resource');
     $pager = new AphrontPagerView();
     $pager->setURI(new PhutilURI('/drydock/resource/'), 'page');
     $data = id(new DrydockResource())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = $pager->sliceResults($data);
     $phids = mpull($data, 'getOwnerPHID');
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($data as $resource) {
         $rows[] = array($resource->getID(), $resource->getOwnerPHID() ? $handles[$resource->getOwnerPHID()]->renderLink() : null, phutil_escape_html($resource->getType()), DrydockResourceStatus::getNameForStatus($resource->getStatus()), phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), phabricator_datetime($resource->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Owner', 'Type', 'Status', 'Resource', 'Created'));
     $table->setColumnClasses(array('', '', '', '', 'pri wide', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Resources');
     $panel->addButton(phutil_render_tag('a', array('href' => '/drydock/resource/allocate/', 'class' => 'green button'), 'Allocate Resource'));
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Resources'));
 }
 private function buildMessageProperties(PhabricatorMetaMTAMail $mail)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($mail);
     if ($mail->getFrom()) {
         $from_str = $viewer->renderHandle($mail->getFrom());
     } else {
         $from_str = pht('Sent by Phabricator');
     }
     $properties->addProperty(pht('From'), $from_str);
     if ($mail->getToPHIDs()) {
         $to_list = $viewer->renderHandleList($mail->getToPHIDs());
     } else {
         $to_list = pht('None');
     }
     $properties->addProperty(pht('To'), $to_list);
     if ($mail->getCcPHIDs()) {
         $cc_list = $viewer->renderHandleList($mail->getCcPHIDs());
     } else {
         $cc_list = pht('None');
     }
     $properties->addProperty(pht('Cc'), $cc_list);
     $properties->addProperty(pht('Sent'), phabricator_datetime($mail->getDateCreated(), $viewer));
     $properties->addSectionHeader(pht('Message'), PHUIPropertyListView::ICON_SUMMARY);
     if ($mail->hasSensitiveContent()) {
         $body = phutil_tag('em', array(), pht('The content of this mail is sensitive and it can not be ' . 'viewed from the web UI.'));
     } else {
         $body = phutil_tag('div', array('style' => 'white-space: pre-wrap'), $mail->getBody());
     }
     $properties->addTextContent($body);
     return $properties;
 }
 protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($pastes, 'PhabricatorPaste');
     $viewer = $this->requireViewer();
     $lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($pastes as $paste) {
         $created = phabricator_date($paste->getDateCreated(), $viewer);
         $author = $handles[$paste->getAuthorPHID()]->renderLink();
         $lines = phutil_split_lines($paste->getContent());
         $preview = id(new PhabricatorSourceCodeView())->setLimit(5)->setLines($lines)->setURI(new PhutilURI($paste->getURI()));
         $source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
         $created = phabricator_datetime($paste->getDateCreated(), $viewer);
         $line_count = count($lines);
         $line_count = pht('%s Line(s)', new PhutilNumber($line_count));
         $title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
         $item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
         $lang_name = $paste->getLanguage();
         if ($lang_name) {
             $lang_name = idx($lang_map, $lang_name, $lang_name);
             $item->addIcon('none', $lang_name);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No pastes found.'));
     return $result;
 }
 public function render()
 {
     $logs = $this->logs;
     $viewer = $this->getUser();
     $handles = $this->handles;
     // Figure out which repositories are editable. We only let you see remote
     // IPs if you have edit capability on a repository.
     $editable_repos = array();
     if ($logs) {
         $editable_repos = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withPHIDs(mpull($logs, 'getRepositoryPHID'))->execute();
         $editable_repos = mpull($editable_repos, null, 'getPHID');
     }
     $rows = array();
     foreach ($logs as $log) {
         $repository = $log->getRepository();
         // Reveal this if it's valid and the user can edit the repository.
         $remote_addr = '-';
         if (isset($editable_repos[$log->getRepositoryPHID()])) {
             $remote_long = $log->getPushEvent()->getRemoteAddress();
             if ($remote_long) {
                 $remote_addr = long2ip($remote_long);
             }
         }
         $event_id = $log->getPushEvent()->getID();
         $old_ref_link = null;
         if ($log->getRefOld() != DiffusionCommitHookEngine::EMPTY_HASH) {
             $old_ref_link = phutil_tag('a', array('href' => $repository->getCommitURI($log->getRefOld())), $log->getRefOldShort());
         }
         $rows[] = array(phutil_tag('a', array('href' => '/diffusion/pushlog/view/' . $event_id . '/'), $event_id), phutil_tag('a', array('href' => $repository->getURI()), $repository->getDisplayName()), $handles[$log->getPusherPHID()]->renderLink(), $remote_addr, $log->getPushEvent()->getRemoteProtocol(), $log->getRefType(), $log->getRefName(), $old_ref_link, phutil_tag('a', array('href' => $repository->getCommitURI($log->getRefNew())), $log->getRefNewShort()), $log->getChangeFlags(), $log->getPushEvent()->getRejectCode(), phabricator_datetime($log->getEpoch(), $viewer));
     }
     $table = id(new AphrontTableView($rows))->setHeaders(array(pht('Push'), pht('Repository'), pht('Pusher'), pht('From'), pht('Via'), pht('Type'), pht('Name'), pht('Old'), pht('New'), pht('Flags'), pht('Code'), pht('Date')))->setColumnClasses(array('', '', '', '', '', '', 'wide', 'n', 'n', 'date'));
     return $table;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('lease');
     $pager = new AphrontPagerView();
     $pager->setURI(new PhutilURI('/drydock/lease/'), 'page');
     $data = id(new DrydockLease())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = $pager->sliceResults($data);
     $phids = mpull($data, 'getOwnerPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $resource_ids = mpull($data, 'getResourceID');
     $resources = array();
     if ($resource_ids) {
         $resources = id(new DrydockResource())->loadAllWhere('id IN (%Ld)', $resource_ids);
     }
     $rows = array();
     foreach ($data as $lease) {
         $resource = idx($resources, $lease->getResourceID());
         $rows[] = array($lease->getID(), DrydockLeaseStatus::getNameForStatus($lease->getStatus()), $lease->getOwnerPHID() ? $handles[$lease->getOwnerPHID()]->renderLink() : null, $lease->getResourceID(), $resource ? phutil_escape_html($resource->getName()) : null, phabricator_datetime($lease->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Status', 'Owner', 'Resource ID', 'Resource', 'Created'));
     $table->setColumnClasses(array('', '', '', '', 'wide pri', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Leases');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Leases'));
 }
 public function render()
 {
     $list = new PHUIObjectItemListView();
     $list->setFlush(true);
     foreach ($this->edits as $edit) {
         $name = nonempty($edit->getRuleName(), 'Unknown Rule');
         $rule_name = phutil_tag('strong', array(), $name);
         switch ($edit->getAction()) {
             case 'create':
                 $details = pht("Created rule '%s'.", $rule_name);
                 break;
             case 'delete':
                 $details = pht("Deleted rule '%s'.", $rule_name);
                 break;
             case 'edit':
             default:
                 $details = pht("Edited rule '%s'.", $rule_name);
                 break;
         }
         $editor = $this->handles[$edit->getEditorPHID()]->renderLink();
         $date = phabricator_datetime($edit->getDateCreated(), $this->user);
         $item = id(new PHUIObjectItemView())->setObjectName(pht('Rule %d', $edit->getRuleID()))->setSubHead($details)->addIcon('none', $date)->addByLine(pht('Editor: %s', $editor));
         $list->addItem($item);
     }
     $list->setNoDataString(pht('No edits for rule.'));
     return $list;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $current_user = $request->getUser();
     $error = null;
     $phid = $this->getClientPHID();
     $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $phid);
     $title = 'View OAuth Client';
     // validate the client
     if (empty($client)) {
         $message = 'No client found with id ' . $phid . '.';
         return $this->buildStandardPageResponse($this->buildErrorView($message), array('title' => $title));
     }
     $panel = new AphrontPanelView();
     $panel->setHeader($title);
     $form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setValue($client->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($phid));
     if ($current_user->getPHID() == $client->getCreatorPHID()) {
         $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Secret')->setValue($client->getSecret()));
     }
     $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Redirect URI')->setValue($client->getRedirectURI()));
     $created = phabricator_datetime($client->getDateCreated(), $current_user);
     $updated = phabricator_datetime($client->getDateModified(), $current_user);
     $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated));
     $panel->appendChild($form);
     $admin_panel = null;
     if ($client->getCreatorPHID() == $current_user->getPHID()) {
         $edit_button = phutil_render_tag('a', array('href' => $client->getEditURI(), 'class' => 'grey button'), 'Edit OAuth Client');
         $panel->addButton($edit_button);
         $create_authorization_form = id(new AphrontFormView())->setUser($current_user)->addHiddenInput('action', 'testclientauthorization')->addHiddenInput('client_phid', $phid)->setAction('/oauthserver/test/')->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Scopeless Test Authorization'));
         $admin_panel = id(new AphrontPanelView())->setHeader('Admin Tools')->appendChild($create_authorization_form);
     }
     return $this->buildStandardPageResponse(array($error, $panel, $admin_panel), array('title' => $title));
 }
 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();
 }
 private function handleHovercardEvent($event)
 {
     $viewer = $event->getUser();
     $hovercard = $event->getValue('hovercard');
     $object_handle = $event->getValue('handle');
     $phid = $object_handle->getPHID();
     $rev = $event->getValue('object');
     if (!$rev instanceof DifferentialRevision) {
         return;
     }
     $rev->loadRelationships();
     $reviewer_phids = $rev->getReviewers();
     $e_task = DifferentialRevisionHasTaskEdgeType::EDGECONST;
     $edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs(array($phid))->withEdgeTypes(array($e_task));
     $edge_query->execute();
     $tasks = $edge_query->getDestinationPHIDs();
     $phids = array_merge(array($rev->getAuthorPHID()), $reviewer_phids, $tasks);
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     $hovercard->setTitle('D' . $rev->getID());
     $hovercard->setDetail($rev->getTitle());
     $hovercard->addField(pht('Author'), $handles[$rev->getAuthorPHID()]->renderLink());
     $hovercard->addField(pht('Date'), phabricator_datetime($rev->getDateModified(), $viewer));
     $hovercard->addField(pht('Reviewers'), implode_selected_handle_links(', ', $handles, $reviewer_phids));
     if ($tasks) {
         $hovercard->addField(pht('Task(s)', count($tasks)), implode_selected_handle_links(', ', $handles, $tasks));
     }
     if ($rev->getSummary()) {
         $hovercard->addField(pht('Summary'), id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(120)->truncateString($rev->getSummary()));
     }
     $hovercard->addTag(DifferentialRevisionDetailView::renderTagForRevision($rev));
     $event->setValue('hovercard', $hovercard);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $pager = new AphrontCursorPagerView();
     $pager->readFromRequest($request);
     $query = id(new PhluxVariableQuery())->setViewer($viewer);
     $vars = $query->executeWithCursorPager($pager);
     $view = new PHUIObjectItemListView();
     $view->setFlush(true);
     foreach ($vars as $var) {
         $key = $var->getVariableKey();
         $item = new PHUIObjectItemView();
         $item->setHeader($key);
         $item->setHref($this->getApplicationURI('/view/' . $key . '/'));
         $item->addIcon('none', phabricator_datetime($var->getDateModified(), $viewer));
         $view->addItem($item);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $box = id(new PHUIObjectBoxView())->setHeaderText('Variables')->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($view);
     $title = pht('Variable List');
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-copy');
     $crumbs->addTextCrumb($title, $this->getApplicationURI());
     $crumbs->setBorder(true);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($box, $pager));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
 public function processRequest()
 {
     $phid = $this->getAuthorizationPHID();
     $title = 'Edit OAuth Client Authorization';
     $request = $this->getRequest();
     $current_user = $request->getUser();
     $authorization = id(new PhabricatorOAuthClientAuthorization())->loadOneWhere('phid = %s', $phid);
     if (empty($authorization)) {
         return new Aphront404Response();
     }
     if ($authorization->getUserPHID() != $current_user->getPHID()) {
         $message = 'Access denied to client authorization with phid ' . $phid . '. ' . 'Only the user who authorized the client has permission to ' . 'edit the authorization.';
         return id(new Aphront403Response())->setForbiddenText($message);
     }
     if ($request->isFormPost()) {
         $scopes = PhabricatorOAuthServerScope::getScopesFromRequest($request);
         $authorization->setScope($scopes);
         $authorization->save();
         return id(new AphrontRedirectResponse())->setURI('/oauthserver/clientauthorization/?edited=' . $phid);
     }
     $client_phid = $authorization->getClientPHID();
     $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $client_phid);
     $created = phabricator_datetime($authorization->getDateCreated(), $current_user);
     $updated = phabricator_datetime($authorization->getDateModified(), $current_user);
     $panel = new AphrontPanelView();
     $delete_button = phutil_render_tag('a', array('href' => $authorization->getDeleteURI(), 'class' => 'grey button'), 'Delete OAuth Client Authorization');
     $panel->addButton($delete_button);
     $panel->setHeader($title);
     $form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormMarkupControl())->setLabel('Client')->setValue(phutil_render_tag('a', array('href' => $client->getViewURI()), phutil_escape_html($client->getName()))))->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated))->appendChild(PhabricatorOAuthServerScope::getCheckboxControl($authorization->getScope()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save OAuth Client Authorization')->addCancelButton('/oauthserver/clientauthorization/'));
     $panel->appendChild($form);
     return $this->buildStandardPageResponse($panel, array('title' => $title));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildSideNav('log');
     $query = new DrydockLogQuery();
     $resource_ids = $request->getStrList('resource');
     if ($resource_ids) {
         $query->withResourceIDs($resource_ids);
     }
     $lease_ids = $request->getStrList('lease');
     if ($lease_ids) {
         $query->withLeaseIDs($lease_ids);
     }
     $pager = new AphrontPagerView();
     $pager->setPageSize(500);
     $pager->setOffset($request->getInt('offset'));
     $pager->setURI($request->getRequestURI(), 'offset');
     $logs = $query->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($logs as $log) {
         $rows[] = array($log->getResourceID(), $log->getLeaseID(), phutil_escape_html($log->getMessage()), phabricator_datetime($log->getEpoch(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Resource', 'Lease', 'Message', 'Date'));
     $table->setColumnClasses(array('', '', 'wide', ''));
     $panel = new AphrontPanelView();
     $panel->setHeader('Drydock Logs');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Logs'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     // Load all projects with "Sprint" in the name.
     $projects = id(new PhabricatorProjectQuery())->setViewer($viewer)->withDatasourceQuery('sprint')->execute();
     $rows = array();
     foreach ($projects as $project) {
         // We need the custom fields so we can pull out the start and end date
         // TODO: query in a loop is bad
         $field_list = PhabricatorCustomField::getObjectFields($project, PhabricatorCustomField::ROLE_EDIT);
         $field_list->setViewer($viewer);
         $field_list->readFieldsFromStorage($project);
         $aux_fields = $field_list->getFields();
         $start = idx($aux_fields, 'isdc:sprint:startdate')->getProxy()->getFieldValue();
         $end = idx($aux_fields, 'isdc:sprint:enddate')->getProxy()->getFieldValue();
         $rows[] = array('project' => phutil_tag('a', array('href' => '/burndown/view/' . $project->getId(), 'style' => 'font-weight:bold'), $project->getName()), 'start' => phabricator_datetime($start, $viewer), 'end' => phabricator_datetime($end, $viewer));
     }
     $projects_table = id(new AphrontTableView($rows))->setHeaders(array('Project/Sprint name', 'Start Date', 'End Date'))->setColumnClasses(array('wide', 'date', 'date'));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Burndown List'));
     $help = id(new PHUIBoxView())->appendChild(phutil_tag('p', array(), "To have a project show up in this list, make sure it's name includes" . "\"sprint\" and then edit it to set the start and end date."))->addMargin(PHUI::MARGIN_LARGE);
     $box = id(new PHUIBoxView())->appendChild($projects_table)->addMargin(PHUI::MARGIN_LARGE);
     return $this->buildApplicationPage(array($crumbs, $help, $box), array('title' => array(pht('Burndown List')), 'device' => true));
 }
 private function buildPropertyView(NuanceItem $item)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer);
     $properties->addProperty(pht('Date Created'), phabricator_datetime($item->getDateCreated(), $viewer));
     $requestor_phid = $item->getRequestorPHID();
     if ($requestor_phid) {
         $requestor_view = $viewer->renderHandle($requestor_phid);
     } else {
         $requestor_view = phutil_tag('em', array(), pht('None'));
     }
     $properties->addProperty(pht('Requestor'), $requestor_view);
     $properties->addProperty(pht('Source'), $viewer->renderHandle($item->getSourcePHID()));
     $queue_phid = $item->getQueuePHID();
     if ($queue_phid) {
         $queue_view = $viewer->renderHandle($queue_phid);
     } else {
         $queue_view = phutil_tag('em', array(), pht('None'));
     }
     $properties->addProperty(pht('Queue'), $queue_view);
     $source = $item->getSource();
     $definition = $source->getDefinition();
     $definition->renderItemEditProperties($viewer, $item, $properties);
     return $properties;
 }
 public function getTitle()
 {
     $author_phid = $this->getAuthorPHID();
     $object_phid = $this->getObjectPHID();
     $old = $this->getOldValue();
     $new = $this->getNewValue();
     $type = $this->getTransactionType();
     switch ($type) {
         case self::TYPE_TITLE:
             if ($old === null) {
                 return pht('%s created this countdown.', $this->renderHandleLink($author_phid));
             } else {
                 return pht('%s renamed this countdown from "%s" to "%s".', $this->renderHandleLink($author_phid), $old, $new);
             }
             break;
         case self::TYPE_DESCRIPTION:
             if ($old === null) {
                 return pht('%s set the description of this countdown.', $this->renderHandleLink($author_phid));
             } else {
                 return pht('%s edited the description of this countdown.', $this->renderHandleLink($author_phid));
             }
             break;
         case self::TYPE_EPOCH:
             if ($old === null) {
                 return pht('%s set this countdown to end on %s.', $this->renderHandleLink($author_phid), phabricator_datetime($new, $this->getViewer()));
             } else {
                 if ($old != $new) {
                     return pht('%s updated this countdown to end on %s.', $this->renderHandleLink($author_phid), phabricator_datetime($new, $this->getViewer()));
                 }
             }
             break;
     }
     return parent::getTitle();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $timers = id(new PhabricatorTimer())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $timers = $pager->sliceResults($timers);
     $phids = mpull($timers, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     foreach ($timers as $timer) {
         $edit_button = null;
         $delete_button = null;
         if ($user->getIsAdmin() || $user->getPHID() == $timer->getAuthorPHID()) {
             $edit_button = phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/countdown/edit/' . $timer->getID() . '/'), 'Edit');
             $delete_button = javelin_render_tag('a', array('class' => 'small button grey', 'href' => '/countdown/delete/' . $timer->getID() . '/', 'sigil' => 'workflow'), 'Delete');
         }
         $rows[] = array(phutil_escape_html($timer->getID()), $handles[$timer->getAuthorPHID()]->renderLink(), phutil_render_tag('a', array('href' => '/countdown/' . $timer->getID() . '/'), phutil_escape_html($timer->getTitle())), phabricator_datetime($timer->getDatepoint(), $user), $edit_button, $delete_button);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Author', 'Title', 'End Date', '', ''));
     $table->setColumnClasses(array(null, null, 'wide pri', null, 'action', 'action'));
     $panel = id(new AphrontPanelView())->appendChild($table)->setHeader('Timers')->setCreateButton('Create Timer', '/countdown/edit/')->appendChild($pager);
     return $this->buildStandardPageResponse($panel, array('title' => 'Countdown'));
 }
 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;
 }
 protected function renderResultList(array $documents, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($documents, 'PhrictionDocument');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($documents as $document) {
         $content = $document->getContent();
         $slug = $document->getSlug();
         $author_phid = $content->getAuthorPHID();
         $slug_uri = PhrictionDocument::getSlugURI($slug);
         $byline = pht('Edited by %s', $handles[$author_phid]->renderLink());
         $updated = phabricator_datetime($content->getDateCreated(), $viewer);
         $item = id(new PHUIObjectItemView())->setHeader($content->getTitle())->setHref($slug_uri)->addByline($byline)->addIcon('none', $updated);
         $item->addAttribute($slug_uri);
         switch ($document->getStatus()) {
             case PhrictionDocumentStatus::STATUS_DELETED:
                 $item->setDisabled(true);
                 $item->addIcon('delete', pht('Deleted'));
                 break;
             case PhrictionDocumentStatus::STATUS_MOVED:
                 $item->setDisabled(true);
                 $item->addIcon('arrow-right', pht('Moved Away'));
                 break;
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No documents found.'));
     return $result;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $timer = id(new PhabricatorTimer())->load($this->id);
     if (!$timer) {
         return new Aphront404Response();
     }
     require_celerity_resource('phabricator-countdown-css');
     $chrome_visible = $request->getBool('chrome', true);
     $chrome_new = $chrome_visible ? false : null;
     $chrome_link = phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('chrome', $chrome_new), 'class' => 'phabricator-timer-chrome-link'), $chrome_visible ? 'Disable Chrome' : 'Enable Chrome');
     $content = '<div class="phabricator-timer">
     <h1 class="phabricator-timer-header">' . phutil_escape_html($timer->getTitle()) . ' &middot; ' . phabricator_datetime($timer->getDatePoint(), $user) . '</h1>
     <div class="phabricator-timer-pane">
       <table class="phabricator-timer-table">
         <tr>
           <th>Days</th>
           <th>Hours</th>
           <th>Minutes</th>
           <th>Seconds</th>
         </tr>
         <tr>
           <td id="phabricator-timer-days"></td>
           <td id="phabricator-timer-hours"></td>
           <td id="phabricator-timer-minutes"></td>
           <td id="phabricator-timer-seconds"></td>
       </table>
     </div>' . $chrome_link . '</div>';
     Javelin::initBehavior('countdown-timer', array('timestamp' => $timer->getDatepoint()));
     $panel = $content;
     return $this->buildStandardPageResponse($panel, array('title' => 'Countdown: ' . $timer->getTitle(), 'chrome' => $chrome_visible));
 }
 private function buildPropertyListView(DrydockResource $resource, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setActionList($actions);
     $status = $resource->getStatus();
     $status = DrydockResourceStatus::getNameForStatus($status);
     $view->addProperty(pht('Status'), $status);
     $until = $resource->getUntil();
     if ($until) {
         $until_display = phabricator_datetime($until, $viewer);
     } else {
         $until_display = phutil_tag('em', array(), pht('Never'));
     }
     $view->addProperty(pht('Expires'), $until_display);
     $view->addProperty(pht('Resource Type'), $resource->getType());
     $view->addProperty(pht('Blueprint'), $viewer->renderHandle($resource->getBlueprintPHID()));
     $attributes = $resource->getAttributes();
     if ($attributes) {
         $view->addSectionHeader(pht('Attributes'), 'fa-list-ul');
         foreach ($attributes as $key => $value) {
             $view->addProperty($key, $value);
         }
     }
     return $view;
 }
 protected function renderResultList(array $polls, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($polls, 'PhabricatorSlowvotePoll');
     $viewer = $this->requireViewer();
     $list = id(new PHUIObjectItemListView())->setUser($viewer);
     $phids = mpull($polls, 'getAuthorPHID');
     foreach ($polls as $poll) {
         $date_created = phabricator_datetime($poll->getDateCreated(), $viewer);
         if ($poll->getAuthorPHID()) {
             $author = $handles[$poll->getAuthorPHID()]->renderLink();
         } else {
             $author = null;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($poll)->setObjectName('V' . $poll->getID())->setHeader($poll->getQuestion())->setHref('/V' . $poll->getID())->addIcon('none', $date_created);
         if ($poll->getIsClosed()) {
             $item->setStatusIcon('fa-ban grey');
             $item->setDisabled(true);
         } else {
             $item->setStatusIcon('fa-bar-chart');
         }
         $description = $poll->getDescription();
         if (strlen($description)) {
             $item->addAttribute(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(120)->truncateString($poll->getDescription()));
         }
         if ($author) {
             $item->addByline(pht('Author: %s', $author));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No polls found.'));
     return $result;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $log = id(new PhabricatorDaemonLog())->load($this->id);
     if (!$log) {
         return new Aphront404Response();
     }
     $events = id(new PhabricatorDaemonLogEvent())->loadAllWhere('logID = %d ORDER BY id DESC LIMIT 1000', $log->getID());
     $content = array();
     $argv = $log->getArgv();
     $argv = implode("\n", $argv);
     $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('Daemon')->setValue($log->getDaemon()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Host')->setValue($log->getHost()))->appendChild(id(new AphrontFormStaticControl())->setLabel('PID')->setValue($log->getPID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Started')->setValue(phabricator_datetime($log->getDateCreated(), $user)))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Argv')->setValue($argv));
     $panel = new AphrontPanelView();
     $panel->setHeader('Daemon Details');
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $panel->appendChild($form);
     $content[] = $panel;
     $event_view = new PhabricatorDaemonLogEventsView();
     $event_view->setUser($user);
     $event_view->setEvents($events);
     $log_panel = new AphrontPanelView();
     $log_panel->setHeader('Daemon Logs');
     $log_panel->appendChild($event_view);
     $content[] = $log_panel;
     return $this->buildStandardPageResponse($content, array('title' => 'Daemon Log'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $action_label = 'Create Timer';
     if ($this->id) {
         $timer = id(new PhabricatorTimer())->load($this->id);
         // If no timer is found
         if (!$timer) {
             return new Aphront404Response();
         }
         if ($timer->getAuthorPHID() != $user->getPHID() && $user->getIsAdmin() == false) {
             return new Aphront403Response();
         }
         $action_label = 'Update Timer';
     } else {
         $timer = new PhabricatorTimer();
         $timer->setDatePoint(time());
     }
     $error_view = null;
     $e_text = null;
     if ($request->isFormPost()) {
         $errors = array();
         $title = $request->getStr('title');
         $datepoint = $request->getStr('datepoint');
         $e_text = null;
         if (!strlen($title)) {
             $e_text = 'Required';
             $errors[] = 'You must give it a name.';
         }
         // If the user types something like "5 PM", convert it to a timestamp
         // using their local time, not the server time.
         $timezone = new DateTimeZone($user->getTimezoneIdentifier());
         try {
             $date = new DateTime($datepoint, $timezone);
             $timestamp = $date->format('U');
         } catch (Exception $e) {
             $errors[] = 'You entered an incorrect date. You can enter date like' . ' \'2011-06-26 13:33:37\' to create an event at' . ' 13:33:37 on the 26th of June 2011.';
             $timestamp = null;
         }
         $timer->setTitle($title);
         $timer->setDatePoint($timestamp);
         if (!count($errors)) {
             $timer->setAuthorPHID($user->getPHID());
             $timer->save();
             return id(new AphrontRedirectResponse())->setURI('/countdown/' . $timer->getID() . '/');
         } else {
             $error_view = id(new AphrontErrorView())->setErrors($errors)->setTitle('It\'s not The Final Countdown (du nu nuuu nun)' . ' until you fix these problem');
         }
     }
     if ($timer->getDatePoint()) {
         $display_datepoint = phabricator_datetime($timer->getDatePoint(), $user);
     } else {
         $display_datepoint = $request->getStr('datepoint');
     }
     $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendChild(id(new AphrontFormTextControl())->setLabel('Title')->setValue($timer->getTitle())->setName('title'))->appendChild(id(new AphrontFormTextControl())->setLabel('End date')->setValue($display_datepoint)->setName('datepoint')->setCaption('Examples: ' . '<tt>2011-12-25</tt> or ' . '<tt>3 hours</tt> or ' . '<tt>June 8 2011, 5 PM</tt>.'))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/countdown/')->setValue($action_label));
     $panel = id(new AphrontPanelView())->setWidth(AphrontPanelView::WIDTH_FORM)->setHeader($action_label)->appendChild($form);
     return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Countdown'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $epoch_control = id(new AphrontFormDateControl())->setUser($user)->setName('epoch')->setLabel(pht('End Date'))->setInitialTime(AphrontFormDateControl::TIME_END_OF_DAY);
     if ($this->id) {
         $page_title = pht('Edit Countdown');
         $countdown = id(new PhabricatorCountdownQuery())->setViewer($user)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$countdown) {
             return new Aphront404Response();
         }
     } else {
         $page_title = pht('Create Countdown');
         $countdown = PhabricatorCountdown::initializeNewCountdown($user);
     }
     $epoch_control->setValue($countdown->getEpoch());
     $e_text = true;
     $errors = array();
     if ($request->isFormPost()) {
         $title = $request->getStr('title');
         $epoch = $epoch_control->readValueFromRequest($request);
         $view_policy = $request->getStr('viewPolicy');
         $e_text = null;
         if (!strlen($title)) {
             $e_text = pht('Required');
             $errors[] = pht('You must give the countdown a name.');
         }
         if (!$epoch) {
             $errors[] = pht('You must give the countdown a valid end date.');
         }
         if (!count($errors)) {
             $countdown->setTitle($title);
             $countdown->setEpoch($epoch);
             $countdown->setViewPolicy($view_policy);
             $countdown->save();
             return id(new AphrontRedirectResponse())->setURI('/countdown/' . $countdown->getID() . '/');
         }
     }
     if ($countdown->getEpoch()) {
         $display_epoch = phabricator_datetime($countdown->getEpoch(), $user);
     } else {
         $display_epoch = $request->getStr('epoch');
     }
     $crumbs = $this->buildApplicationCrumbs();
     $cancel_uri = '/countdown/';
     if ($countdown->getID()) {
         $cancel_uri = '/countdown/' . $countdown->getID() . '/';
         $crumbs->addTextCrumb('C' . $countdown->getID(), $cancel_uri);
         $crumbs->addTextCrumb(pht('Edit'));
         $submit_label = pht('Save Changes');
     } else {
         $crumbs->addTextCrumb(pht('Create Countdown'));
         $submit_label = pht('Create Countdown');
     }
     $policies = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($countdown)->execute();
     $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Title'))->setValue($countdown->getTitle())->setName('title')->setError($e_text))->appendChild($epoch_control)->appendChild(id(new AphrontFormPolicyControl())->setUser($user)->setName('viewPolicy')->setPolicyObject($countdown)->setPolicies($policies)->setCapability(PhabricatorPolicyCapability::CAN_VIEW))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($submit_label));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setFormErrors($errors)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $page_title));
 }
 private function buildPropertySection(PhabricatorAuthSSHKey $ssh_key)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer);
     $properties->addProperty(pht('SSH Key Type'), $ssh_key->getKeyType());
     $properties->addProperty(pht('Created'), phabricator_datetime($ssh_key->getDateCreated(), $viewer));
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($properties);
 }
Exemple #30
0
 public function getLabel(PhabricatorUser $viewer)
 {
     // this is generated at the time the item is created based on
     // the configuration from the item source. It is typically
     // something like 'Twitter'.
     $source_label = $this->getSourceLabel();
     return pht('Item via %s @ %s.', $source_label, phabricator_datetime($this->getDateCreated(), $viewer));
 }