public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $query = id(new PhabricatorProjectQuery())->setViewer($user)->needMembers(true)->needWatchers(true)->needImages(true)->needSlugs(true);
     $id = $request->getURIData('id');
     $slug = $request->getURIData('slug');
     if ($slug) {
         $query->withSlugs(array($slug));
     } else {
         $query->withIDs(array($id));
     }
     $project = $query->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     if ($slug && $slug != $project->getPrimarySlug()) {
         return id(new AphrontRedirectResponse())->setURI('/tag/' . $project->getPrimarySlug() . '/');
     }
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($project->getPHID()));
     $query->setLimit(50);
     $query->setViewer($request->getUser());
     $stories = $query->execute();
     $feed = $this->renderStories($stories);
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Project Activity'))->appendChild($feed);
     $nav = $this->buildIconNavView($project);
     $nav->selectFilter("feed/{$id}/");
     $nav->appendChild($box);
     return $this->buildApplicationPage($nav, array('title' => $project->getName()));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $querykey = $request->getURIData('queryKey');
     $merchant_id = $request->getURIData('merchantID');
     $account_id = $request->getURIData('accountID');
     $engine = new PhortuneSubscriptionSearchEngine();
     if ($merchant_id) {
         $merchant = id(new PhortuneMerchantQuery())->setViewer($viewer)->withIDs(array($merchant_id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$merchant) {
             return new Aphront404Response();
         }
         $this->merchant = $merchant;
         $viewer->grantAuthority($merchant);
         $engine->setMerchant($merchant);
     } else {
         if ($account_id) {
             $account = id(new PhortuneAccountQuery())->setViewer($viewer)->withIDs(array($account_id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
             if (!$account) {
                 return new Aphront404Response();
             }
             $this->account = $account;
             $engine->setAccount($account);
         } else {
             return new Aphront404Response();
         }
     }
     $controller = id(new PhabricatorApplicationSearchController())->setQueryKey($querykey)->setSearchEngine($engine)->setNavigation($this->buildSideNavView());
     return $this->delegateToController($controller);
 }
 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;
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$event) {
         return new Aphront404Response();
     }
     $response = $this->newImportedEventResponse($event);
     if ($response) {
         return $response;
     }
     $cancel_uri = $event->getURI();
     if (!$event->getIsUserAttending($viewer->getPHID())) {
         return $this->newDialog()->setTitle(pht('Not Attending Event'))->appendParagraph(pht('You can not change your display availability for events you ' . 'are not attending.'))->addCancelButton($cancel_uri);
     }
     // TODO: This endpoint currently only works via AJAX. It would be vaguely
     // nice to provide a plain HTML version of the workflow where we return
     // a dialog with a vanilla <select /> in it for cases where all the JS
     // breaks.
     $request->validateCSRF();
     $invitee = $event->getInviteeForPHID($viewer->getPHID());
     $map = PhabricatorCalendarEventInvitee::getAvailabilityMap();
     $new_availability = $request->getURIData('availability');
     if (isset($map[$new_availability])) {
         $invitee->setAvailability($new_availability)->save();
         // Invalidate the availability cache.
         $viewer->writeAvailabilityCache(array(), null);
     }
     return id(new AphrontRedirectResponse())->setURI($cancel_uri);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $status = $request->getURIData('status');
     $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$question) {
         return new Aphront404Response();
     }
     switch ($status) {
         case 'open':
             $status = PonderQuestionStatus::STATUS_OPEN;
             break;
         case 'close':
             $status = PonderQuestionStatus::STATUS_CLOSED;
             break;
         default:
             return new Aphront400Response();
     }
     $xactions = array();
     $xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_STATUS)->setNewValue($status);
     $editor = id(new PonderQuestionEditor())->setActor($viewer)->setContentSourceFromRequest($request);
     $editor->applyTransactions($question, $xactions);
     return id(new AphrontRedirectResponse())->setURI('/Q' . $question->getID());
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $phid = $request->getURIData('phid');
     $capability = $request->getURIData('capability');
     $object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     if (!$object) {
         return new Aphront404Response();
     }
     $policies = PhabricatorPolicyQuery::loadPolicies($viewer, $object);
     $policy = idx($policies, $capability);
     if (!$policy) {
         return new Aphront404Response();
     }
     $handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     $object_name = $handle->getName();
     $object_uri = nonempty($handle->getURI(), '/');
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setClass('aphront-access-dialog aphront-policy-explain-dialog')->setTitle(pht('Policy Details: %s', $object_name))->addCancelButton($object_uri, pht('Done'));
     $space_section = $this->buildSpaceSection($object, $policy, $capability);
     $extended_section = $this->buildExtendedSection($object, $capability);
     $exceptions_section = $this->buildExceptionsSection($object, $capability);
     $object_section = $this->buildObjectSection($object, $policy, $capability, $handle);
     $dialog->appendChild(array($space_section, $extended_section, $exceptions_section, $object_section));
     return $dialog;
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$blueprint) {
         return new Aphront404Response();
     }
     $is_disable = $request->getURIData('action') == 'disable';
     $id = $blueprint->getID();
     $cancel_uri = $this->getApplicationURI("blueprint/{$id}/");
     if ($request->isFormPost()) {
         $xactions = array();
         $xactions[] = id(new DrydockBlueprintTransaction())->setTransactionType(DrydockBlueprintTransaction::TYPE_DISABLED)->setNewValue($is_disable ? 1 : 0);
         $editor = id(new DrydockBlueprintEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($blueprint, $xactions);
         return id(new AphrontRedirectResponse())->setURI($cancel_uri);
     }
     if ($is_disable) {
         $title = pht('Disable Blueprint');
         $body = pht('If you disable this blueprint, Drydock will no longer use it to ' . 'allocate new resources. Existing resources will not be affected.');
         $button = pht('Disable Blueprint');
     } else {
         $title = pht('Enable Blueprint');
         $body = pht('If you enable this blueprint, Drydock will start using it to ' . 'allocate new resources.');
         $button = pht('Enable Blueprint');
     }
     return $this->newDialog()->setTitle($title)->appendParagraph($body)->addCancelButton($cancel_uri)->addSubmitButton($button);
 }
    public function handleRequest(AphrontRequest $request)
    {
        $engine_key = $request->getURIData('engineKey');
        $this->setEngineKey($engine_key);
        $key = $request->getURIData('key');
        $viewer = $this->getViewer();
        $config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
        if (!$config) {
            return id(new Aphront404Response());
        }
        $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
        if ($request->isFormPost()) {
            $xactions = array();
            $locks = $request->getArr('locks');
            $type_locks = PhabricatorEditEngineConfigurationTransaction::TYPE_LOCKS;
            $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type_locks)->setNewValue($locks);
            $editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
            $editor->applyTransactions($config, $xactions);
            return id(new AphrontRedirectResponse())->setURI($cancel_uri);
        }
        $engine = $config->getEngine();
        $fields = $engine->getFieldsForConfig($config);
        $help = pht(<<<EOTEXT
**Locked** fields are visible in the form, but their values can not be changed
by the user.

**Hidden** fields are not visible in the form.

Any assigned default values are still respected, even if the field is locked
or hidden.
EOTEXT
);
        $form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions($help);
        $locks = $config->getFieldLocks();
        $lock_visible = PhabricatorEditEngineConfiguration::LOCK_VISIBLE;
        $lock_locked = PhabricatorEditEngineConfiguration::LOCK_LOCKED;
        $lock_hidden = PhabricatorEditEngineConfiguration::LOCK_HIDDEN;
        $map = array($lock_visible => pht('Visible'), $lock_locked => pht("🔒 Locked"), $lock_hidden => pht("✘ Hidden"));
        foreach ($fields as $field) {
            if (!$field->getIsLockable()) {
                continue;
            }
            $key = $field->getKey();
            $label = $field->getLabel();
            if (!strlen($label)) {
                $label = $key;
            }
            if ($field->getIsHidden()) {
                $value = $lock_hidden;
            } else {
                if ($field->getIsLocked()) {
                    $value = $lock_locked;
                } else {
                    $value = $lock_visible;
                }
            }
            $form->appendControl(id(new AphrontFormSelectControl())->setName('locks[' . $key . ']')->setLabel($label)->setValue($value)->setOptions($map));
        }
        return $this->newDialog()->setTitle(pht('Lock / Hide Fields'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendForm($form)->addSubmitButton(pht('Save Changes'))->addCancelButton($cancel_uri);
    }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $dblob = $request->getURIData('dblob');
     $fragment = id(new PhragmentFragmentQuery())->setViewer($viewer)->withPaths(array($dblob))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if ($fragment === null) {
         return new Aphront404Response();
     }
     $version = id(new PhragmentFragmentVersionQuery())->setViewer($viewer)->withFragmentPHIDs(array($fragment->getPHID()))->withIDs(array($id))->executeOne();
     if ($version === null) {
         return new Aphront404Response();
     }
     if ($request->isDialogFormPost()) {
         $file_phid = $version->getFilePHID();
         $file = null;
         if ($file_phid !== null) {
             $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($file_phid))->executeOne();
             if ($file === null) {
                 throw new Exception(pht('The file associated with this version was not found.'));
             }
         }
         if ($file === null) {
             $fragment->deleteFile($viewer);
         } else {
             $fragment->updateFromFile($viewer, $file);
         }
         return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/history/' . $dblob));
     }
     return $this->createDialog($fragment, $version);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $query = id(new PhabricatorProjectQuery())->setViewer($user)->needMembers(true)->needWatchers(true)->needImages(true)->needSlugs(true);
     $id = $request->getURIData('id');
     $slug = $request->getURIData('slug');
     if ($slug) {
         $query->withSlugs(array($slug));
     } else {
         $query->withIDs(array($id));
     }
     $project = $query->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     if ($slug && $slug != $project->getPrimarySlug()) {
         return id(new AphrontRedirectResponse())->setURI('/tag/' . $project->getPrimarySlug() . '/');
     }
     require_celerity_resource('phabricator-profile-css');
     $query = new PhabricatorFeedQuery();
     $query->setFilterPHIDs(array($project->getPHID()));
     $query->setLimit(50);
     $query->setViewer($request->getUser());
     $stories = $query->execute();
     $feed = $this->renderStories($stories);
     $content = phutil_tag_div('phabricator-project-feed', $feed);
     $nav = $this->buildIconNavView($project);
     $nav->selectFilter("feed/{$id}/");
     $nav->appendChild($content);
     return $this->buildApplicationPage($nav, array('title' => $project->getName()));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $this->database = $request->getURIData('database');
     $this->table = $request->getURIData('table');
     $this->column = $request->getURIData('column');
     $this->key = $request->getURIData('key');
     $query = $this->buildSchemaQuery();
     $actual = $query->loadActualSchema();
     $expect = $query->loadExpectedSchema();
     $comp = $query->buildComparisonSchema($expect, $actual);
     if ($this->column) {
         return $this->renderColumn($comp, $expect, $actual, $this->database, $this->table, $this->column);
     } else {
         if ($this->key) {
             return $this->renderKey($comp, $expect, $actual, $this->database, $this->table, $this->key);
         } else {
             if ($this->table) {
                 return $this->renderTable($comp, $expect, $actual, $this->database, $this->table);
             } else {
                 if ($this->database) {
                     return $this->renderDatabase($comp, $expect, $actual, $this->database);
                 } else {
                     return $this->renderServer($comp, $expect, $actual);
                 }
             }
         }
     }
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $key = $request->getURIData('key');
     if ($id) {
         $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$user) {
             return new Aphront404Response();
         }
         $this->user = $user;
     } else {
         $this->user = $viewer;
     }
     $panels = $this->buildPanels();
     $nav = $this->renderSideNav($panels);
     $key = $nav->selectFilter($key, head($panels)->getPanelKey());
     $panel = $panels[$key];
     $panel->setUser($this->getUser());
     $panel->setViewer($viewer);
     $response = $panel->processRequest($request);
     if ($response instanceof AphrontResponse) {
         return $response;
     }
     $crumbs = $this->buildApplicationCrumbs();
     if (!$this->isSelf()) {
         $crumbs->addTextCrumb($this->getUser()->getUsername(), '/p/' . $this->getUser()->getUsername() . '/');
     }
     $crumbs->addTextCrumb($panel->getPanelName());
     $nav->appendChild(array($crumbs, $response));
     return $this->buildApplicationPage($nav, array('title' => $panel->getPanelName()));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $project_id = $request->getURIData('projectID');
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW))->withIDs(array($project_id))->needImages(true)->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $this->setProject($project);
     $column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
     if (!$column) {
         return new Aphront404Response();
     }
     $timeline = $this->buildTransactionTimeline($column, new PhabricatorProjectColumnTransactionQuery());
     $timeline->setShouldTerminate(true);
     $title = pht('%s', $column->getDisplayName());
     $header = $this->buildHeaderView($column);
     $actions = $this->buildActionView($column);
     $properties = $this->buildPropertyView($column, $actions);
     $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $nav = $this->buildIconNavView($project);
     $nav->appendChild($box);
     $nav->appendChild($timeline);
     return $this->buildApplicationPage($nav, array('title' => $title));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $engine_key = $request->getURIData('engineKey');
     $this->setEngineKey($engine_key);
     $key = $request->getURIData('key');
     $viewer = $this->getViewer();
     $config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->executeOne();
     if (!$config) {
         return id(new Aphront404Response());
     }
     $is_concrete = (bool) $config->getID();
     $actions = $this->buildActionView($config);
     $properties = $this->buildPropertyView($config)->setActionList($actions);
     $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($config)->setHeader(pht('Edit Form: %s', $config->getDisplayName()));
     $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $crumbs = $this->buildApplicationCrumbs();
     if ($is_concrete) {
         $crumbs->addTextCrumb(pht('Form %d', $config->getID()));
     } else {
         $crumbs->addTextCrumb(pht('Builtin'));
     }
     if ($is_concrete) {
         $timeline = $this->buildTransactionTimeline($config, new PhabricatorEditEngineConfigurationTransactionQuery());
         $timeline->setShouldTerminate(true);
     } else {
         $timeline = null;
     }
     return $this->newPage()->setCrumbs($crumbs)->appendChild(array($box, $timeline));
 }
 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_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$post) {
         return new Aphront404Response();
     }
     $cancel_uri = $post->getViewURI();
     $action = $request->getURIData('action');
     $is_publish = $action == 'publish';
     if ($request->isFormPost()) {
         $xactions = array();
         if ($is_publish) {
             $new_value = PhameConstants::VISIBILITY_PUBLISHED;
         } else {
             $new_value = PhameConstants::VISIBILITY_DRAFT;
         }
         $xactions[] = id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY)->setNewValue($new_value);
         id(new PhamePostEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($post, $xactions);
         return id(new AphrontRedirectResponse())->setURI($cancel_uri);
     }
     if ($is_publish) {
         $title = pht('Publish Post');
         $body = pht('This post will go live once you publish it.');
         $button = pht('Publish');
     } else {
         $title = pht('Unpublish Post');
         $body = pht('This post will revert to draft status and no longer be visible ' . 'to other users.');
         $button = pht('Unpublish');
     }
     return $this->newDialog()->setTitle($title)->appendParagraph($body)->addSubmitButton($button)->addCancelButton($cancel_uri);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $action = $request->getURIData('action');
     $rule = id(new HeraldRuleQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$rule) {
         return new Aphront404Response();
     }
     if ($rule->isGlobalRule()) {
         $this->requireApplicationCapability(HeraldManageGlobalRulesCapability::CAPABILITY);
     }
     $view_uri = $this->getApplicationURI("rule/{$id}/");
     $is_disable = $action === 'disable';
     if ($request->isFormPost()) {
         $xaction = id(new HeraldRuleTransaction())->setTransactionType(HeraldRuleTransaction::TYPE_DISABLE)->setNewValue($is_disable);
         id(new HeraldRuleEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->applyTransactions($rule, array($xaction));
         return id(new AphrontRedirectResponse())->setURI($view_uri);
     }
     if ($is_disable) {
         $title = pht('Really archive this rule?');
         $body = pht('This rule will no longer activate.');
         $button = pht('Archive Rule');
     } else {
         $title = pht('Really activate this rule?');
         $body = pht('This rule will become active again.');
         $button = pht('Activate Rule');
     }
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild($body)->addSubmitButton($button)->addCancelButton($view_uri);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $project_id = $request->getURIData('projectID');
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW))->withIDs(array($project_id))->needImages(true)->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $this->setProject($project);
     $project_id = $project->getID();
     $column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
     if (!$column) {
         return new Aphront404Response();
     }
     $timeline = $this->buildTransactionTimeline($column, new PhabricatorProjectColumnTransactionQuery());
     $timeline->setShouldTerminate(true);
     $title = $column->getDisplayName();
     $header = $this->buildHeaderView($column);
     $actions = $this->buildActionView($column);
     $properties = $this->buildPropertyView($column, $actions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Workboard'), "/project/board/{$project_id}/");
     $crumbs->addTextCrumb(pht('Column: %s', $title));
     $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     $nav = $this->getProfileMenu();
     return $this->newPage()->setTitle($title)->setNavigation($nav)->setCrumbs($crumbs)->appendChild(array($box, $timeline));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $issue = $request->getURIData('key');
     $verb = $request->getURIData('verb');
     $issue_uri = $this->getApplicationURI('issue/' . $issue . '/');
     if ($request->isDialogFormPost()) {
         $this->manageApplication($issue);
         return id(new AphrontRedirectResponse())->setURI($issue_uri);
     }
     if ($verb == 'ignore') {
         $title = pht('Really ignore this setup issue?');
         $submit_title = pht('Ignore');
         $body = pht("You can ignore an issue if you don't want to fix it, or plan to " . "fix it later. Ignored issues won't appear on every page but will " . "still be shown in the list of open issues.");
     } else {
         if ($verb == 'unignore') {
             $title = pht('Unignore this setup issue?');
             $submit_title = pht('Unignore');
             $body = pht('This issue will no longer be suppressed, and will return to its ' . 'rightful place as a global setup warning.');
         } else {
             throw new Exception(pht('Unrecognized verb: %s', $verb));
         }
     }
     $dialog = id(new AphrontDialogView())->setUser($request->getUser())->setTitle($title)->appendChild($body)->addSubmitButton($submit_title)->addCancelButton($issue_uri);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $phid = $request->getURIData('phid');
     $action = $request->getURIData('action');
     if (!$request->isFormPost()) {
         return new Aphront400Response();
     }
     switch ($action) {
         case 'add':
             $is_add = true;
             break;
         case 'delete':
             $is_add = false;
             break;
         default:
             return new Aphront400Response();
     }
     $handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     if (phid_get_type($phid) == PhabricatorProjectProjectPHIDType::TYPECONST) {
         // TODO: This is a big hack, but a weak argument for adding some kind
         // of "load for role" feature to ObjectQuery, and also not a really great
         // argument for adding some kind of "load extra stuff" feature to
         // SubscriberInterface. Do this for now and wait for the best way forward
         // to become more clear?
         $object = id(new PhabricatorProjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->needWatchers(true)->executeOne();
     } else {
         $object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     }
     if (!$object instanceof PhabricatorSubscribableInterface) {
         return $this->buildErrorResponse(pht('Bad Object'), pht('This object is not subscribable.'), $handle->getURI());
     }
     if ($object->isAutomaticallySubscribed($viewer->getPHID())) {
         return $this->buildErrorResponse(pht('Automatically Subscribed'), pht('You are automatically subscribed to this object.'), $handle->getURI());
     }
     if ($object instanceof PhabricatorApplicationTransactionInterface) {
         if ($is_add) {
             $xaction_value = array('+' => array($viewer->getPHID()));
         } else {
             $xaction_value = array('-' => array($viewer->getPHID()));
         }
         $xaction = id($object->getApplicationTransactionTemplate())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue($xaction_value);
         $editor = id($object->getApplicationTransactionEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request);
         $editor->applyTransactions($object->getApplicationTransactionObject(), array($xaction));
     } else {
         // TODO: Eventually, get rid of this once everything implements
         // PhabriatorApplicationTransactionInterface.
         $editor = id(new PhabricatorSubscriptionsEditor())->setActor($viewer)->setObject($object);
         if ($is_add) {
             $editor->subscribeExplicit(array($viewer->getPHID()), $explicit = true);
         } else {
             $editor->unsubscribe(array($viewer->getPHID()));
         }
         $editor->save();
     }
     // TODO: We should just render the "Unsubscribe" action and swap it out
     // in the document for Ajax requests.
     return id(new AphrontReloadResponse())->setURI($handle->getURI());
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $sequence = $request->getURIData('sequence');
     $timeline = null;
     $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$event) {
         return new Aphront404Response();
     }
     if ($sequence) {
         $result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $sequence);
         if ($result) {
             $parent_event = $event;
             $event = $result;
             $event->attachParentEvent($parent_event);
             return id(new AphrontRedirectResponse())->setURI('/E' . $result->getID());
         } else {
             if ($sequence && $event->getIsRecurring()) {
                 $parent_event = $event;
                 $event = $event->generateNthGhost($sequence, $viewer);
                 $event->attachParentEvent($parent_event);
             } else {
                 if ($sequence) {
                     return new Aphront404Response();
                 }
             }
         }
         $title = $event->getMonogram() . ' (' . $sequence . ')';
         $page_title = $title . ' ' . $event->getName();
         $crumbs = $this->buildApplicationCrumbs();
         $crumbs->addTextCrumb($title, '/' . $event->getMonogram() . '/' . $sequence);
     } else {
         $title = 'E' . $event->getID();
         $page_title = $title . ' ' . $event->getName();
         $crumbs = $this->buildApplicationCrumbs();
         $crumbs->addTextCrumb($title);
         $crumbs->setBorder(true);
     }
     if (!$event->getIsGhostEvent()) {
         $timeline = $this->buildTransactionTimeline($event, new PhabricatorCalendarEventTransactionQuery());
     }
     $header = $this->buildHeaderView($event);
     $actions = $this->buildActionView($event);
     $properties = $this->buildPropertyListView($event);
     $details = $this->buildPropertySection($event);
     $description = $this->buildDescriptionView($event);
     $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
     $add_comment_header = $is_serious ? pht('Add Comment') : pht('Add To Plate');
     $draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID());
     if ($sequence) {
         $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/' . $sequence . '/');
     } else {
         $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/');
     }
     $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($event->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment'));
     $view = id(new PHUITwoColumnView())->setHeader($header)->setMainColumn($timeline)->setPropertyList($properties)->addPropertySection(pht('DETAILS'), $details)->addPropertySection(pht('DESCRIPTION'), $description)->setActionList($actions);
     return $this->newPage()->setTitle($page_title)->setCrumbs($crumbs)->setPageObjectPHIDs(array($event->getPHID()))->appendChild(array($view));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $action = $request->getURIData('action');
     $id = $request->getURIData('requestID');
     $viewer = $request->getViewer();
     $request->validateCSRF();
     $pull = id(new ReleephRequestQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$pull) {
         return new Aphront404Response();
     }
     $branch = $pull->getBranch();
     $product = $branch->getProduct();
     $origin_uri = '/' . $pull->getMonogram();
     $editor = id(new ReleephRequestTransactionalEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
     $xactions = array();
     switch ($action) {
         case 'want':
         case 'pass':
             static $action_map = array('want' => ReleephRequest::INTENT_WANT, 'pass' => ReleephRequest::INTENT_PASS);
             $intent = $action_map[$action];
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isAuthoritative', $product->isAuthoritative($viewer))->setNewValue($intent);
             break;
         case 'mark-manually-picked':
         case 'mark-manually-reverted':
             if ($pull->getRequestUserPHID() === $viewer->getPHID() || $product->isAuthoritative($viewer)) {
                 // We're all good!
             } else {
                 throw new Exception(pht("Bug! Only pushers or the requestor can manually change a " . "request's in-branch status!"));
             }
             if ($action === 'mark-manually-picked') {
                 $in_branch = 1;
                 $intent = ReleephRequest::INTENT_WANT;
             } else {
                 $in_branch = 0;
                 $intent = ReleephRequest::INTENT_PASS;
             }
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isManual', true)->setMetadataValue('isAuthoritative', true)->setNewValue($intent);
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH)->setNewValue($in_branch);
             break;
         default:
             throw new Exception(pht('Unknown or unimplemented action %s.', $action));
     }
     $editor->applyTransactions($pull, $xactions);
     if ($request->getBool('render')) {
         $field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW);
         $field_list->setViewer($viewer)->readFieldsFromStorage($pull);
         // TODO: This should be more modern and general.
         $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
         foreach ($field_list->getFields() as $field) {
             if ($field->shouldMarkup()) {
                 $field->setMarkupEngine($engine);
             }
         }
         $engine->process();
         $pull_box = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull)->setIsListView(true);
         return id(new AphrontAjaxResponse())->setContent(array('markup' => hsprintf('%s', $pull_box)));
     }
     return id(new AphrontRedirectResponse())->setURI($origin_uri);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $phid = $request->getURIData('phid');
     $attach_type = $request->getURIData('type');
     $action = $request->getURIData('action', self::ACTION_ATTACH);
     $handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($phid))->executeOne();
     $object_type = $handle->getType();
     $object = id(new PhabricatorObjectQuery())->setViewer($user)->withPHIDs(array($phid))->executeOne();
     if (!$object) {
         return new Aphront404Response();
     }
     $edge_type = null;
     switch ($action) {
         case self::ACTION_EDGE:
         case self::ACTION_DEPENDENCIES:
         case self::ACTION_BLOCKS:
         case self::ACTION_ATTACH:
             $edge_type = $this->getEdgeType($object_type, $attach_type);
             break;
     }
     if ($request->isFormPost()) {
         $phids = explode(';', $request->getStr('phids'));
         $phids = array_filter($phids);
         $phids = array_values($phids);
         if ($edge_type) {
             if (!$object instanceof PhabricatorApplicationTransactionInterface) {
                 throw new Exception(pht('Expected object ("%s") to implement interface "%s".', get_class($object), 'PhabricatorApplicationTransactionInterface'));
             }
             $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($phid, $edge_type);
             $add_phids = $phids;
             $rem_phids = array_diff($old_phids, $add_phids);
             $txn_editor = $object->getApplicationTransactionEditor()->setActor($user)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $txn_template = $object->getApplicationTransactionTemplate()->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edge_type)->setNewValue(array('+' => array_fuse($add_phids), '-' => array_fuse($rem_phids)));
             try {
                 $txn_editor->applyTransactions($object->getApplicationTransactionObject(), array($txn_template));
             } catch (PhabricatorEdgeCycleException $ex) {
                 $this->raiseGraphCycleException($ex);
             }
             return id(new AphrontReloadResponse())->setURI($handle->getURI());
         } else {
             return $this->performMerge($object, $handle, $phids);
         }
     } else {
         if ($edge_type) {
             $phids = PhabricatorEdgeQuery::loadDestinationPHIDs($phid, $edge_type);
         } else {
             // This is a merge.
             $phids = array();
         }
     }
     $strings = $this->getStrings($attach_type, $action);
     $handles = $this->loadViewerHandles($phids);
     $obj_dialog = new PhabricatorObjectSelectorDialog();
     $obj_dialog->setUser($user)->setHandles($handles)->setFilters($this->getFilters($strings, $attach_type))->setSelectedFilter($strings['selected'])->setExcluded($phid)->setCancelURI($handle->getURI())->setSearchURI('/search/select/' . $attach_type . '/' . $action . '/')->setTitle($strings['title'])->setHeader($strings['header'])->setButtonText($strings['button'])->setInstructions($strings['instructions']);
     $dialog = $obj_dialog->buildDialog();
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $aid = $request->getURIData('aid');
     $bid = $request->getURIData('bid');
     // If "aid" is "x", then it means the user wants to generate
     // a patch of an empty file to the version specified by "bid".
     $ids = array($aid, $bid);
     if ($aid === 'x') {
         $ids = array($bid);
     }
     $versions = id(new PhragmentFragmentVersionQuery())->setViewer($viewer)->withIDs($ids)->execute();
     $version_a = null;
     if ($aid !== 'x') {
         $version_a = idx($versions, $aid, null);
         if ($version_a === null) {
             return new Aphront404Response();
         }
     }
     $version_b = idx($versions, $bid, null);
     if ($version_b === null) {
         return new Aphront404Response();
     }
     $file_phids = array();
     if ($version_a !== null) {
         $file_phids[] = $version_a->getFilePHID();
     }
     $file_phids[] = $version_b->getFilePHID();
     $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs($file_phids)->execute();
     $files = mpull($files, null, 'getPHID');
     $file_a = null;
     if ($version_a != null) {
         $file_a = idx($files, $version_a->getFilePHID(), null);
     }
     $file_b = idx($files, $version_b->getFilePHID(), null);
     $patch = PhragmentPatchUtil::calculatePatch($file_a, $file_b);
     if ($patch === null) {
         // There are no differences between the two files, so we output
         // an empty patch.
         $patch = '';
     }
     $a_sequence = 'x';
     if ($version_a !== null) {
         $a_sequence = $version_a->getSequence();
     }
     $name = $version_b->getFragment()->getName() . '.' . $a_sequence . '.' . $version_b->getSequence() . '.patch';
     $return = $version_b->getURI();
     if ($request->getExists('return')) {
         $return = $request->getStr('return');
     }
     $result = PhabricatorFile::buildFromFileDataOrHash($patch, array('name' => $name, 'mime-type' => 'text/plain', 'ttl' => time() + 60 * 60 * 24));
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     $result->attachToObject($version_b->getFragmentPHID());
     unset($unguarded);
     return id(new AphrontRedirectResponse())->setURI($result->getDownloadURI($return));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $engine_key = $request->getURIData('engineKey');
     $this->setEngineKey($engine_key);
     $key = $request->getURIData('key');
     $viewer = $this->getViewer();
     $config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$config) {
         return id(new Aphront404Response());
     }
     $cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
     $engine = $config->getEngine();
     $fields = $engine->getFieldsForConfig($config);
     foreach ($fields as $key => $field) {
         if (!$field->getIsDefaultable()) {
             unset($fields[$key]);
             continue;
         }
     }
     foreach ($fields as $field) {
         $field->setIsEditDefaults(true);
     }
     if ($request->isFormPost()) {
         $xactions = array();
         foreach ($fields as $field) {
             $field->readValueFromSubmit($request);
         }
         $type = PhabricatorEditEngineConfigurationTransaction::TYPE_DEFAULT;
         $xactions = array();
         foreach ($fields as $field) {
             $new_value = $field->getValueForDefaults();
             $xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type)->setMetadataValue('field.key', $field->getKey())->setNewValue($new_value);
         }
         $editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
         $editor->applyTransactions($config, $xactions);
         return id(new AphrontRedirectResponse())->setURI($cancel_uri);
     }
     $title = pht('Edit Form Defaults');
     $form = id(new AphrontFormView())->setUser($viewer);
     foreach ($fields as $field) {
         $field->appendToForm($form);
     }
     $form->appendControl(id(new AphrontFormSubmitControl())->setValue(pht('Save Defaults'))->addCancelButton($cancel_uri));
     $info = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setErrors(array(pht('You are editing the default values for this form.')));
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Form'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Form %d', $config->getID()), $cancel_uri);
     $crumbs->addTextCrumb(pht('Edit Defaults'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Form Defaults'))->setHeaderIcon('fa-pencil');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($info, $box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
Ejemplo n.º 25
0
 protected function getRepositoryIdentifierFromRequest(AphrontRequest $request)
 {
     $identifier = $request->getURIData('repositoryCallsign');
     if (strlen($identifier)) {
         return $identifier;
     }
     $id = $request->getURIData('repositoryID');
     if (strlen($id)) {
         return (int) $id;
     }
     return null;
 }
 public function handleRequest(AphrontRequest $request)
 {
     $year = $request->getURIData('year');
     $month = $request->getURIData('month');
     $day = $request->getURIData('day');
     $engine = new PhabricatorCalendarEventSearchEngine();
     if ($month && $year) {
         $engine->setCalendarYearAndMonthAndDay($year, $month, $day);
     }
     $controller = id(new PhabricatorApplicationSearchController())->setQueryKey($request->getURIData('queryKey'))->setSearchEngine($engine)->setNavigation($this->buildSideNav());
     return $this->delegateToController($controller);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $this->id = $request->getURIData('id');
     $action = $request->getURIData('action');
     $request = $this->getRequest();
     $viewer = $request->getViewer();
     $declined_status = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
     $attending_status = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
     $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($this->id))->executeOne();
     if (!$event) {
         return new Aphront404Response();
     }
     $cancel_uri = '/E' . $event->getID();
     $validation_exception = null;
     $is_attending = $event->getIsUserAttending($viewer->getPHID());
     if ($request->isFormPost()) {
         $new_status = null;
         switch ($action) {
             case self::ACTION_ACCEPT:
                 $new_status = $attending_status;
                 break;
             case self::ACTION_JOIN:
                 if ($is_attending) {
                     $new_status = $declined_status;
                 } else {
                     $new_status = $attending_status;
                 }
                 break;
             case self::ACTION_DECLINE:
                 $new_status = $declined_status;
                 break;
         }
         $new_status = array($viewer->getPHID() => $new_status);
         $xaction = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorCalendarEventTransaction::TYPE_INVITE)->setNewValue($new_status);
         $editor = id(new PhabricatorCalendarEventEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
         try {
             $editor->applyTransactions($event, array($xaction));
             return id(new AphrontRedirectResponse())->setURI($cancel_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
         }
     }
     if ($action == self::ACTION_JOIN && !$is_attending || $action == self::ACTION_ACCEPT) {
         $title = pht('Join Event');
         $paragraph = pht('Would you like to join this event?');
         $submit = pht('Join');
     } else {
         $title = pht('Decline Event');
         $paragraph = pht('Would you like to decline this event?');
         $submit = pht('Decline');
     }
     return $this->newDialog()->setTitle($title)->setValidationException($validation_exception)->appendParagraph($paragraph)->addCancelButton($cancel_uri)->addSubmitButton($submit);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$event) {
         return new Aphront404Response();
     }
     $response = $this->newImportedEventResponse($event);
     if ($response) {
         return $response;
     }
     $cancel_uri = $event->getURI();
     $action = $request->getURIData('action');
     switch ($action) {
         case 'accept':
             $is_join = true;
             break;
         case 'decline':
             $is_join = false;
             break;
         default:
             $is_join = !$event->getIsUserAttending($viewer->getPHID());
             break;
     }
     $validation_exception = null;
     if ($request->isFormPost()) {
         if ($is_join) {
             $xaction_type = PhabricatorCalendarEventAcceptTransaction::TRANSACTIONTYPE;
         } else {
             $xaction_type = PhabricatorCalendarEventDeclineTransaction::TRANSACTIONTYPE;
         }
         $xaction = id(new PhabricatorCalendarEventTransaction())->setTransactionType($xaction_type)->setNewValue(true);
         $editor = id(new PhabricatorCalendarEventEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
         try {
             $editor->applyTransactions($event, array($xaction));
             return id(new AphrontRedirectResponse())->setURI($cancel_uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
         }
     }
     if ($is_join) {
         $title = pht('Join Event');
         $paragraph = pht('Would you like to join this event?');
         $submit = pht('Join');
     } else {
         $title = pht('Decline Event');
         $paragraph = pht('Would you like to decline this event?');
         $submit = pht('Decline');
     }
     return $this->newDialog()->setTitle($title)->setValidationException($validation_exception)->appendParagraph($paragraph)->addCancelButton($cancel_uri)->addSubmitButton($submit);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('branchID');
     $querykey = $request->getURIData('queryKey');
     $branch = id(new ReleephBranchQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$branch) {
         return new Aphront404Response();
     }
     $this->setBranch($branch);
     $controller = id(new PhabricatorApplicationSearchController())->setPreface($this->renderPreface())->setQueryKey($querykey)->setSearchEngine($this->getSearchEngine())->setNavigation($this->buildSideNavView());
     return $this->delegateToController($controller);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $revision_id = $request->getURIData('id');
     $strategy_class = $request->getURIData('strategy');
     $revision = id(new DifferentialRevisionQuery())->withIDs(array($revision_id))->setViewer($viewer)->executeOne();
     if (!$revision) {
         return new Aphront404Response();
     }
     if (is_subclass_of($strategy_class, 'DifferentialLandingStrategy')) {
         $this->pushStrategy = newv($strategy_class, array());
     } else {
         throw new Exception(pht("Strategy type must be a valid class name and must subclass " . "%s. '%s' is not a subclass of %s", 'DifferentialLandingStrategy', $strategy_class, 'DifferentialLandingStrategy'));
     }
     if ($request->isDialogFormPost()) {
         $response = null;
         $text = '';
         try {
             $response = $this->attemptLand($revision, $request);
             $title = pht('Success!');
             $text = pht('Revision was successfully landed.');
         } catch (Exception $ex) {
             $title = pht('Failed to land revision');
             if ($ex instanceof PhutilProxyException) {
                 $text = hsprintf('%s:<br><pre>%s</pre>', $ex->getMessage(), $ex->getPreviousException()->getMessage());
             } else {
                 $text = phutil_tag('pre', array(), $ex->getMessage());
             }
             $text = id(new PHUIInfoView())->appendChild($text);
         }
         if ($response instanceof AphrontDialogView) {
             $dialog = $response;
         } else {
             $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild(phutil_tag('p', array(), $text))->addCancelButton('/D' . $revision_id, pht('Done'));
         }
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     $is_disabled = $this->pushStrategy->isActionDisabled($viewer, $revision, $revision->getRepository());
     if ($is_disabled) {
         if (is_string($is_disabled)) {
             $explain = $is_disabled;
         } else {
             $explain = pht('This action is not currently enabled.');
         }
         $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht("Can't land revision"))->appendChild($explain)->addCancelButton('/D' . $revision_id);
         return id(new AphrontDialogResponse())->setDialog($dialog);
     }
     $prompt = hsprintf('%s<br><br>%s', pht('This will squash and rebase revision %s, and push it to ' . 'the default / master branch.', $revision_id), pht('It is an experimental feature and may not work.'));
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Land Revision %s?', $revision_id))->appendChild($prompt)->setSubmitURI($request->getRequestURI())->addSubmitButton(pht('Land it!'))->addCancelButton('/D' . $revision_id);
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }