AphrontRequest PHP Class Code Examples

This page contains top rated real world PHP examples of class AphrontRequest extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: PhabricatorOAuthServerTestController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $client = id(new PhabricatorOAuthServerClientQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$client) {
         return new Aphront404Response();
     }
     $view_uri = $client->getViewURI();
     // Look for an existing authorization.
     $authorization = id(new PhabricatorOAuthClientAuthorizationQuery())->setViewer($viewer)->withUserPHIDs(array($viewer->getPHID()))->withClientPHIDs(array($client->getPHID()))->executeOne();
     if ($authorization) {
         return $this->newDialog()->setTitle(pht('Already Authorized'))->appendParagraph(pht('You have already authorized this application to access your ' . 'account.'))->addCancelButton($view_uri, pht('Close'));
     }
     if ($request->isFormPost()) {
         $server = id(new PhabricatorOAuthServer())->setUser($viewer)->setClient($client);
         $scope = array();
         $authorization = $server->authorizeClient($scope);
         $id = $authorization->getID();
         $panel_uri = '/settings/panel/oauthorizations/?id=' . $id;
         return id(new AphrontRedirectResponse())->setURI($panel_uri);
     }
     // TODO: It would be nice to put scope options in this dialog, maybe?
     return $this->newDialog()->setTitle(pht('Authorize Application?'))->appendParagraph(pht('This will create an authorization, permitting %s to access ' . 'your account.', phutil_tag('strong', array(), $client->getName())))->addCancelButton($view_uri)->addSubmitButton(pht('Authorize Application'));
 }
Example #2
Show file File: PhabricatorBadgesSearchEngine.php Project: patelhardik/phabricator
0
 public function buildSavedQueryFromRequest(AphrontRequest $request)
 {
     $saved = new PhabricatorSavedQuery();
     $saved->setParameter('statuses', $this->readListFromRequest($request, 'statuses'));
     $saved->setParameter('qualities', $this->readListFromRequest($request, 'qualities'));
     return $saved;
 }
Example #3
Show file File: FundInitiativeCloseController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $initiative = id(new FundInitiativeQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$initiative) {
         return new Aphront404Response();
     }
     $initiative_uri = '/' . $initiative->getMonogram();
     $is_close = !$initiative->isClosed();
     if ($request->isFormPost()) {
         $type_status = FundInitiativeTransaction::TYPE_STATUS;
         if ($is_close) {
             $new_status = FundInitiative::STATUS_CLOSED;
         } else {
             $new_status = FundInitiative::STATUS_OPEN;
         }
         $xaction = id(new FundInitiativeTransaction())->setTransactionType($type_status)->setNewValue($new_status);
         $editor = id(new FundInitiativeEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true);
         $editor->applyTransactions($initiative, array($xaction));
         return id(new AphrontRedirectResponse())->setURI($initiative_uri);
     }
     if ($is_close) {
         $title = pht('Close Initiative?');
         $body = pht('Really close this initiative? Users will no longer be able to ' . 'back it.');
         $button_text = pht('Close Initiative');
     } else {
         $title = pht('Reopen Initiative?');
         $body = pht('Really reopen this initiative?');
         $button_text = pht('Reopen Initiative');
     }
     return $this->newDialog()->setTitle($title)->appendParagraph($body)->addCancelButton($initiative_uri)->addSubmitButton($button_text);
 }
Example #4
Show file File: DivinerBookEditController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needProjectPHIDs(true)->withNames(array($book_name))->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $view_uri = '/book/' . $book->getName() . '/';
     if ($request->isFormPost()) {
         $v_projects = $request->getArr('projectPHIDs');
         $v_view = $request->getStr('viewPolicy');
         $v_edit = $request->getStr('editPolicy');
         $xactions = array();
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($v_projects)));
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
         $xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
         id(new DivinerLiveBookEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($book, $xactions);
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Basics'));
     $title = pht('Edit %s', $book->getTitle());
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($book)->execute();
     $view_capability = PhabricatorPolicyCapability::CAN_VIEW;
     $edit_capability = PhabricatorPolicyCapability::CAN_EDIT;
     $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Projects'))->setValue($book->getProjectPHIDs()))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionRepositoryDatasource())->setName('repositoryPHIDs')->setLabel(pht('Repository'))->setDisableBehavior(true)->setLimit(1)->setValue($book->getRepositoryPHID() ? array($book->getRepositoryPHID()) : null))->appendChild(id(new AphrontFormPolicyControl())->setName('viewPolicy')->setPolicyObject($book)->setCapability($view_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($view_capability)))->appendChild(id(new AphrontFormPolicyControl())->setName('editPolicy')->setPolicyObject($book)->setCapability($edit_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($edit_capability)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($view_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     $timeline = $this->buildTransactionTimeline($book, new DivinerLiveBookTransactionQuery());
     $timeline->setShouldTerminate(true);
     return $this->buildApplicationPage(array($crumbs, $object_box, $timeline), array('title' => $title));
 }
Example #5
Show file File: PhameSkinSpecification.php Project: patelhardik/phabricator
0
 public function buildSkin(AphrontRequest $request)
 {
     foreach ($this->phutilLibraries as $library) {
         phutil_load_library($library);
     }
     return newv($this->getSkinClass(), array($request, $this));
 }
Example #6
Show file File: PhabricatorDashboardArchiveController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $dashboard = id(new PhabricatorDashboardQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$dashboard) {
         return new Aphront404Response();
     }
     $view_uri = $this->getApplicationURI('manage/' . $dashboard->getID() . '/');
     if ($request->isFormPost()) {
         if ($dashboard->isArchived()) {
             $new_status = PhabricatorDashboard::STATUS_ACTIVE;
         } else {
             $new_status = PhabricatorDashboard::STATUS_ARCHIVED;
         }
         $xactions = array();
         $xactions[] = id(new PhabricatorDashboardTransaction())->setTransactionType(PhabricatorDashboardTransaction::TYPE_STATUS)->setNewValue($new_status);
         id(new PhabricatorDashboardTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($dashboard, $xactions);
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     if ($dashboard->isArchived()) {
         $title = pht('Activate Dashboard');
         $body = pht('This dashboard will become active again.');
         $button = pht('Activate Dashboard');
     } else {
         $title = pht('Archive Dashboard');
         $body = pht('This dashboard will be marked as archived.');
         $button = pht('Archive Dashboard');
     }
     return $this->newDialog()->setTitle($title)->appendChild($body)->addCancelButton($view_uri)->addSubmitButton($button);
 }
Example #7
Show file File: DiffusionRepositoryEditStagingController.php Project: truSense/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $response = $this->loadDiffusionContextForEdit();
     if ($response) {
         return $response;
     }
     $viewer = $this->getViewer();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     if (!$repository->supportsStaging()) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
     $v_area = $repository->getHumanReadableDetail('staging-uri');
     if ($request->isFormPost()) {
         $v_area = $request->getStr('area');
         $xactions = array();
         $template = id(new PhabricatorRepositoryTransaction());
         $type_encoding = PhabricatorRepositoryTransaction::TYPE_STAGING_URI;
         $xactions[] = id(clone $template)->setTransactionType($type_encoding)->setNewValue($v_area);
         id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($repository, $xactions);
         return id(new AphrontRedirectResponse())->setURI($edit_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Staging'));
     $title = pht('Edit %s', $repository->getName());
     $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht("To make it easier to run integration tests and builds on code " . "under review, you can configure a **Staging Area**. When `arc` " . "creates a diff, it will push a copy of the changes to the " . "configured staging area with a corresponding tag." . "\n\n" . "IMPORTANT: This feature is new, experimental, and not supported. " . "Use it at your own risk."))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Staging Area URI'))->setName('area')->setValue($v_area))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($edit_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($object_box);
 }
Example #8
Show file File: PhameBlogManageController.php Project: MenZil-Team/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $blog = id(new PhameBlogQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->executeOne();
     if (!$blog) {
         return new Aphront404Response();
     }
     if ($blog->isArchived()) {
         $header_icon = 'fa-ban';
         $header_name = pht('Archived');
         $header_color = 'dark';
     } else {
         $header_icon = 'fa-check';
         $header_name = pht('Active');
         $header_color = 'bluegrey';
     }
     $picture = $blog->getProfileImageURI();
     $header = id(new PHUIHeaderView())->setHeader($blog->getName())->setUser($viewer)->setPolicyObject($blog)->setImage($picture)->setStatus($header_icon, $header_color, $header_name);
     $actions = $this->renderActions($blog, $viewer);
     $properties = $this->renderProperties($blog, $viewer, $actions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Blogs'), $this->getApplicationURI('blog/'));
     $crumbs->addTextCrumb($blog->getName());
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $timeline = $this->buildTransactionTimeline($blog, new PhameBlogTransactionQuery());
     $timeline->setShouldTerminate(true);
     return $this->newPage()->setTitle($blog->getName())->setCrumbs($crumbs)->appendChild(array($object_box, $timeline));
 }
Example #9
Show file File: PhabricatorAuthFinishController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     // If the user already has a full session, just kick them out of here.
     $has_partial_session = $viewer->hasSession() && $viewer->getSession()->getIsPartial();
     if (!$has_partial_session) {
         return id(new AphrontRedirectResponse())->setURI('/');
     }
     $engine = new PhabricatorAuthSessionEngine();
     // If this cookie is set, the user is headed into a high security area
     // after login (normally because of a password reset) so if they are
     // able to pass the checkpoint we just want to put their account directly
     // into high security mode, rather than prompt them again for the same
     // set of credentials.
     $jump_into_hisec = $request->getCookie(PhabricatorCookies::COOKIE_HISEC);
     try {
         $token = $engine->requireHighSecuritySession($viewer, $request, '/logout/', $jump_into_hisec);
     } catch (PhabricatorAuthHighSecurityRequiredException $ex) {
         $form = id(new PhabricatorAuthSessionEngine())->renderHighSecurityForm($ex->getFactors(), $ex->getFactorValidationResults(), $viewer, $request);
         return $this->newDialog()->setTitle(pht('Provide Multi-Factor Credentials'))->setShortTitle(pht('Multi-Factor Login'))->setWidth(AphrontDialogView::WIDTH_FORM)->addHiddenInput(AphrontRequest::TYPE_HISEC, true)->appendParagraph(pht('Welcome, %s. To complete the login process, provide your ' . 'multi-factor credentials.', phutil_tag('strong', array(), $viewer->getUsername())))->appendChild($form->buildLayoutView())->setSubmitURI($request->getPath())->addCancelButton($ex->getCancelURI())->addSubmitButton(pht('Continue'));
     }
     // Upgrade the partial session to a full session.
     $engine->upgradePartialSession($viewer);
     // TODO: It might be nice to add options like "bind this session to my IP"
     // here, even for accounts without multi-factor auth attached to them.
     $next = PhabricatorCookies::getNextURICookie($request);
     $request->clearCookie(PhabricatorCookies::COOKIE_NEXTURI);
     $request->clearCookie(PhabricatorCookies::COOKIE_HISEC);
     if (!PhabricatorEnv::isValidLocalURIForLink($next)) {
         $next = '/';
     }
     return id(new AphrontRedirectResponse())->setURI($next);
 }
Example #10
Show file File: HarbormasterBuildableViewController.php Project: patelhardik/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $buildable = id(new HarbormasterBuildableQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->needBuildableHandles(true)->needContainerHandles(true)->executeOne();
     if (!$buildable) {
         return new Aphront404Response();
     }
     $id = $buildable->getID();
     // Pull builds and build targets.
     $builds = id(new HarbormasterBuildQuery())->setViewer($viewer)->withBuildablePHIDs(array($buildable->getPHID()))->needBuildTargets(true)->execute();
     list($lint, $unit) = $this->renderLintAndUnit($buildable, $builds);
     $buildable->attachBuilds($builds);
     $object = $buildable->getBuildableObject();
     $build_list = $this->buildBuildList($buildable);
     $title = pht('Buildable %d', $id);
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($buildable);
     $box = id(new PHUIObjectBoxView())->setHeader($header);
     $timeline = $this->buildTransactionTimeline($buildable, new HarbormasterBuildableTransactionQuery());
     $timeline->setShouldTerminate(true);
     $actions = $this->buildActionList($buildable);
     $this->buildPropertyLists($box, $buildable, $actions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($buildable->getMonogram());
     return $this->buildApplicationPage(array($crumbs, $box, $lint, $unit, $build_list, $timeline), array('title' => $title));
 }
Example #11
Show file File: PhabricatorDashboardManageController.php Project: fuding/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $dashboard_uri = $this->getApplicationURI('view/' . $id . '/');
     // TODO: This UI should drop a lot of capabilities if the user can't
     // edit the dashboard, but we should still let them in for "Install" and
     // "View History".
     $dashboard = id(new PhabricatorDashboardQuery())->setViewer($viewer)->withIDs(array($id))->needPanels(true)->executeOne();
     if (!$dashboard) {
         return new Aphront404Response();
     }
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $dashboard, PhabricatorPolicyCapability::CAN_EDIT);
     $title = $dashboard->getName();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID()), $dashboard_uri);
     $crumbs->addTextCrumb(pht('Manage'));
     $header = $this->buildHeaderView($dashboard);
     $actions = $this->buildActionView($dashboard);
     $properties = $this->buildPropertyView($dashboard);
     $properties->setActionList($actions);
     $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     if (!$can_edit) {
         $no_edit = pht('You do not have permission to edit this dashboard. If you want to ' . 'make changes, make a copy first.');
         $box->setInfoView(id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setErrors(array($no_edit)));
     }
     $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())->setViewer($viewer)->setDashboard($dashboard)->setArrangeMode($can_edit)->renderDashboard();
     return $this->buildApplicationPage(array($crumbs, $box, $rendered_dashboard), array('title' => $title));
 }
Example #12
Show file File: PhabricatorLogoutController.php Project: truSense/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     if ($request->isFormPost()) {
         $log = PhabricatorUserLog::initializeNewLog($viewer, $viewer->getPHID(), PhabricatorUserLog::ACTION_LOGOUT);
         $log->save();
         // Destroy the user's session in the database so logout works even if
         // their cookies have some issues. We'll detect cookie issues when they
         // try to login again and tell them to clear any junk.
         $phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
         if (strlen($phsid)) {
             $session = id(new PhabricatorAuthSessionQuery())->setViewer($viewer)->withSessionKeys(array($phsid))->executeOne();
             if ($session) {
                 $session->delete();
             }
         }
         $request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
         return id(new AphrontRedirectResponse())->setURI('/auth/loggedout/');
     }
     if ($viewer->getPHID()) {
         $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Log out of Phabricator?'))->appendChild(pht('Are you sure you want to log out?'))->addSubmitButton(pht('Logout'))->addCancelButton('/');
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     return id(new AphrontRedirectResponse())->setURI('/');
 }
Example #13
Show file File: PhabricatorSpacesArchiveController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $space = id(new PhabricatorSpacesNamespaceQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$space) {
         return new Aphront404Response();
     }
     $is_archive = $request->getURIData('action') == 'archive';
     $cancel_uri = '/' . $space->getMonogram();
     if ($request->isFormPost()) {
         $type_archive = PhabricatorSpacesNamespaceTransaction::TYPE_ARCHIVE;
         $xactions = array();
         $xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_archive)->setNewValue($is_archive ? 1 : 0);
         $editor = id(new PhabricatorSpacesNamespaceEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request);
         $editor->applyTransactions($space, $xactions);
         return id(new AphrontRedirectResponse())->setURI($cancel_uri);
     }
     $body = array();
     if ($is_archive) {
         $title = pht('Archive Space: %s', $space->getNamespaceName());
         $body[] = pht('If you archive this Space, you will no longer be able to create ' . 'new objects inside it.');
         $body[] = pht('Existing objects in this Space will be hidden from query results ' . 'by default.');
         $button = pht('Archive Space');
     } else {
         $title = pht('Activate Space: %s', $space->getNamespaceName());
         $body[] = pht('If you activate this space, you will be able to create objects ' . 'inside it again.');
         $body[] = pht('Existing objects will no longer be hidden from query results.');
         $button = pht('Activate Space');
     }
     $dialog = $this->newDialog()->setTitle($title)->addCancelButton($cancel_uri)->addSubmitButton($button);
     foreach ($body as $paragraph) {
         $dialog->appendParagraph($paragraph);
     }
     return $dialog;
 }
Example #14
Show file File: DiffusionRepositoryEditActionsController.php Project: patelhardik/phabricator
0
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $drequest = $this->diffusionRequest;
     $repository = $drequest->getRepository();
     $repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne();
     if (!$repository) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
     // NOTE: We're inverting these here, because the storage is silly.
     $v_notify = !$repository->getHumanReadableDetail('herald-disabled');
     $v_autoclose = !$repository->getHumanReadableDetail('disable-autoclose');
     if ($request->isFormPost()) {
         $v_notify = $request->getBool('notify');
         $v_autoclose = $request->getBool('autoclose');
         $xactions = array();
         $template = id(new PhabricatorRepositoryTransaction());
         $type_notify = PhabricatorRepositoryTransaction::TYPE_NOTIFY;
         $type_autoclose = PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE;
         $xactions[] = id(clone $template)->setTransactionType($type_notify)->setNewValue($v_notify);
         $xactions[] = id(clone $template)->setTransactionType($type_autoclose)->setNewValue($v_autoclose);
         id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($repository, $xactions);
         return id(new AphrontRedirectResponse())->setURI($edit_uri);
     }
     $content = array();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Actions'));
     $title = pht('Edit Actions (%s)', $repository->getName());
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($repository)->execute();
     $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht("Normally, Phabricator publishes notifications when it discovers " . "new commits. You can disable publishing for this repository by " . "turning off **Notify/Publish**. This will disable notifications, " . "feed, and Herald (including audits and build plans) for this " . "repository.\n\n" . "When Phabricator discovers a new commit, it can automatically " . "close associated revisions and tasks. If you don't want " . "Phabricator to close objects when it discovers new commits in " . "this repository, you can disable **Autoclose**."))->appendChild(id(new AphrontFormSelectControl())->setName('notify')->setLabel(pht('Notify/Publish'))->setValue((int) $v_notify)->setOptions(array(1 => pht('Enable Notifications, Feed and Herald'), 0 => pht('Disable Notifications, Feed and Herald'))))->appendChild(id(new AphrontFormSelectControl())->setName('autoclose')->setLabel(pht('Autoclose'))->setValue((int) $v_autoclose)->setOptions(array(1 => pht('Enable Autoclose'), 0 => pht('Disable Autoclose'))))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Actions'))->addCancelButton($edit_uri));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
 }
Example #15
Show file File: PhabricatorMediaWikiAuthProvider.php Project: YJSoft/phabricator-extensions
0
 public function extendEditForm(AphrontRequest $request, AphrontFormView $form, array $values, array $issues)
 {
     $is_setup = $this->isSetup();
     $e_required = $request->isFormPost() ? null : true;
     $v_name = $values[self::PROPERTY_MEDIAWIKI_NAME];
     if ($is_setup) {
         $e_name = idx($issues, self::PROPERTY_MEDIAWIKI_NAME, $e_required);
     } else {
         $e_name = null;
     }
     $v_uri = $values[self::PROPERTY_MEDIAWIKI_URI];
     $e_uri = idx($issues, self::PROPERTY_MEDIAWIKI_URI, $e_required);
     $config = $this->getProviderConfig();
     if ($is_setup) {
         $form->appendRemarkupInstructions(pht("**MediaWiki Instance Name**\n\n" . "Choose a permanent name for this instance of MediaWiki." . "Phabricator uses this name internally to keep track of " . "this instance of MediaWiki, in case the URL changes later." . "\n\n" . "Use lowercase letters, digits, and period. For example: " . "\n\n`mediawiki`, `mediawiki.mycompany` " . "or `mediawiki.engineering` are reasonable names."))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('MediaWiki Instance Name'))->setValue($v_name)->setName(self::PROPERTY_MEDIAWIKI_NAME)->setError($e_name));
     } else {
         $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('MediaWiki Instance Name'))->setValue($v_name)->setName(self::PROPERTY_MEDIAWIKI_NAME)->setDisabled(true)->setError($e_name));
     }
     $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('MediaWiki Base URI'))->setValue($v_uri)->setName(self::PROPERTY_MEDIAWIKI_URI)->setPlaceholder('https://www.mediawiki.org/w')->setCaption(pht('The full URL to your MediaWiki innstall, up to but not including "index.php"'))->setError($e_uri));
     if (!$is_setup) {
         if (!strlen($config->getProperty(self::PROPERTY_CONSUMER_KEY))) {
             $form->appendRemarkupInstructions(pht('NOTE: Copy the keys generated by the MediaWiki OAuth' . ' consumer registration and paste them here.'));
         }
         $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Consumer Key'))->setName(self::PROPERTY_CONSUMER_KEY)->setValue($values[self::PROPERTY_CONSUMER_KEY]))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Secret Key'))->setName(self::PROPERTY_CONSUMER_SECRET)->setValue($values[self::PROPERTY_CONSUMER_SECRET]));
     }
 }
Example #16
Show file File: PhabricatorXHProfProfileController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $phid = $request->getURIData('phid');
     $file = id(new PhabricatorFileQuery())->setViewer($request->getUser())->withPHIDs(array($phid))->executeOne();
     if (!$file) {
         return new Aphront404Response();
     }
     $data = $file->loadFileData();
     try {
         $data = phutil_json_decode($data);
     } catch (PhutilJSONParserException $ex) {
         throw new PhutilProxyException(pht('Failed to unserialize XHProf profile!'), $ex);
     }
     $symbol = $request->getStr('symbol');
     $is_framed = $request->getBool('frame');
     if ($symbol) {
         $view = new PhabricatorXHProfProfileSymbolView();
         $view->setSymbol($symbol);
     } else {
         $view = new PhabricatorXHProfProfileTopLevelView();
         $view->setFile($file);
         $view->setLimit(100);
     }
     $view->setBaseURI($request->getRequestURI()->getPath());
     $view->setIsFramed($is_framed);
     $view->setProfileData($data);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('%s Profile', $symbol));
     return $this->buildStandardPageResponse(array($crumbs, $view), array('title' => pht('Profile'), 'frame' => $is_framed));
 }
Example #17
Show file File: PhabricatorMetaMTAMailgunReceiveController.php Project: barcelonascience/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     // No CSRF for Mailgun.
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     if (!$this->verifyMessage()) {
         throw new Exception(pht('Mail signature is not valid. Check your Mailgun API key.'));
     }
     $user = $request->getUser();
     $raw_headers = $request->getStr('headers');
     $raw_headers = explode("\n", rtrim($raw_headers));
     $raw_dict = array();
     foreach (array_filter($raw_headers) as $header) {
         list($name, $value) = explode(':', $header, 2);
         $raw_dict[$name] = ltrim($value);
     }
     $headers = array('to' => $request->getStr('recipient'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
     $received = new PhabricatorMetaMTAReceivedMail();
     $received->setHeaders($headers);
     $received->setBodies(array('text' => $request->getStr('stripped-text'), 'html' => $request->getStr('stripped-html')));
     $file_phids = array();
     foreach ($_FILES as $file_raw) {
         try {
             $file = PhabricatorFile::newFromPHPUpload($file_raw, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
             $file_phids[] = $file->getPHID();
         } catch (Exception $ex) {
             phlog($ex);
         }
     }
     $received->setAttachments($file_phids);
     $received->save();
     $received->processReceivedMail();
     $response = new AphrontWebpageResponse();
     $response->setContent(pht("Got it! Thanks, Mailgun!\n"));
     return $response;
 }
Example #18
Show file File: DiffusionRepositoryNewController.php Project: patelhardik/phabricator
0
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $this->requireApplicationCapability(DiffusionCreateRepositoriesCapability::CAPABILITY);
     if ($request->isFormPost()) {
         if ($request->getStr('type')) {
             switch ($request->getStr('type')) {
                 case 'create':
                     $uri = $this->getApplicationURI('create/');
                     break;
                 case 'import':
                 default:
                     $uri = $this->getApplicationURI('import/');
                     break;
             }
             return id(new AphrontRedirectResponse())->setURI($uri);
         }
     }
     $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Repository Hosting');
     $doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Diffusion User Guide: Repository Hosting'));
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormRadioButtonControl())->setName('type')->addButton('create', pht('Create a New Hosted Repository'), array(pht('Create a new, empty repository which Phabricator will host. ' . 'For instructions on configuring repository hosting, see %s.', $doc_link)))->addButton('import', pht('Import an Existing External Repository'), pht("Import a repository hosted somewhere else, like GitHub, " . "Bitbucket, or your organization's existing servers. " . "Phabricator will read changes from the repository but will " . "not host or manage it. The authoritative master version of " . "the repository will stay where it is now.")))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($this->getApplicationURI()));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('New Repository'));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Create or Import Repository'))->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => pht('New Repository')));
 }
Example #19
Show file File: DrydockBlueprintViewController.php Project: patelhardik/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$blueprint) {
         return new Aphront404Response();
     }
     $title = $blueprint->getBlueprintName();
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($blueprint);
     if ($blueprint->getIsDisabled()) {
         $header->setStatus('fa-ban', 'red', pht('Disabled'));
     } else {
         $header->setStatus('fa-check', 'bluegrey', pht('Active'));
     }
     $actions = $this->buildActionListView($blueprint);
     $properties = $this->buildPropertyListView($blueprint, $actions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID()));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $field_list = PhabricatorCustomField::getObjectFields($blueprint, PhabricatorCustomField::ROLE_VIEW);
     $field_list->setViewer($viewer)->readFieldsFromStorage($blueprint);
     $field_list->appendFieldsToPropertyList($blueprint, $viewer, $properties);
     $resource_box = $this->buildResourceBox($blueprint);
     $authorizations_box = $this->buildAuthorizationsBox($blueprint);
     $timeline = $this->buildTransactionTimeline($blueprint, new DrydockBlueprintTransactionQuery());
     $timeline->setShouldTerminate(true);
     $log_query = id(new DrydockLogQuery())->withBlueprintPHIDs(array($blueprint->getPHID()));
     $log_box = $this->buildLogBox($log_query, $this->getApplicationURI("blueprint/{$id}/logs/query/all/"));
     return $this->buildApplicationPage(array($crumbs, $object_box, $resource_box, $authorizations_box, $log_box, $timeline), array('title' => $title));
 }
Example #20
Show file File: PhabricatorTokensSettingsPanel.php Project: truSense/phabricator
0
 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;
 }
Example #21
Show file File: DiffusionRepositoryEditStagingController.php Project: patelhardik/phabricator
0
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $drequest = $this->diffusionRequest;
     $repository = $drequest->getRepository();
     $repository = id(new PhabricatorRepositoryQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne();
     if (!$repository) {
         return new Aphront404Response();
     }
     if (!$repository->supportsStaging()) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
     $v_area = $repository->getHumanReadableDetail('staging-uri');
     if ($request->isFormPost()) {
         $v_area = $request->getStr('area');
         $xactions = array();
         $template = id(new PhabricatorRepositoryTransaction());
         $type_encoding = PhabricatorRepositoryTransaction::TYPE_STAGING_URI;
         $xactions[] = id(clone $template)->setTransactionType($type_encoding)->setNewValue($v_area);
         id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($user)->applyTransactions($repository, $xactions);
         return id(new AphrontRedirectResponse())->setURI($edit_uri);
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Staging'));
     $title = pht('Edit %s', $repository->getName());
     $form = id(new AphrontFormView())->setUser($user)->appendRemarkupInstructions(pht("To make it easier to run integration tests and builds on code " . "under review, you can configure a **Staging Area**. When `arc` " . "creates a diff, it will push a copy of the changes to the " . "configured staging area with a corresponding tag." . "\n\n" . "IMPORTANT: This feature is new, experimental, and not supported. " . "Use it at your own risk."))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Staging Area URI'))->setName('area')->setValue($v_area))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($edit_uri));
     $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $object_box), array('title' => $title));
 }
Example #22
Show file File: PhamePostMoveController.php Project: truSense/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $post = id(new PhamePostQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
     if (!$post) {
         return new Aphront404Response();
     }
     $view_uri = $post->getViewURI();
     $v_blog = $post->getBlog()->getPHID();
     if ($request->isFormPost()) {
         $v_blog = $request->getStr('blogPHID');
         $xactions = array();
         $xactions[] = id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_BLOG)->setNewValue($v_blog);
         $editor = id(new PhamePostEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
         $editor->applyTransactions($post, $xactions);
         $view_uri = $post->getViewURI();
         return id(new AphrontRedirectResponse())->setURI($view_uri . '?moved=1');
     }
     $blogs = id(new PhameBlogQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     $options = mpull($blogs, 'getName', 'getPHID');
     asort($options);
     $form = id(new PHUIFormLayoutView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Blog'))->setName('blogPHID')->setOptions($options)->setValue($v_blog));
     return $this->newDialog()->setTitle(pht('Move Post'))->appendChild($form)->addSubmitButton(pht('Move Post'))->addCancelButton($view_uri);
 }
Example #23
Show file File: DrydockRepositoryOperationListController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $query_key = $request->getURIData('queryKey');
     $engine = new DrydockRepositoryOperationSearchEngine();
     $controller = id(new PhabricatorApplicationSearchController())->setQueryKey($query_key)->setSearchEngine($engine)->setNavigation($this->buildSideNavView());
     return $this->delegateToController($controller);
 }
Example #24
Show file File: FundInitiativeSearchEngine.php Project: truSense/phabricator
0
 public function buildSavedQueryFromRequest(AphrontRequest $request)
 {
     $saved = new PhabricatorSavedQuery();
     $saved->setParameter('ownerPHIDs', $this->readUsersFromRequest($request, 'owners'));
     $saved->setParameter('statuses', $this->readListFromRequest($request, 'statuses'));
     return $saved;
 }
Example #25
Show file File: PhabricatorEditEngineConfigurationDisableController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $config = $this->loadConfigForEdit();
     if (!$config) {
         return id(new Aphront404Response());
     }
     $engine_key = $config->getEngineKey();
     $key = $config->getIdentifier();
     $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
     $type = PhabricatorEditEngineConfigurationTransaction::TYPE_DISABLE;
     if ($request->isFormPost()) {
         $xactions = array();
         $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type)->setNewValue(!$config->getIsDisabled());
         $editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
         $editor->applyTransactions($config, $xactions);
         return id(new AphrontRedirectResponse())->setURI($cancel_uri);
     }
     if ($config->getIsDisabled()) {
         $title = pht('Enable Form');
         $body = pht('Enable this form? Users who can see it will be able to use it to ' . 'create objects.');
         $button = pht('Enable Form');
     } else {
         $title = pht('Disable Form');
         $body = pht('Disable this form? Users will no longer be able to use it.');
         $button = pht('Disable Form');
     }
     return $this->newDialog()->setTitle($title)->appendParagraph($body)->addSubmitButton($button)->addCancelbutton($cancel_uri);
 }
Example #26
Show file File: AlmanacServiceViewController.php Project: truSense/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $name = $request->getURIData('name');
     $service = id(new AlmanacServiceQuery())->setViewer($viewer)->withNames(array($name))->executeOne();
     if (!$service) {
         return new Aphront404Response();
     }
     $title = pht('Service %s', $service->getName());
     $property_list = $this->buildPropertyList($service);
     $action_list = $this->buildActionList($service);
     $property_list->setActionList($action_list);
     $header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($service->getName())->setPolicyObject($service);
     $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($property_list);
     $messages = $service->getServiceType()->getStatusMessages($service);
     if ($messages) {
         $box->setFormErrors($messages);
     }
     if ($service->getIsLocked()) {
         $this->addLockMessage($box, pht('This service is locked, and can not be edited.'));
     }
     $bindings = $this->buildBindingList($service);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($service->getName());
     $timeline = $this->buildTransactionTimeline($service, new AlmanacServiceTransactionQuery());
     $timeline->setShouldTerminate(true);
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($box, $bindings, $this->buildAlmanacPropertiesTable($service), $timeline));
 }
Example #27
Show file File: PhabricatorConfigHTTPParameterTypesModule.php Project: pugong/phabricator
0
 public function renderModuleStatus(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $types = AphrontHTTPParameterType::getAllTypes();
     $table = id(new PhabricatorHTTPParameterTypeTableView())->setHTTPParameterTypes($types);
     return id(new PHUIObjectBoxView())->setHeaderText(pht('HTTP Parameter Types'))->setTable($table);
 }
Example #28
Show file File: PonderQuestionCommentController.php Project: pugong/phabricator
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     if (!$request->isFormPost()) {
         return new Aphront400Response();
     }
     $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$question) {
         return new Aphront404Response();
     }
     $is_preview = $request->isPreviewRequest();
     //    $draft = PhabricatorDraft::buildFromRequest($request);
     $qid = $question->getID();
     $view_uri = "/Q{$qid}";
     $xactions = array();
     $xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PonderQuestionTransactionComment())->setContent($request->getStr('comment')));
     $editor = id(new PonderQuestionEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
     try {
         $xactions = $editor->applyTransactions($question, $xactions);
     } catch (PhabricatorApplicationTransactionNoEffectException $ex) {
         return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
     }
     //    if ($draft) {
     //      $draft->replaceOrDelete();
     //    }
     if ($request->isAjax() && $is_preview) {
         return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
     } else {
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
 }