public function processRequest()
 {
     $rule = id(new HeraldRule())->load($this->id);
     if (!$rule) {
         return new Aphront404Response();
     }
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($user->getPHID() != $rule->getAuthorPHID()) {
         return new Aphront400Response();
     }
     if ($request->isFormPost()) {
         $rule->delete();
         if ($request->isAjax()) {
             return new AphrontRedirectResponse();
         } else {
             return id(new AphrontRedirectResponse())->setURI('/herald/');
         }
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle('Really delete this rule?');
     $dialog->appendChild("Are you sure you want to delete the rule " . "'<strong>" . phutil_escape_html($rule->getName()) . "</strong>'?");
     $dialog->addSubmitButton('Delete');
     $dialog->addCancelButton('/herald/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $slug = PhabricatorSlug::normalize($request->getStr('slug'));
     if ($request->isFormPost()) {
         $document = id(new PhrictionDocumentQuery())->setViewer($user)->withSlugs(array($slug))->executeOne();
         $prompt = $request->getStr('prompt', 'no');
         $document_exists = $document && $document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS;
         if ($document_exists && $prompt == 'no') {
             $dialog = new AphrontDialogView();
             $dialog->setSubmitURI('/phriction/new/')->setTitle(pht('Edit Existing Document?'))->setUser($user)->appendChild(pht('The document %s already exists. Do you want to edit it instead?', phutil_tag('tt', array(), $slug)))->addHiddenInput('slug', $slug)->addHiddenInput('prompt', 'yes')->addCancelButton('/w/')->addSubmitButton(pht('Edit Document'));
             return id(new AphrontDialogResponse())->setDialog($dialog);
         } else {
             if (PhrictionDocument::isProjectSlug($slug)) {
                 $project = id(new PhabricatorProjectQuery())->setViewer($user)->withPhrictionSlugs(array(PhrictionDocument::getProjectSlugIdentifier($slug)))->executeOne();
                 if (!$project) {
                     $dialog = new AphrontDialogView();
                     $dialog->setSubmitURI('/w/')->setTitle(pht('Oops!'))->setUser($user)->appendChild(pht('You cannot create wiki pages under "projects/",
               because they are reserved as project pages.
               Create a new project with this name first.'))->addCancelButton('/w/', 'Okay');
                     return id(new AphrontDialogResponse())->setDialog($dialog);
                 }
             }
         }
         $uri = '/phriction/edit/?slug=' . $slug;
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     if ($slug == '/') {
         $slug = '';
     }
     $view = id(new PHUIFormLayoutView())->appendChild(id(new AphrontFormTextControl())->setLabel('/w/')->setValue($slug)->setName('slug'));
     $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('New Document'))->setSubmitURI('/phriction/new/')->appendChild(phutil_tag('p', array(), pht('Create a new document at')))->appendChild($view)->addSubmitButton(pht('Create'))->addCancelButton('/w/');
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function processRequest()
 {
     $rule = id(new HeraldRule())->load($this->id);
     if (!$rule) {
         return new Aphront404Response();
     }
     $request = $this->getRequest();
     $user = $request->getUser();
     // Anyone can delete a global rule, but only the rule owner can delete a
     // personal one.
     if ($rule->getRuleType() == HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) {
         if ($user->getPHID() != $rule->getAuthorPHID()) {
             return new Aphront400Response();
         }
     }
     if ($request->isFormPost()) {
         $rule->openTransaction();
         $rule->logEdit($user->getPHID(), 'delete');
         $rule->delete();
         $rule->saveTransaction();
         return id(new AphrontReloadResponse())->setURI('/herald/');
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle('Really delete this rule?');
     $dialog->appendChild("Are you sure you want to delete the rule " . "'<strong>" . phutil_escape_html($rule->getName()) . "</strong>'?");
     $dialog->addSubmitButton('Delete');
     $dialog->addCancelButton('/herald/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         if (!$request->isDialogFormPost()) {
             $dialog = new AphrontDialogView();
             $dialog->setUser($user);
             $dialog->setTitle('Really regenerate session?');
             $dialog->setSubmitURI('/settings/page/conduit/');
             $dialog->addSubmitButton('Regenerate');
             $dialog->addCancelbutton('/settings/page/conduit/');
             $dialog->appendChild('<p>Really destroy the old certificate? Any established ' . 'sessions will be terminated.');
             return id(new AphrontDialogResponse())->setDialog($dialog);
         }
         $conn = $user->establishConnection('w');
         queryfx($conn, 'DELETE FROM %T WHERE userPHID = %s AND type LIKE %>', PhabricatorUser::SESSION_TABLE, $user->getPHID(), 'conduit');
         // This implicitly regenerates the certificate.
         $user->setConduitCertificate(null);
         $user->save();
         return id(new AphrontRedirectResponse())->setURI('/settings/page/conduit/?regenerated=true');
     }
     if ($request->getStr('regenerated')) {
         $notice = new AphrontErrorView();
         $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
         $notice->setTitle('Certificate Regenerated');
         $notice->appendChild('<p>Your old certificate has been destroyed and you have been issued ' . 'a new certificate. Sessions established under the old certificate ' . 'are no longer valid.</p>');
         $notice = $notice->render();
     } else {
         $notice = null;
     }
     $cert_form = new AphrontFormView();
     $cert_form->setUser($user)->appendChild('<p class="aphront-form-instructions">This certificate allows you to ' . 'authenticate over Conduit, the Phabricator API. Normally, you just ' . 'run <tt>arc install-certificate</tt> to install it.')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Certificate')->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT)->setValue($user->getConduitCertificate()));
     $cert = new AphrontPanelView();
     $cert->setHeader('Arcanist Certificate');
     $cert->appendChild($cert_form);
     $cert->setWidth(AphrontPanelView::WIDTH_FORM);
     $regen_form = new AphrontFormView();
     $regen_form->setUser($user)->setAction('/settings/page/conduit/')->appendChild('<p class="aphront-form-instructions">You can regenerate this ' . 'certificate, which will invalidate the old certificate and create ' . 'a new one.</p>')->appendChild(id(new AphrontFormSubmitControl())->setValue('Regenerate Certificate'));
     $regen = new AphrontPanelView();
     $regen->setHeader('Regenerate Certificate');
     $regen->appendChild($regen_form);
     $regen->setWidth(AphrontPanelView::WIDTH_FORM);
     return id(new AphrontNullView())->appendChild(array($notice, $cert, $regen));
 }
 public function processRequest(AphrontRequest $request)
 {
     $user = $this->getUser();
     $viewer = $request->getUser();
     id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($viewer, $request, '/settings/');
     if ($request->isFormPost()) {
         if (!$request->isDialogFormPost()) {
             $dialog = new AphrontDialogView();
             $dialog->setUser($viewer);
             $dialog->setTitle(pht('Really regenerate session?'));
             $dialog->setSubmitURI($this->getPanelURI());
             $dialog->addSubmitButton(pht('Regenerate'));
             $dialog->addCancelbutton($this->getPanelURI());
             $dialog->appendChild(phutil_tag('p', array(), pht('Really destroy the old certificate? Any established ' . 'sessions will be terminated.')));
             return id(new AphrontDialogResponse())->setDialog($dialog);
         }
         $sessions = id(new PhabricatorAuthSessionQuery())->setViewer($user)->withIdentityPHIDs(array($user->getPHID()))->withSessionTypes(array(PhabricatorAuthSession::TYPE_CONDUIT))->execute();
         foreach ($sessions as $session) {
             $session->delete();
         }
         // This implicitly regenerates the certificate.
         $user->setConduitCertificate(null);
         $user->save();
         return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?regenerated=true'));
     }
     if ($request->getStr('regenerated')) {
         $notice = new AphrontErrorView();
         $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
         $notice->setTitle(pht('Certificate Regenerated'));
         $notice->appendChild(phutil_tag('p', array(), pht('Your old certificate has been destroyed and you have been issued ' . 'a new certificate. Sessions established under the old certificate ' . 'are no longer valid.')));
         $notice = $notice->render();
     } else {
         $notice = null;
     }
     Javelin::initBehavior('select-on-click');
     $cert_form = new AphrontFormView();
     $cert_form->setUser($viewer)->appendChild(phutil_tag('p', array('class' => 'aphront-form-instructions'), pht('This certificate allows you to authenticate over Conduit, ' . 'the Phabricator API. Normally, you just run %s to install it.', phutil_tag('tt', array(), 'arc install-certificate'))))->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Certificate'))->setHeight(AphrontFormTextAreaControl::HEIGHT_SHORT)->setReadonly(true)->setSigil('select-on-click')->setValue($user->getConduitCertificate()));
     $cert_form = id(new PHUIObjectBoxView())->setHeaderText(pht('Arcanist Certificate'))->setForm($cert_form);
     $regen_instruction = pht('You can regenerate this certificate, which ' . 'will invalidate the old certificate and create a new one.');
     $regen_form = new AphrontFormView();
     $regen_form->setUser($viewer)->setAction($this->getPanelURI())->setWorkflow(true)->appendChild(phutil_tag('p', array('class' => 'aphront-form-instructions'), $regen_instruction))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Regenerate Certificate')));
     $regen_form = id(new PHUIObjectBoxView())->setHeaderText(pht('Regenerate Certificate'))->setForm($regen_form);
     return array($notice, $cert_form, $regen_form);
 }
 public function processRequest()
 {
     $category = id(new PhabricatorDirectoryCategory())->load($this->id);
     if (!$category) {
         return new Aphront404Response();
     }
     $request = $this->getRequest();
     if ($request->isFormPost()) {
         $category->delete();
         return id(new AphrontRedirectResponse())->setURI('/directory/category/');
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle('Really delete this category?');
     $dialog->appendChild("Are you sure you want to delete this category?");
     $dialog->addSubmitButton('Delete');
     $dialog->addCancelButton('/directory/category/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $countdown = id(new PhabricatorCountdownQuery())->setViewer($user)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$countdown) {
         return new Aphront404Response();
     }
     if ($request->isFormPost()) {
         $countdown->delete();
         return id(new AphrontRedirectResponse())->setURI('/countdown/');
     }
     $inst = pht('Are you sure you want to delete the countdown %s?', $countdown->getTitle());
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle(pht('Really delete this countdown?'));
     $dialog->appendChild(phutil_tag('p', array(), $inst));
     $dialog->addSubmitButton(pht('Delete'));
     $dialog->addCancelButton('/countdown/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $slug = PhabricatorSlug::normalize($request->getStr('slug'));
     if ($request->isFormPost()) {
         $document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withSlugs(array($slug))->executeOne();
         $prompt = $request->getStr('prompt', 'no');
         $document_exists = $document && $document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS;
         if ($document_exists && $prompt == 'no') {
             $dialog = new AphrontDialogView();
             $dialog->setSubmitURI('/phriction/new/')->setTitle(pht('Edit Existing Document?'))->setUser($viewer)->appendChild(pht('The document %s already exists. Do you want to edit it instead?', phutil_tag('tt', array(), $slug)))->addHiddenInput('slug', $slug)->addHiddenInput('prompt', 'yes')->addCancelButton('/w/')->addSubmitButton(pht('Edit Document'));
             return id(new AphrontDialogResponse())->setDialog($dialog);
         }
         $uri = '/phriction/edit/?slug=' . $slug;
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     if ($slug == '/') {
         $slug = '';
     }
     $view = id(new PHUIFormLayoutView())->appendChild(id(new AphrontFormTextControl())->setLabel('/w/')->setValue($slug)->setName('slug'));
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('New Document'))->setSubmitURI('/phriction/new/')->appendChild(phutil_tag('p', array(), pht('Create a new document at')))->appendChild($view)->addSubmitButton(pht('Create'))->addCancelButton('/w/');
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $timer = id(new PhabricatorTimer())->load($this->id);
     if (!$timer) {
         return new Aphront404Response();
     }
     if ($timer->getAuthorPHID() !== $user->getPHID() && $user->getIsAdmin() === false) {
         return new Aphront404Response();
     }
     if ($request->isFormPost()) {
         $timer->delete();
         return id(new AphrontRedirectResponse())->setURI('/countdown/');
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle('Really delete this countdown?');
     $dialog->appendChild('<p>Are you sure you want to delete the countdown "' . phutil_escape_html($timer->getTitle()) . '"?</p>');
     $dialog->addSubmitButton('Delete');
     $dialog->addCancelButton('/countdown/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 public function handleRequest(AphrontRequest $request)
 {
     if (!PhabricatorPasswordAuthProvider::getPasswordProvider()) {
         return new Aphront400Response();
     }
     $e_email = true;
     $e_captcha = true;
     $errors = array();
     $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
     if ($request->isFormPost()) {
         $e_email = null;
         $e_captcha = pht('Again');
         $captcha_ok = AphrontFormRecaptchaControl::processCaptcha($request);
         if (!$captcha_ok) {
             $errors[] = pht('Captcha response is incorrect, try again.');
             $e_captcha = pht('Invalid');
         }
         $email = $request->getStr('email');
         if (!strlen($email)) {
             $errors[] = pht('You must provide an email address.');
             $e_email = pht('Required');
         }
         if (!$errors) {
             // NOTE: Don't validate the email unless the captcha is good; this makes
             // it expensive to fish for valid email addresses while giving the user
             // a better error if they goof their email.
             $target_email = id(new PhabricatorUserEmail())->loadOneWhere('address = %s', $email);
             $target_user = null;
             if ($target_email) {
                 $target_user = id(new PhabricatorUser())->loadOneWhere('phid = %s', $target_email->getUserPHID());
             }
             if (!$target_user) {
                 $errors[] = pht('There is no account associated with that email address.');
                 $e_email = pht('Invalid');
             }
             // If this address is unverified, only send a reset link to it if
             // the account has no verified addresses. This prevents an opportunistic
             // attacker from compromising an account if a user adds an email
             // address but mistypes it and doesn't notice.
             // (For a newly created account, all the addresses may be unverified,
             // which is why we'll send to an unverified address in that case.)
             if ($target_email && !$target_email->getIsVerified()) {
                 $verified_addresses = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s AND isVerified = 1', $target_email->getUserPHID());
                 if ($verified_addresses) {
                     $errors[] = pht('That email address is not verified. You can only send ' . 'password reset links to a verified address.');
                     $e_email = pht('Unverified');
                 }
             }
             if (!$errors) {
                 $engine = new PhabricatorAuthSessionEngine();
                 $uri = $engine->getOneTimeLoginURI($target_user, null, PhabricatorAuthSessionEngine::ONETIME_RESET);
                 if ($is_serious) {
                     $body = pht("You can use this link to reset your Phabricator password:"******"\n\n  %s\n", $uri);
                 } else {
                     $body = pht("Condolences on forgetting your password. You can use this " . "link to reset it:\n\n" . "  %s\n\n" . "After you set a new password, consider writing it down on a " . "sticky note and attaching it to your monitor so you don't " . "forget again! Choosing a very short, easy-to-remember password " . "like \"cat\" or \"1234\" might also help.\n\n" . "Best Wishes,\nPhabricator\n", $uri);
                 }
                 $mail = id(new PhabricatorMetaMTAMail())->setSubject(pht('[Phabricator] Password Reset'))->setForceDelivery(true)->addRawTos(array($target_email->getAddress()))->setBody($body)->saveAndSend();
                 return $this->newDialog()->setTitle(pht('Check Your Email'))->setShortTitle(pht('Email Sent'))->appendParagraph(pht('An email has been sent with a link you can use to login.'))->addCancelButton('/', pht('Done'));
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new PHUIInfoView();
         $error_view->setErrors($errors);
     }
     $email_auth = new PHUIFormLayoutView();
     $email_auth->appendChild($error_view);
     $email_auth->setUser($request->getUser())->setFullWidth(true)->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Email'))->setName('email')->setValue($request->getStr('email'))->setError($e_email))->appendChild(id(new AphrontFormRecaptchaControl())->setLabel(pht('Captcha'))->setError($e_captcha));
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Reset Password'));
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle(pht('Forgot Password / Email Login'));
     $dialog->appendChild($email_auth);
     $dialog->addSubmitButton(pht('Send Email'));
     $dialog->setSubmitURI('/login/email/');
     return $this->buildApplicationPage(array($crumbs, $dialog), array('title' => pht('Forgot Password')));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $this->readRequestParameters();
     switch ($this->getOperation()) {
         case 'delete':
             $inline = $this->loadCommentForEdit($this->getCommentID());
             if ($request->isFormPost()) {
                 $inline->delete();
                 return $this->buildEmptyResponse();
             }
             $dialog = new AphrontDialogView();
             $dialog->setUser($user);
             $dialog->setSubmitURI($request->getRequestURI());
             $dialog->setTitle('Really delete this comment?');
             $dialog->addHiddenInput('id', $this->getCommentID());
             $dialog->addHiddenInput('op', 'delete');
             $dialog->appendChild('<p>Delete this inline comment?</p>');
             $dialog->addCancelButton('#');
             $dialog->addSubmitButton('Delete');
             return id(new AphrontDialogResponse())->setDialog($dialog);
         case 'edit':
             $inline = $this->loadCommentForEdit($this->getCommentID());
             $text = $this->getCommentText();
             if ($request->isFormPost()) {
                 if (strlen($text)) {
                     $inline->setContent($text);
                     $inline->save();
                     return $this->buildRenderedCommentResponse($inline, $this->getIsOnRight());
                 } else {
                     $inline->delete();
                     return $this->buildEmptyResponse();
                 }
             }
             $edit_dialog = $this->buildEditDialog();
             $edit_dialog->setTitle('Edit Inline Comment');
             $edit_dialog->addHiddenInput('id', $this->getCommentID());
             $edit_dialog->addHiddenInput('op', 'edit');
             $edit_dialog->appendChild($this->renderTextArea(nonempty($text, $inline->getContent())));
             return id(new AphrontAjaxResponse())->setContent($edit_dialog->render());
         case 'create':
             $text = $this->getCommentText();
             if (!$request->isFormPost() || !strlen($text)) {
                 return $this->buildEmptyResponse();
             }
             $inline = $this->createComment()->setChangesetID($this->getChangesetID())->setAuthorPHID($user->getPHID())->setLineNumber($this->getLineNumber())->setLineLength($this->getLineLength())->setIsNewFile($this->getIsNewFile())->setContent($text)->save();
             return $this->buildRenderedCommentResponse($inline, $this->getIsOnRight());
         case 'reply':
         default:
             $edit_dialog = $this->buildEditDialog();
             if ($this->getOperation() == 'reply') {
                 $inline = $this->loadComment($this->getCommentID());
                 $edit_dialog->setTitle('Reply to Inline Comment');
                 $changeset = $inline->getChangesetID();
                 $is_new = $inline->getIsNewFile();
                 $number = $inline->getLineNumber();
                 $length = $inline->getLineLength();
             } else {
                 $edit_dialog->setTitle('New Inline Comment');
                 $changeset = $this->getChangesetID();
                 $is_new = $this->getIsNewFile();
                 $number = $this->getLineNumber();
                 $length = $this->getLineLength();
             }
             $edit_dialog->addHiddenInput('op', 'create');
             $edit_dialog->addHiddenInput('changeset', $changeset);
             $edit_dialog->addHiddenInput('is_new', $is_new);
             $edit_dialog->addHiddenInput('number', $number);
             $edit_dialog->addHiddenInput('length', $length);
             $text_area = $this->renderTextArea($this->getCommentText());
             $edit_dialog->appendChild($text_area);
             return id(new AphrontAjaxResponse())->setContent($edit_dialog->render());
     }
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $changeset = $request->getInt('changeset');
     $is_new = $request->getBool('is_new');
     $on_right = $request->getBool('on_right');
     $number = $request->getInt('number');
     $length = $request->getInt('length');
     $text = $request->getStr('text');
     $op = $request->getStr('op');
     $inline_id = $request->getInt('id');
     $user = $request->getUser();
     $submit_uri = '/differential/comment/inline/edit/' . $this->revisionID . '/';
     $edit_dialog = new AphrontDialogView();
     $edit_dialog->setUser($user);
     $edit_dialog->setSubmitURI($submit_uri);
     $edit_dialog->addHiddenInput('on_right', $on_right);
     $edit_dialog->addSubmitButton();
     $edit_dialog->addCancelButton('#');
     switch ($op) {
         case 'delete':
             $inline = $this->loadInlineCommentForEditing($inline_id);
             if ($request->isFormPost()) {
                 $inline->delete();
                 return $this->buildEmptyResponse();
             }
             $edit_dialog->setTitle('Really delete this comment?');
             $edit_dialog->addHiddenInput('id', $inline_id);
             $edit_dialog->addHiddenInput('op', 'delete');
             $edit_dialog->appendChild('<p>Delete this inline comment?</p>');
             return id(new AphrontDialogResponse())->setDialog($edit_dialog);
         case 'edit':
             $inline = $this->loadInlineCommentForEditing($inline_id);
             if ($request->isFormPost()) {
                 if (strlen($text)) {
                     $inline->setContent($text);
                     $inline->setCache(null);
                     $inline->save();
                     return $this->buildRenderedCommentResponse($inline, $on_right);
                 } else {
                     $inline->delete();
                     return $this->buildEmptyResponse();
                 }
             }
             $edit_dialog->setTitle('Edit Inline Comment');
             $edit_dialog->addHiddenInput('id', $inline_id);
             $edit_dialog->addHiddenInput('op', 'edit');
             $edit_dialog->appendChild($this->renderTextArea(nonempty($text, $inline->getContent())));
             return id(new AphrontDialogResponse())->setDialog($edit_dialog);
         case 'create':
             if (!$request->isFormPost() || !strlen($text)) {
                 return $this->buildEmptyResponse();
             }
             // Verify revision and changeset correspond to actual objects.
             $revision_obj = id(new DifferentialRevision())->load($this->revisionID);
             $changeset_obj = id(new DifferentialChangeset())->load($changeset);
             if (!$revision_obj || !$changeset_obj) {
                 throw new Exception("Invalid revision ID or changeset ID!");
             }
             $inline = id(new DifferentialInlineComment())->setRevisionID($this->revisionID)->setChangesetID($changeset)->setCommentID(null)->setAuthorPHID($user->getPHID())->setLineNumber($number)->setLineLength($length)->setIsNewFile($on_right)->setContent($text)->save();
             return $this->buildRenderedCommentResponse($inline, $on_right);
         case 'reply':
         default:
             if ($op == 'reply') {
                 $inline = $this->loadInlineComment($inline_id);
                 // Override defaults.
                 $changeset = $inline->getChangesetID();
                 $is_new = $inline->getIsNewFile();
                 $number = $inline->getLineNumber();
                 $length = $inline->getLineLength();
                 $edit_dialog->setTitle('Reply to Inline Comment');
             } else {
                 $edit_dialog->setTitle('New Inline Comment');
             }
             $edit_dialog->addHiddenInput('op', 'create');
             $edit_dialog->addHiddenInput('changeset', $changeset);
             $edit_dialog->addHiddenInput('is_new', $is_new);
             $edit_dialog->addHiddenInput('number', $number);
             $edit_dialog->addHiddenInput('length', $length);
             $edit_dialog->appendChild($this->renderTextArea($text));
             return id(new AphrontDialogResponse())->setDialog($edit_dialog);
     }
 }