public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $job = id(new PhabricatorWorkerBulkJobQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->executeOne(); if (!$job) { return new Aphront404Response(); } // If the user clicks "Continue" on a completed job, take them back to // whatever application sent them here. if ($request->getStr('done')) { if ($request->isFormPost()) { $done_uri = $job->getDoneURI(); return id(new AphrontRedirectResponse())->setURI($done_uri); } } $title = pht('Bulk Job %d', $job->getID()); if ($job->getStatus() == PhabricatorWorkerBulkJob::STATUS_CONFIRM) { $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $job, PhabricatorPolicyCapability::CAN_EDIT); if ($can_edit) { if ($request->isFormPost()) { $type_status = PhabricatorWorkerBulkJobTransaction::TYPE_STATUS; $xactions = array(); $xactions[] = id(new PhabricatorWorkerBulkJobTransaction())->setTransactionType($type_status)->setNewValue(PhabricatorWorkerBulkJob::STATUS_WAITING); $editor = id(new PhabricatorWorkerBulkJobEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->applyTransactions($job, $xactions); return id(new AphrontRedirectResponse())->setURI($job->getMonitorURI()); } else { return $this->newDialog()->setTitle(pht('Confirm Bulk Job'))->appendParagraph($job->getDescriptionForConfirm())->appendParagraph(pht('Start work on this bulk job?'))->addCancelButton($job->getManageURI(), pht('Details'))->addSubmitButton(pht('Start Work')); } } else { return $this->newDialog()->setTitle(pht('Waiting For Confirmation'))->appendParagraph(pht('This job is waiting for confirmation before work begins.'))->addCancelButotn($job->getManageURI(), pht('Details')); } } $dialog = $this->newDialog()->setTitle(pht('%s: %s', $title, $job->getStatusName()))->addCancelButton($job->getManageURI(), pht('Details')); switch ($job->getStatus()) { case PhabricatorWorkerBulkJob::STATUS_WAITING: $dialog->appendParagraph(pht('This job is waiting for tasks to be queued.')); break; case PhabricatorWorkerBulkJob::STATUS_RUNNING: $dialog->appendParagraph(pht('This job is running.')); break; case PhabricatorWorkerBulkJob::STATUS_COMPLETE: $dialog->appendParagraph(pht('This job is complete.')); break; } $counts = $job->loadTaskStatusCounts(); if ($counts) { $dialog->appendParagraph($this->renderProgress($counts)); } switch ($job->getStatus()) { case PhabricatorWorkerBulkJob::STATUS_COMPLETE: $dialog->addHiddenInput('done', true); $dialog->addSubmitButton(pht('Continue')); break; default: Javelin::initBehavior('bulk-job-reload'); break; } return $dialog; }
protected function extendOAuthEditForm(AphrontRequest $request, AphrontFormView $form, array $values, array $issues, $id_label, $secret_label) { $key_id = $this->getIDKey(); $key_secret = $this->getSecretKey(); $key_note = self::PROPERTY_NOTE; $v_id = $values[$key_id]; $v_secret = $values[$key_secret]; if ($v_secret) { $v_secret = str_repeat('*', strlen($v_secret)); } $v_note = $values[$key_note]; $e_id = idx($issues, $key_id, $request->isFormPost() ? null : true); $e_secret = idx($issues, $key_secret, $request->isFormPost() ? null : true); $form->appendChild(id(new AphrontFormTextControl())->setLabel($id_label)->setName($key_id)->setValue($v_id)->setError($e_id))->appendChild(id(new AphrontFormPasswordControl())->setLabel($secret_label)->setDisableAutocomplete(true)->setName($key_secret)->setValue($v_secret)->setError($e_secret))->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('OAuth App Notes'))->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setName($key_note)->setValue($v_note)); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne(); if (!$document) { return new Aphront404Response(); } $document_uri = PhrictionDocument::getSlugURI($document->getSlug()); $e_text = null; if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_DELETE)->setNewValue(true); $editor = id(new PhrictionTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true); try { $editor->applyTransactions($document, $xactions); return id(new AphrontRedirectResponse())->setURI($document_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $e_text = phutil_implode_html("\n", $ex->getErrorMessages()); } } if ($e_text) { $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Can Not Delete Document!'))->appendChild($e_text)->addCancelButton($document_uri); } else { $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Delete Document?'))->appendChild(pht('Really delete this document? You can recover it later by ' . 'reverting to a previous version.'))->addSubmitButton(pht('Delete'))->addCancelButton($document_uri); } return id(new AphrontDialogResponse())->setDialog($dialog); }
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); }
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)); }
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); }
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('/'); }
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)); }
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); }
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/view/' . $post->getID() . '/'; $view_uri = $this->getApplicationURI($view_uri); if ($request->isFormPost()) { $blog = id(new PhameBlogQuery())->setViewer($viewer)->withIDs(array($request->getInt('blog')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if ($blog) { $post->setBlogPHID($blog->getPHID()); $post->save(); return id(new AphrontRedirectResponse())->setURI($view_uri . '?moved=1'); } } $blogs = id(new PhameBlogQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->execute(); $options = mpull($blogs, 'getName', 'getID'); asort($options); $selected_value = null; if ($post && $post->getBlog()) { $selected_value = $post->getBlog()->getID(); } $form = id(new PHUIFormLayoutView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Blog'))->setName('blog')->setOptions($options)->setValue($selected_value)); return $this->newDialog()->setTitle(pht('Move Post'))->appendChild($form)->addSubmitButton(pht('Move Post'))->addCancelButton($view_uri); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); if (!$request->isFormPost()) { return new Aphront400Response(); } $document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->executeOne(); if (!$document) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $document_uri = $this->getApplicationURI('view/' . $document->getID()); $comment = $request->getStr('comment'); $xactions = array(); if (strlen($comment)) { $xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($comment)); } $editor = id(new LegalpadDocumentEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($document, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($document_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($document_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('branchID'); $branch = id(new ReleephBranchQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($id))->executeOne(); if (!$branch) { return new Aphront404Response(); } $this->setBranch($branch); $symbolic_name = $request->getStr('symbolicName', $branch->getSymbolicName()); if ($request->isFormPost()) { $existing_with_same_symbolic_name = id(new ReleephBranch())->loadOneWhere('id != %d AND releephProjectID = %d AND symbolicName = %s', $branch->getID(), $branch->getReleephProjectID(), $symbolic_name); $branch->openTransaction(); $branch->setSymbolicName($symbolic_name); if ($existing_with_same_symbolic_name) { $existing_with_same_symbolic_name->setSymbolicName(null)->save(); } $branch->save(); $branch->saveTransaction(); return id(new AphrontRedirectResponse())->setURI($this->getBranchViewURI($branch)); } $phids = array(); $phids[] = $creator_phid = $branch->getCreatedByUserPHID(); $phids[] = $cut_commit_phid = $branch->getCutPointCommitPHID(); $handles = id(new PhabricatorHandleQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute(); $form = id(new AphrontFormView())->setUser($request->getUser())->appendChild(id(new AphrontFormStaticControl())->setLabel(pht('Branch Name'))->setValue($branch->getName()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Cut Point'))->setValue($handles[$cut_commit_phid]->renderLink()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Created By'))->setValue($handles[$creator_phid]->renderLink()))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Symbolic Name'))->setName('symbolicName')->setValue($symbolic_name)->setCaption(pht('Mutable alternate name, for easy reference, (e.g. "LATEST")')))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getBranchViewURI($branch))->setValue(pht('Save Branch'))); $title = pht('Edit Branch %s', $branch->getDisplayNameWithDetail()); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Edit')); $box = id(new PHUIObjectBoxView())->setHeaderText($title)->appendChild($form); return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title)); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $done_uri = "/project/members/{$id}/"; if (!$project->supportsEditMembers()) { $copy = pht('Parent projects and milestones do not support adding ' . 'members. You can add members directly to any non-parent subproject.'); return $this->newDialog()->setTitle(pht('Unsupported Project'))->appendParagraph($copy)->addCancelButton($done_uri); } if ($request->isFormPost()) { $member_phids = $request->getArr('memberPHIDs'); $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue(array('+' => array_fuse($member_phids))); $editor = id(new PhabricatorProjectTransactionEditor($project))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setName('memberPHIDs')->setLabel(pht('Members'))->setDatasource(new PhabricatorPeopleDatasource())); return $this->newDialog()->setTitle(pht('Add Members'))->appendForm($form)->addCancelButton($done_uri)->addSubmitButton(pht('Add Members')); }
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'); $badge = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withIDs(array($id))->needRecipients(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$badge) { return new Aphront404Response(); } $recipient_phids = $badge->getRecipientPHIDs(); $remove_phid = $request->getStr('phid'); if (!in_array($remove_phid, $recipient_phids)) { return new Aphront404Response(); } $recipients_uri = $this->getApplicationURI('recipients/' . $badge->getID() . '/'); if ($request->isFormPost()) { $recipient_spec = array(); $recipient_spec['-'] = array($remove_phid => $remove_phid); $type_recipient = PhabricatorBadgeHasRecipientEdgeType::EDGECONST; $xactions = array(); $xactions[] = id(new PhabricatorBadgesTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_recipient)->setNewValue($recipient_spec); $editor = id(new PhabricatorBadgesEditor($badge))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($badge, $xactions); return id(new AphrontRedirectResponse())->setURI($recipients_uri); } $handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($remove_phid))->executeOne(); $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Really Revoke Badge?'))->appendParagraph(pht('Really revoke the badge "%s" from %s?', phutil_tag('strong', array(), $badge->getName()), phutil_tag('strong', array(), $handle->getName())))->addCancelButton($recipients_uri)->addSubmitButton(pht('Revoke Badge')); return $dialog; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $export = id(new PhabricatorCalendarExportQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$export) { return new Aphront404Response(); } $export_uri = $export->getURI(); $is_disable = !$export->getIsDisabled(); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorCalendarExportTransaction())->setTransactionType(PhabricatorCalendarExportDisableTransaction::TRANSACTIONTYPE)->setNewValue($is_disable ? 1 : 0); $editor = id(new PhabricatorCalendarExportEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request); $editor->applyTransactions($export, $xactions); return id(new AphrontRedirectResponse())->setURI($export_uri); } if ($is_disable) { $title = pht('Disable Export'); $body = pht('Disable this export? The export URI will no longer function.'); $button = pht('Disable Export'); } else { $title = pht('Enable Export'); $body = pht('Enable this export? Anyone who knows the export URI will be able ' . 'to export the data.'); $button = pht('Enable Export'); } return $this->newDialog()->setTitle($title)->appendParagraph($body)->addCancelButton($export_uri)->addSubmitButton($button); }
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); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$user) { return new Aphront404Response(); } $view_uri = '/p/' . $user->getUsername(); if ($request->isFormPost()) { $badge_phids = $request->getArr('badgePHIDs'); $badges = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withPHIDs($badge_phids)->needRecipients(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->execute(); if (!$badges) { return new Aphront404Response(); } $award_phids = array($user->getPHID()); foreach ($badges as $badge) { $xactions = array(); $xactions[] = id(new PhabricatorBadgesTransaction())->setTransactionType(PhabricatorBadgesTransaction::TYPE_AWARD)->setNewValue($award_phids); $editor = id(new PhabricatorBadgesEditor($badge))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($badge, $xactions); } return id(new AphrontRedirectResponse())->setURI($view_uri); } $form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Badge'))->setName('badgePHIDs')->setDatasource(id(new PhabricatorBadgesDatasource())->setParameters(array('recipientPHID' => $user->getPHID())))); $dialog = $this->newDialog()->setTitle(pht('Grant Badge'))->appendForm($form)->addCancelButton($view_uri)->addSubmitButton(pht('Award')); return $dialog; }
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'))); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$project) { return new Aphront404Response(); } $edit_uri = $this->getApplicationURI('profile/' . $project->getID() . '/'); if ($request->isFormPost()) { if ($project->isArchived()) { $new_status = PhabricatorProjectStatus::STATUS_ACTIVE; } else { $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED; } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)->setNewValue($new_status); id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($edit_uri); } if ($project->isArchived()) { $title = pht('Really activate project?'); $body = pht('This project will become active again.'); $button = pht('Activate Project'); } else { $title = pht('Really archive project?'); $body = pht('This project will be moved to the archive.'); $button = pht('Archive Project'); } $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle($title)->appendChild($body)->addCancelButton($edit_uri)->addSubmitButton($button); return id(new AphrontDialogResponse())->setDialog($dialog); }
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 = $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(); if ($request->isFormPost()) { $uri = new PhutilURI('/fact/chart/'); $uri->setQueryParam('y1', $request->getStr('y1')); return id(new AphrontRedirectResponse())->setURI($uri); } $types = array('+N:*', '+N:DREV', 'updated'); $engines = PhabricatorFactEngine::loadAllEngines(); $specs = PhabricatorFactSpec::newSpecsForFactTypes($engines, $types); $facts = id(new PhabricatorFactAggregate())->loadAllWhere('factType IN (%Ls)', $types); $rows = array(); foreach ($facts as $fact) { $spec = $specs[$fact->getFactType()]; $name = $spec->getName(); $value = $spec->formatValueForDisplay($viewer, $fact->getValueX()); $rows[] = array($name, $value); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Fact'), pht('Value'))); $table->setColumnClasses(array('wide', 'n')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Facts')); $panel->setTable($table); $chart_form = $this->buildChartForm(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Home')); $title = pht('Facts'); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($chart_form, $panel)); }
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')); }
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); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); if (!$request->isFormPost()) { return new Aphront400Response(); } $event = id(new PhabricatorCalendarEventQuery())->setViewer($user)->withIDs(array($this->id))->executeOne(); if (!$event) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $view_uri = '/' . $event->getMonogram(); $xactions = array(); $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorCalendarEventTransactionComment())->setContent($request->getStr('comment'))); $editor = id(new PhabricatorCalendarEventEditor())->setActor($user)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($event, $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($user)->setTransactions($xactions)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($view_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $file = PhabricatorFile::initializeNewFile(); $e_file = true; $errors = array(); if ($request->isFormPost()) { $view_policy = $request->getStr('viewPolicy'); if (!$request->getFileExists('file')) { $e_file = pht('Required'); $errors[] = pht('You must select a file to upload.'); } else { $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true)); } if (!$errors) { return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); } $file->setViewPolicy($view_policy); } $support_id = celerity_generate_unique_node_id(); $instructions = id(new AphrontFormMarkupControl())->setControlID($support_id)->setControlStyle('display: none')->setValue(hsprintf('<br /><br /><strong>%s</strong> %s<br /><br />', pht('Drag and Drop:'), pht('You can also upload files by dragging and dropping them from your ' . 'desktop onto this page or the Phabricator home page.'))); $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($file)->execute(); $form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setLabel(pht('File'))->setName('file')->setError($e_file))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name'))->setName('name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicyObject($file)->setPolicies($policies)->setName('viewPolicy'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload'))->addCancelButton('/file/'))->appendChild($instructions); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Upload'), $request->getRequestURI()); $crumbs->setBorder(true); $title = pht('Upload File'); $global_upload = id(new PhabricatorGlobalUploadTargetView())->setUser($viewer)->setShowIfSupportedID($support_id); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('File'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form); $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-upload'); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $global_upload)); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $credential = id(new PassphraseCredentialQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$credential) { return new Aphront404Response(); } $type = PassphraseCredentialType::getTypeByConstant($credential->getCredentialType()); if (!$type) { throw new Exception(pht('Credential has invalid type "%s"!', $type)); } $view_uri = '/K' . $credential->getID(); if ($credential->getIsLocked()) { return $this->newDialog()->setTitle(pht('Credential Already Locked'))->appendChild(pht('This credential is already locked.'))->addCancelButton($view_uri, pht('Close')); } if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PassphraseCredentialTransaction())->setTransactionType(PassphraseCredentialTransaction::TYPE_CONDUIT)->setNewValue(0); $xactions[] = id(new PassphraseCredentialTransaction())->setTransactionType(PassphraseCredentialTransaction::TYPE_LOCK)->setNewValue(1); $editor = id(new PassphraseCredentialTransactionEditor())->setActor($viewer)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->applyTransactions($credential, $xactions); return id(new AphrontRedirectResponse())->setURI($view_uri); } return $this->newDialog()->setTitle(pht('Lock Credential'))->appendChild(pht('This credential will be locked and the secret will be hidden ' . 'forever. If Conduit access is enabled, it will be revoked. ' . 'Anything relying on this credential will still function. This ' . 'operation can not be undone.'))->addSubmitButton(pht('Lock Credential'))->addCancelButton($view_uri); }
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); } }
protected function processDiffusionRequest(AphrontRequest $request) { $user = $request->getUser(); $drequest = $this->getDiffusionRequest(); $callsign = $drequest->getRepository()->getCallsign(); $repository = $drequest->getRepository(); $commit = $drequest->loadCommit(); $data = $commit->loadCommitData(); $page_title = pht('Edit Diffusion Commit'); if (!$commit) { return new Aphront404Response(); } $commit_phid = $commit->getPHID(); $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($commit_phid, $edge_type); if ($request->isFormPost()) { $xactions = array(); $proj_phids = $request->getArr('projects'); $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edge_type)->setNewValue(array('=' => array_fuse($proj_phids))); $editor = id(new PhabricatorAuditEditor())->setActor($user)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request); $xactions = $editor->applyTransactions($commit, $xactions); return id(new AphrontRedirectResponse())->setURI('/r' . $callsign . $commit->getCommitIdentifier()); } $tokenizer_id = celerity_generate_unique_node_id(); $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Projects'))->setName('projects')->setValue($current_proj_phids)->setID($tokenizer_id)->setCaption(javelin_tag('a', array('href' => '/project/create/', 'mustcapture' => true, 'sigil' => 'project-create'), pht('Create New Project')))->setDatasource(new PhabricatorProjectDatasource())); $reason = $data->getCommitDetail('autocloseReason', false); $reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED; if ($reason !== false) { switch ($reason) { case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: $desc = pht('No, Repository Importing'); break; case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: $desc = pht('No, Autoclose Disabled'); break; case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH: $desc = pht('No, Not On Autoclose Branch'); break; case PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED: $desc = pht('Yes, Forced Via bin/repository CLI Tool.'); break; case null: $desc = pht('Yes'); break; default: $desc = pht('Unknown'); break; } $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); $doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Learn More')); $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Autoclose?'))->setValue(array($desc, " ยท ", $doc_link))); } Javelin::initBehavior('project-create', array('tokenizerID' => $tokenizer_id)); $submit = id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton('/r' . $callsign . $commit->getCommitIdentifier()); $form->appendChild($submit); $crumbs = $this->buildCrumbs(array('commit' => true)); $crumbs->addTextCrumb(pht('Edit')); $form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setForm($form); return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $page_title)); }