public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $macro_table = new PhabricatorFileImageMacro(); $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize()); // Get an exact count since the size here is reasonably going to be a few // thousand at most in any reasonable case. $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName()); $count = $count['N']; $pager->setCount($count); $pager->setURI($request->getRequestURI(), 'page'); $rows = array(); foreach ($macros as $macro) { $src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID()); $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), phutil_render_tag('a', array('href' => $src, 'target' => '_blank'), phutil_render_tag('img', array('src' => $src))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Image', '')); $table->setColumnClasses(array('pri', 'wide thumb', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Image Macros'); $panel->setCreateButton('New Image Macro', '/file/macro/edit/'); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Image Macros', 'tab' => 'macros')); }
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')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $views = array(self::VIEW_ALL => 'All Slowvotes', self::VIEW_CREATED => 'Created', self::VIEW_VOTED => 'Voted In'); $view = isset($views[$this->view]) ? $this->view : self::VIEW_ALL; $side_nav = $this->renderSideNav($views, $view); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pager->setURI($request->getRequestURI(), 'page'); $polls = $this->loadPolls($pager, $view); $phids = mpull($polls, 'getAuthorPHID'); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); foreach ($polls as $poll) { $rows[] = array('V' . $poll->getID(), phutil_render_tag('a', array('href' => '/V' . $poll->getID()), phutil_escape_html($poll->getQuestion())), $handles[$poll->getAuthorPHID()]->renderLink(), phabricator_date($poll->getDateCreated(), $user), phabricator_time($poll->getDateCreated(), $user)); } $table = new AphrontTableView($rows); $table->setColumnClasses(array('', 'pri wide', '', '', 'right')); $table->setHeaders(array('ID', 'Poll', 'Author', 'Date', 'Time')); $panel = new AphrontPanelView(); $panel->setHeader($this->getTableHeader($view)); $panel->setCreateButton('Create Slowvote', '/vote/create/'); $panel->appendChild($table); $panel->appendChild($pager); $side_nav->appendChild($panel); return $this->buildStandardPageResponse($side_nav, array('title' => 'Slowvotes')); }
public function processRequest() { $drequest = $this->diffusionRequest; $request = $this->getRequest(); $page_size = $request->getInt('pagesize', 100); $offset = $request->getInt('page', 0); $history_query = DiffusionHistoryQuery::newFromDiffusionRequest($drequest); $history_query->setOffset($offset); $history_query->setLimit($page_size + 1); if (!$request->getBool('copies')) { $history_query->needDirectChanges(true); $history_query->needChildChanges(true); } $history = $history_query->loadHistory(); $phids = array(); foreach ($history as $item) { $data = $item->getCommitData(); if ($data) { if ($data->getCommitDetail('authorPHID')) { $phids[$data->getCommitDetail('authorPHID')] = true; } } } $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $pager = new AphrontPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); if (count($history) == $page_size + 1) { array_pop($history); $pager->setHasMorePages(true); } else { $pager->setHasMorePages(false); } $pager->setURI($request->getRequestURI(), 'page'); $content = array(); $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history')); if ($request->getBool('copies')) { $button_title = 'Hide Copies/Branches'; } else { $button_title = 'Show Copies/Branches'; } $button_uri = $request->getRequestURI()->alter('copies', !$request->getBool('copies')); $button = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $button_uri), phutil_escape_html($button_title)); $history_table = new DiffusionHistoryTableView(); $history_table->setDiffusionRequest($drequest); $history_table->setHandles($handles); $history_table->setHistory($history); $history_panel = new AphrontPanelView(); $history_panel->setHeader('History'); $history_panel->addButton($button); $history_panel->appendChild($history_table); $history_panel->appendChild($pager); $content[] = $history_panel; // TODO: Sometimes we do have a change view, we need to look at the most // recent history entry to figure it out. $nav = $this->buildSideNav('history', false); $nav->appendChild($content); return $this->buildStandardPageResponse($nav, array('title' => 'history')); }
public function processRequest() { $request = $this->getRequest(); $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $calls = $call_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $calls = $pager->sliceResults($calls); $pager->setURI(new PhutilURI('/conduit/log/'), 'page'); $pager->setEnableKeyboardShortcuts(true); $min = $pager->getOffset() + 1; $max = $min + count($calls) - 1; $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Method Calls (' . $min . '-' . $max . ')'); $panel->appendChild($table); $panel->appendChild($pager); $this->setShowSideNav(false); return $this->buildStandardPageResponse($panel, array('title' => 'Conduit Logs')); }
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 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(); $user = $request->getUser(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pager->setURI($request->getRequestURI(), 'page'); $mails = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $mails = $pager->sliceResults($mails); $phids = array_merge(mpull($mails, 'getAuthorPHID'), mpull($mails, 'getRelatedPHID')); $phids = array_unique(array_filter($phids)); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); foreach ($mails as $mail) { $rows[] = array($mail->getID(), phabricator_date($mail->getDateCreated(), $user), phabricator_time($mail->getDateCreated(), $user), $mail->getAuthorPHID() ? $handles[$mail->getAuthorPHID()]->renderLink() : '-', $mail->getRelatedPHID() ? $handles[$mail->getRelatedPHID()]->renderLink() : '-', phutil_escape_html($mail->getMessage())); } $table = new AphrontTableView($rows); $table->setHeaders(array('ID', 'Date', 'Time', 'Author', 'Object', 'Message')); $table->setColumnClasses(array(null, null, 'right', null, null, 'wide')); $panel = new AphrontPanelView(); $panel->setHeader('Received Mail'); $panel->appendChild($table); $panel->appendChild($pager); $nav = $this->buildSideNavView(); $nav->selectFilter('received'); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => 'Received Mail')); }
public function processRequest(AphrontRequest $request) { $user = $request->getUser(); $ldap_info = id(new PhabricatorUserLDAPInfo())->loadOneWhere('userID = %d', $user->getID()); $forms = array(); if (!$ldap_info) { $unlink = 'Link LDAP Account'; $unlink_form = new AphrontFormView(); $unlink_form->setUser($user)->setAction('/ldap/login/')->appendChild('<p class="aphront-form-instructions">There is currently no ' . 'LDAP account linked to your Phabricator account. You can link an ' . 'account, which will allow you to use it to log into Phabricator</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('LDAP username')->setName('username'))->appendChild(id(new AphrontFormPasswordControl())->setLabel('Password')->setName('password'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Link LDAP Account »")); $forms['Link Account'] = $unlink_form; } else { $unlink = 'Unlink LDAP Account'; $unlink_form = new AphrontFormView(); $unlink_form->setUser($user)->appendChild('<p class="aphront-form-instructions">You may unlink this account ' . 'from your LDAP account. This will prevent you from logging in with ' . 'your LDAP credentials.</p>')->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/ldap/unlink/', $unlink)); $forms['Unlink Account'] = $unlink_form; } $panel = new AphrontPanelView(); $panel->setHeader('LDAP Account Settings'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); foreach ($forms as $name => $form) { if ($name) { $panel->appendChild('<br /><h1>' . $name . '</h1><br />'); } $panel->appendChild($form); } return array($panel); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $offset = $request->getInt('offset', 0); $pager = new AphrontPagerView(); $pager->setPageSize(250); $pager->setOffset($offset); $pager->setURI($request->getRequestURI(), 'offset'); $list = new PhabricatorMetaMTAMailingList(); $conn_r = $list->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT * FROM %T ORDER BY name ASC LIMIT %d, %d', $list->getTableName(), $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $lists = $list->loadAllFromArray($data); $rows = array(); foreach ($lists as $list) { $rows[] = array(phutil_escape_html($list->getName()), phutil_escape_html($list->getEmail()), phutil_render_tag('a', array('class' => 'button grey small', 'href' => $this->getApplicationURI('/edit/' . $list->getID() . '/')), 'Edit')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Email', '')); $table->setColumnClasses(array(null, 'wide', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Mailing Lists'); $panel->setCreateButton('Add New List', $this->getApplicationURI('/edit/')); $panel->appendChild($pager); return $this->buildApplicationPage($panel, array('title' => 'Mailing Lists')); }
public function processRequest() { // Build the view selection form. $select_map = array('highlighted' => 'View as Highlighted Text', 'blame' => 'View as Highlighted Text with Blame', 'plain' => 'View as Plain Text', 'plainblame' => 'View as Plain Text with Blame'); $request = $this->getRequest(); $selected = $request->getStr('view'); $select = '<select name="view">'; foreach ($select_map as $k => $v) { $option = phutil_render_tag('option', array('value' => $k, 'selected' => $k == $selected ? 'selected' : null), phutil_escape_html($v)); $select .= $option; } $select .= '</select>'; require_celerity_resource('diffusion-source-css'); $view_select_panel = new AphrontPanelView(); $view_select_form = phutil_render_tag('form', array('action' => $request->getRequestURI(), 'method' => 'get', 'class' => 'diffusion-browse-type-form'), $select . '<button>View</button>'); $view_select_panel->appendChild($view_select_form); $view_select_panel->appendChild('<div style="clear: both;"></div>'); // Build the content of the file. $corpus = $this->buildCorpus($selected); // Render the page. $content = array(); $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse')); $content[] = $view_select_panel; $content[] = $corpus; $nav = $this->buildSideNav('browse', true); $nav->appendChild($content); $basename = basename($this->getDiffusionRequest()->getPath()); return $this->buildStandardPageResponse($nav, array('title' => $basename)); }
public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pastes = id(new PhabricatorPaste())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $pastes = $pager->sliceResults($pastes); $pager->setURI($request->getRequestURI(), 'page'); $phids = mpull($pastes, 'getAuthorPHID'); $handles = array(); if ($phids) { $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); } $rows = array(); foreach ($pastes as $paste) { $handle = $handles[$paste->getAuthorPHID()]; $rows[] = array(phutil_escape_html('P' . $paste->getID()), phutil_render_tag('a', array('href' => '/p/' . $handle->getName() . '/'), phutil_escape_html($handle->getName())), phutil_escape_html($paste->getLanguage()), phutil_render_tag('a', array('href' => '/P' . $paste->getID()), phutil_escape_html(nonempty($paste->getTitle(), 'Untitled Masterwork P' . $paste->getID()))), phutil_render_tag('a', array('href' => PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID())), phutil_escape_html($paste->getFilePHID()))); } $table = new AphrontTableView($rows); $table->setHeaders(array('Paste ID', 'Author', 'Language', 'Title', 'File')); $table->setColumnClasses(array(null, null, null, 'wide pri', null)); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->setHeader("Paste"); $panel->setCreateButton('Paste Something', '/paste/'); $panel->appendChild($table); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Paste List', 'tab' => 'list')); }
public function processRequest() { $request = $this->getRequest(); $nav = new AphrontSideNavView(); $links = array('calls' => 'All Calls'); if (empty($links[$this->view])) { $this->view = key($links); } foreach ($links as $slug => $name) { $nav->addNavItem(phutil_render_tag('a', array('href' => '/conduit/log/view/' . $slug . '/', 'class' => $slug == $this->view ? 'aphront-side-nav-selected' : null), phutil_escape_html($name))); } $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $calls = $call_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $calls = $pager->sliceResults($calls); $pager->setURI(new PhutilURI('/conduit/log/view/' . $this->view . '/'), 'page'); $pager->setEnableKeyboardShortcuts(true); $min = $pager->getOffset() + 1; $max = $min + count($calls) - 1; $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Method Calls (' . $min . '-' . $max . ')'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Conduit Logs', 'tab' => 'logs')); }
public function processRequest() { // Get a page of mails together with pager. $request = $this->getRequest(); $user = $request->getUser(); $offset = $request->getInt('offset', 0); $related_phid = $request->getStr('phid'); $status = $request->getStr('status'); $pager = new AphrontPagerView(); $pager->setOffset($offset); $pager->setURI($request->getRequestURI(), 'offset'); $mail = new PhabricatorMetaMTAMail(); $conn_r = $mail->establishConnection('r'); $wheres = array(); if ($status) { $wheres[] = qsprintf($conn_r, 'status = %s', $status); } if ($related_phid) { $wheres[] = qsprintf($conn_r, 'relatedPHID = %s', $related_phid); } if (count($wheres)) { $where_clause = 'WHERE ' . implode($wheres, ' AND '); } else { $where_clause = 'WHERE 1 = 1'; } $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q ORDER BY id DESC LIMIT %d, %d', $mail->getTableName(), $where_clause, $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $mails = $mail->loadAllFromArray($data); // Render the details table. $rows = array(); foreach ($mails as $mail) { $next_retry = $mail->getNextRetry() - time(); if ($next_retry <= 0) { $next_retry = "None"; } else { $next_retry = phabricator_format_relative_time_detailed($next_retry); } $rows[] = array(PhabricatorMetaMTAMail::getReadableStatus($mail->getStatus()), $mail->getRetryCount(), $next_retry, phabricator_datetime($mail->getDateCreated(), $user), phabricator_format_relative_time_detailed(time() - $mail->getDateModified()), phutil_escape_html($mail->getSubject()), phutil_render_tag('a', array('class' => 'button small grey', 'href' => $this->getApplicationURI('/view/' . $mail->getID() . '/')), 'View')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Status', 'Retry', 'Next', 'Created', 'Updated', 'Subject', '')); $table->setColumnClasses(array(null, null, null, null, null, 'wide', 'action')); // Render the whole page. $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('MetaMTA Messages'); $panel->appendChild($pager); $nav = $this->buildSideNavView(); $nav->selectFilter('sent'); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => 'Sent Mail')); }
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 processRequest() { $request = $this->getRequest(); $macro_table = new PhabricatorFileImageMacro(); if ($request->getStr('name') !== null) { $macros = $macro_table->loadAllWhere('name LIKE %~', $request->getStr('name')); } else { $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize()); // Get an exact count since the size here is reasonably going to be a few // thousand at most in any reasonable case. $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName()); $count = $count['N']; $pager->setCount($count); $pager->setURI($request->getRequestURI(), 'page'); } $file_phids = mpull($macros, 'getFilePHID'); $files = array(); if ($file_phids) { $files = id(new PhabricatorFile())->loadAllWhere("phid IN (%Ls)", $file_phids); $author_phids = mpull($files, 'getAuthorPHID', 'getPHID'); $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles(); } $files_map = mpull($files, null, 'getPHID'); $rows = array(); foreach ($macros as $macro) { $file_phid = $macro->getFilePHID(); $file = idx($files_map, $file_phid); $author_link = isset($author_phids[$file_phid]) ? $handles[$author_phids[$file_phid]]->renderLink() : null; $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), $author_link, phutil_render_tag('a', array('href' => $file ? $file->getBestURI() : null, 'target' => '_blank'), phutil_render_tag('img', array('src' => $file ? $file->getBestURI() : null))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Author', 'Image', '')); $table->setColumnClasses(array('pri', '', 'wide thumb', 'action')); $filter_form = id(new AphrontFormView())->setMethod('GET')->setAction('/file/macro/')->setUser($request->getUser())->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel('Name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Image Macros')); $filter_view = new AphrontListFilterView(); $filter_view->appendChild($filter_form); $filter_view->addButton(phutil_render_tag('a', array('href' => '/file/macro/edit/', 'class' => 'green button'), 'New Image Macro')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Image Macros'); if ($request->getStr('name') === null) { $panel->appendChild($pager); } $side_nav = new PhabricatorFileSideNavView(); $side_nav->setSelectedFilter('all_macros'); $side_nav->appendChild($filter_view); $side_nav->appendChild($panel); return $this->buildStandardPageResponse($side_nav, array('title' => 'Image Macros')); }
public function processRequest() { // Build the view selection form. $select_map = array('highlighted' => 'View as Highlighted Text', 'blame' => 'View as Highlighted Text with Blame', 'plain' => 'View as Plain Text', 'plainblame' => 'View as Plain Text with Blame', 'raw' => 'View as raw document'); $request = $this->getRequest(); $drequest = $this->getDiffusionRequest(); $path = $drequest->getPath(); $selected = $request->getStr('view'); $needs_blame = $selected == 'blame' || $selected == 'plainblame'; $file_query = DiffusionFileContentQuery::newFromDiffusionRequest($this->diffusionRequest); $file_query->setNeedsBlame($needs_blame); $file_query->loadFileContent(); $data = $file_query->getRawData(); if ($selected === 'raw') { $response = new AphrontFileResponse(); $response->setContent($data); $mime_type = $this->getDocumentType($path); if ($mime_type) { $response->setMimeType($mime_type); } else { $as_filename = idx(pathinfo($path), 'basename'); $response->setDownload($as_filename); } return $response; } $select = '<select name="view">'; foreach ($select_map as $k => $v) { $option = phutil_render_tag('option', array('value' => $k, 'selected' => $k == $selected ? 'selected' : null), phutil_escape_html($v)); $select .= $option; } $select .= '</select>'; require_celerity_resource('diffusion-source-css'); $view_select_panel = new AphrontPanelView(); $view_select_form = phutil_render_tag('form', array('action' => $request->getRequestURI(), 'method' => 'get', 'class' => 'diffusion-browse-type-form'), $select . '<button>View</button>'); $view_select_panel->appendChild($view_select_form); $view_select_panel->appendChild('<div style="clear: both;"></div>'); // Build the content of the file. $corpus = $this->buildCorpus($selected, $file_query, $needs_blame, $drequest, $path, $data); // Render the page. $content = array(); $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse')); $content[] = $view_select_panel; $content[] = $corpus; $content[] = $this->buildOpenRevisions(); $nav = $this->buildSideNav('browse', true); $nav->appendChild($content); $basename = basename($this->getDiffusionRequest()->getPath()); return $this->buildStandardPageResponse($nav, array('title' => $basename)); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $editable = $this->getAccountEditable(); // There's no sense in showing a change password panel if the user // can't change their password if (!$editable || !PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) { return new Aphront400Response(); } $errors = array(); if ($request->isFormPost()) { if ($user->comparePassword($request->getStr('old_pw'))) { $pass = $request->getStr('new_pw'); $conf = $request->getStr('conf_pw'); if ($pass === $conf) { if (strlen($pass)) { $user->setPassword($pass); // This write is unguarded because the CSRF token has already // been checked in the call to $request->isFormPost() and // the CSRF token depends on the password hash, so when it // is changed here the CSRF token check will fail. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $user->save(); unset($unguarded); return id(new AphrontRedirectResponse())->setURI('/settings/page/password/?saved=true'); } else { $errors[] = 'Your new password is too short.'; } } else { $errors[] = 'New password and confirmation do not match.'; } } else { $errors[] = 'The old password you entered is incorrect.'; } } $notice = null; if (!$errors) { if ($request->getStr('saved')) { $notice = new AphrontErrorView(); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setTitle('Changes Saved'); $notice->appendChild('<p>Your password has been updated.</p>'); } } else { $notice = new AphrontErrorView(); $notice->setTitle('Error Changing Password'); $notice->setErrors($errors); } $form = new AphrontFormView(); $form->setUser($user)->appendChild(id(new AphrontFormPasswordControl())->setLabel('Old Password')->setName('old_pw')); $form->appendChild(id(new AphrontFormPasswordControl())->setLabel('New Password')->setName('new_pw')); $form->appendChild(id(new AphrontFormPasswordControl())->setLabel('Confirm Password')->setName('conf_pw')); $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Save')); $panel = new AphrontPanelView(); $panel->setHeader('Change Password'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); return id(new AphrontNullView())->appendChild(array($notice, $panel)); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $project = id(new PhabricatorRepositoryArcanistProject())->load($this->id); if (!$project) { return new Aphront404Response(); } $repositories = id(new PhabricatorRepository())->loadAll(); $repos = array(0 => 'None'); foreach ($repositories as $repository) { $callsign = $repository->getCallsign(); $name = $repository->getname(); $repos[$repository->getID()] = "r{$callsign} ({$name})"; } if ($request->isFormPost()) { $repo_id = $request->getInt('repository', 0); if (isset($repos[$repo_id])) { $project->setRepositoryID($repo_id); $project->save(); return id(new AphrontRedirectResponse())->setURI('/repository/'); } } $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setValue($project->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('PHID')->setValue($project->getPHID()))->appendChild(id(new AphrontFormSelectControl())->setLabel('Repository')->setOptions($repos)->setName('repository')->setValue($project->getRepositoryID()))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/repository/')->setValue('Save')); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setHeader('Edit Arcanist Project'); $panel->appendChild($form); return $this->buildStandardPageResponse($panel, array('title' => 'Edit Project')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); if (empty($content_type_map[$this->contentType])) { $this->contentType = head_key($content_type_map); } $rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap(); if (empty($rule_type_map[$this->ruleType])) { $this->ruleType = HeraldRuleTypeConfig::RULE_TYPE_PERSONAL; } // Reorder array to put "personal" first. $rule_type_map = array_select_keys($rule_type_map, array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL)) + $rule_type_map; $captions = array(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL => 'Personal rules notify you about events. You own them, but they can ' . 'only affect you.', HeraldRuleTypeConfig::RULE_TYPE_GLOBAL => 'Global rules notify anyone about events. No one owns them, and ' . 'anyone can edit them. Usually, Global rules are used to notify ' . 'mailing lists.'); $radio = id(new AphrontFormRadioButtonControl())->setLabel('Type')->setName('rule_type')->setValue($this->ruleType); foreach ($rule_type_map as $value => $name) { $radio->addButton($value, $name, idx($captions, $value)); } $form = id(new AphrontFormView())->setUser($user)->setAction('/herald/rule/')->appendChild(id(new AphrontFormSelectControl())->setLabel('New rule for')->setName('content_type')->setValue($this->contentType)->setOptions($content_type_map))->appendChild($radio)->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Rule')->addCancelButton('/herald/view/' . $this->contentType . '/')); $panel = new AphrontPanelView(); $panel->setHeader('Create New Herald Rule'); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->appendChild($form); $nav = $this->renderNav(); $nav->selectFilter('new'); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Create Herald Rule')); }
public function processRequest() { $request = $this->getRequest(); $phids = $request->getStrList('phids'); if ($phids) { $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); foreach ($handles as $handle) { if ($handle->getURI()) { $link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getURI())); } else { $link = null; } $rows[] = array(phutil_escape_html($handle->getPHID()), phutil_escape_html($handle->getType()), phutil_escape_html($handle->getName()), $link); } $table = new AphrontTableView($rows); $table->setHeaders(array('PHID', 'Type', 'Name', 'URI')); $table->setColumnClasses(array(null, null, null, 'wide')); $panel = new AphrontPanelView(); $panel->setHeader('PHID Handles'); $panel->appendChild($table); return $this->buildStandardPageResponse($panel, array('title' => 'PHID Lookup Results')); } $lookup_form = new AphrontFormView(); $lookup_form->setUser($request->getUser()); $lookup_form->setAction('/phid/')->appendChild(id(new AphrontFormTextAreaControl())->setName('phids')->setCaption('Enter PHIDs separated by spaces or commas.'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Lookup PHIDs')); $lookup_panel = new AphrontPanelView(); $lookup_panel->setHeader('Lookup PHIDs'); $lookup_panel->appendChild($lookup_form); $lookup_panel->setWidth(AphrontPanelView::WIDTH_WIDE); return $this->buildStandardPageResponse(array($lookup_panel), array('title' => 'PHID Lookup')); }
public function processRequest() { $event = id(new PhabricatorTimelineEvent('NULL'))->load($this->id); if (!$event) { return new Aphront404Response(); } $request = $this->getRequest(); $user = $request->getUser(); if ($event->getDataID()) { $data = id(new PhabricatorTimelineEventData())->load($event->getDataID()); } if ($data) { $data = json_encode($data->getEventData()); } else { $data = 'null'; } $form = new AphrontFormView(); $form->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($event->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($event->getType()))->appendChild(id(new AphrontFormTextAreaControl())->setDisabled(true)->setLabel('Data')->setValue($data))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/timeline/')); $panel = new AphrontPanelView(); $panel->setHeader('Event'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); $nav = $this->buildSideNavView(); $nav->selectFilter('timeline'); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => 'Timeline Event')); }
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(); if ($request->isFormPost()) { $source = $request->getStr('source'); $future = xhpast_get_parser_future($source); $resolved = $future->resolve(); // This is just to let it throw exceptions if stuff is broken. $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture($source, $resolved); list($err, $stdout, $stderr) = $resolved; $storage_tree = new PhabricatorXHPASTViewParseTree(); $storage_tree->setInput($source); $storage_tree->setStdout($stdout); $storage_tree->setAuthorPHID($user->getPHID()); $storage_tree->save(); return id(new AphrontRedirectResponse())->setURI('/xhpast/view/' . $storage_tree->getID() . '/'); } $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Source')->setName('source')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))->appendChild(id(new AphrontFormSubmitControl())->setValue('Parse')); $panel = new AphrontPanelView(); $panel->setHeader('Generate XHP AST'); $panel->setWidth(AphrontPanelView::WIDTH_WIDE); $panel->appendChild($form); return $this->buildStandardPageResponse($panel, array('title' => 'XHPAST View')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($request->isFormPost()) { $receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($request->getStr('obj')); if (!$receiver) { throw new Exception("No such task or revision!"); } $hash = PhabricatorMetaMTAReceivedMail::computeMailHash($receiver->getMailKey(), $user->getPHID()); $received = new PhabricatorMetaMTAReceivedMail(); $received->setHeaders(array('to' => $request->getStr('obj') . '+' . $user->getID() . '+' . $hash . '@')); $received->setBodies(array('text' => $request->getStr('body'))); $received->save(); $received->processReceivedMail(); $phid = $receiver->getPHID(); $handles = $this->loadViewerHandles(array($phid)); $uri = $handles[$phid]->getURI(); return id(new AphrontRedirectResponse())->setURI($uri); } $form = new AphrontFormView(); $form->setUser($request->getUser()); $form->setAction($this->getApplicationURI('/receive/')); $form->appendChild('<p class="aphront-form-instructions">This form will simulate ' . 'sending mail to an object.</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('To')->setName('obj')->setCaption('e.g. <tt>D1234</tt> or <tt>T1234</tt>'))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Body')->setName('body'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Receive Mail')); $panel = new AphrontPanelView(); $panel->setHeader('Receive Email'); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $nav = $this->buildSideNavView(); $nav->selectFilter('receive'); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => 'Receive Test')); }
public function processRequest() { $request = $this->getRequest(); if ($request->isFormPost()) { $parser = new ArcanistDiffParser(); $diff = null; try { $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']); } catch (Exception $ex) { $diff = $request->getStr('diff'); } $changes = $parser->parseDiff($diff); $diff = DifferentialDiff::newFromRawChanges($changes); $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP); $diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP); $diff->setAuthorPHID($request->getUser()->getPHID()); $diff->setCreationMethod('web'); $diff->save(); return id(new AphrontRedirectResponse())->setURI('/differential/diff/' . $diff->getID() . '/'); } $form = new AphrontFormView(); $arcanist_href = PhabricatorEnv::getDoclink('article/Arcanist_User_Guide.html'); $arcanist_link = phutil_render_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), 'Arcanist'); $form->setAction('/differential/diff/create/')->setEncType('multipart/form-data')->setUser($request->getUser())->appendChild('<p class="aphront-form-instructions">The best way to create a ' . "Differential diff is by using {$arcanist_link}, but you " . 'can also just paste a diff (e.g., from <tt>svn diff</tt> or ' . '<tt>git diff</tt>) into this box or upload it as a file if you ' . 'really want.</p>')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Raw Diff')->setName('diff')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))->appendChild(id(new AphrontFormFileControl())->setLabel('Raw Diff from file')->setName('diff-file'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Create Diff »")); $panel = new AphrontPanelView(); $panel->setHeader('Create New Diff'); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); return $this->buildStandardPageResponse($panel, array('title' => 'Create Diff', 'tab' => 'create')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $preferences = $user->loadPreferences(); if ($request->isFormPost()) { $monospaced = $request->getStr(PhabricatorUserPreferences::PREFERENCE_MONOSPACED); // Prevent the user from doing stupid things. $monospaced = preg_replace('/[^a-z0-9 ,"]+/i', '', $monospaced); $pref_dict = array(PhabricatorUserPreferences::PREFERENCE_TITLES => $request->getStr(PhabricatorUserPreferences::PREFERENCE_TITLES), PhabricatorUserPreferences::PREFERENCE_MONOSPACED => $monospaced); $preferences->setPreferences($pref_dict); $preferences->save(); return id(new AphrontRedirectResponse())->setURI('/settings/page/preferences/?saved=true'); } $example_string = <<<EXAMPLE // This is what your monospaced font currently looks like. function helloWorld() { alert("Hello world!"); } EXAMPLE; $form = id(new AphrontFormView())->setUser($user)->setAction('/settings/page/preferences/')->appendChild(id(new AphrontFormSelectControl())->setLabel('Page Titles')->setName(PhabricatorUserPreferences::PREFERENCE_TITLES)->setValue($preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_TITLES))->setOptions(array('glyph' => "In page titles, show Tool names as unicode glyphs: ⚙", 'text' => 'In page titles, show Tool names as plain text: [Differential]')))->appendChild(id(new AphrontFormTextControl())->setLabel('Monospaced Font')->setName(PhabricatorUserPreferences::PREFERENCE_MONOSPACED)->setCaption('Overrides default fonts in tools like Differential. ' . '(Default: 10px "Menlo", "Consolas", "Monaco", ' . 'monospace)')->setValue($preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_MONOSPACED)))->appendChild(id(new AphrontFormMarkupControl())->setValue('<pre class="PhabricatorMonospaced">' . phutil_escape_html($example_string) . '</pre>'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save Preferences')); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_WIDE); $panel->setHeader('Phabricator Preferences'); $panel->appendChild($form); $error_view = null; if ($request->getStr('saved') === 'true') { $error_view = id(new AphrontErrorView())->setTitle('Preferences Saved')->setSeverity(AphrontErrorView::SEVERITY_NOTICE)->setErrors(array('Your preferences have been saved.')); } return id(new AphrontNullView())->appendChild(array($error_view, $panel)); }
private function renderServerStatus(array $status) { $rows = array(); foreach ($status as $key => $value) { $label = phutil_escape_html($key); switch ($key) { case 'uptime': $value /= 1000; $value = phabricator_format_relative_time_detailed($value); break; case 'log': $value = phutil_escape_html($value); break; default: $value = phutil_escape_html(number_format($value)); break; } $rows[] = array($label, $value); } $table = new AphrontTableView($rows); $table->setColumnClasses(array('header', 'wide')); $panel = new AphrontPanelView(); $panel->setHeader('Server Status'); $panel->appendChild($table); return $panel; }
private function buildChartForm() { $request = $this->getRequest(); $user = $request->getUser(); $table = new PhabricatorFactRaw(); $conn_r = $table->establishConnection('r'); $table_name = $table->getTableName(); $facts = queryfx_all($conn_r, 'SELECT DISTINCT factType from %T', $table_name); $specs = PhabricatorFactSpec::newSpecsForFactTypes(PhabricatorFactEngine::loadAllEngines(), ipull($facts, 'factType')); $options = array(); foreach ($specs as $spec) { if ($spec->getUnit() == PhabricatorFactSpec::UNIT_COUNT) { $options[$spec->getType()] = $spec->getName(); } } if (!$options) { return id(new AphrontErrorView())->setSeverity(AphrontErrorView::SEVERITY_NOTICE)->setTitle(pht('No Chartable Facts'))->appendChild('<p>' . pht('There are no facts that can be plotted yet.') . '</p>'); } $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel('Y-Axis')->setName('y1')->setOptions($options))->appendChild(id(new AphrontFormSubmitControl())->setValue('Plot Chart')); $panel = new AphrontPanelView(); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setHeader('Plot Chart'); return $panel; }
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)); }