diff --git a/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php b/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php index 1cb38b1768..a93f16a688 100644 --- a/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php +++ b/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentEditController.php @@ -1,87 +1,69 @@ phid = $data['phid']; - } - - public function processRequest() { - $request = $this->getRequest(); - $user = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); $xaction = id(new PhabricatorObjectQuery()) - ->withPHIDs(array($this->phid)) - ->setViewer($user) + ->setViewer($viewer) + ->withPHIDs(array($request->getURIData('phid'))) ->executeOne(); - if (!$xaction) { return new Aphront404Response(); } if (!$xaction->getComment()) { // You can't currently edit a transaction which doesn't have a comment. // Some day you may be able to edit the visibility. return new Aphront404Response(); } if ($xaction->getComment()->getIsRemoved()) { // You can't edit history of a transaction with a removed comment. return new Aphront400Response(); } - $obj_phid = $xaction->getObjectPHID(); - $obj_handle = id(new PhabricatorHandleQuery()) - ->setViewer($user) - ->withPHIDs(array($obj_phid)) - ->executeOne(); + $phid = $xaction->getObjectPHID(); + $handles = $viewer->loadHandles(array($phid)); + $obj_handle = $handles[$phid]; if ($request->isDialogFormPost()) { $text = $request->getStr('text'); $comment = $xaction->getApplicationTransactionCommentObject(); $comment->setContent($text); if (!strlen($text)) { $comment->setIsDeleted(true); } $editor = id(new PhabricatorApplicationTransactionCommentEditor()) - ->setActor($user) + ->setActor($viewer) ->setContentSource(PhabricatorContentSource::newFromRequest($request)) ->applyEdit($xaction, $comment); if ($request->isAjax()) { return id(new AphrontAjaxResponse())->setContent(array()); } else { return id(new AphrontReloadResponse())->setURI($obj_handle->getURI()); } } - $dialog = id(new AphrontDialogView()) - ->setUser($user) - ->setSubmitURI( - $this->getApplicationURI('/transactions/edit/'.$xaction->getPHID().'/')) - ->setTitle(pht('Edit Comment')); + $form = id(new AphrontFormView()) + ->setUser($viewer) + ->setFullWidth(true) + ->appendControl( + id(new PhabricatorRemarkupControl()) + ->setName('text') + ->setValue($xaction->getComment()->getContent())); - $dialog + return $this->newDialog() + ->setTitle(pht('Edit Comment')) ->addHiddenInput('anchor', $request->getStr('anchor')) - ->appendChild( - id(new PHUIFormLayoutView()) - ->setFullWidth(true) - ->appendChild( - id(new PhabricatorRemarkupControl()) - ->setUser($user) - ->setName('text') - ->setValue($xaction->getComment()->getContent()))); - - $dialog + ->appendForm($form) ->addSubmitButton(pht('Save Changes')) ->addCancelButton($obj_handle->getURI()); - - return id(new AphrontDialogResponse())->setDialog($dialog); } }