Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentController.php
| <?php | <?php | ||||
| abstract class PhabricatorInlineCommentController | abstract class PhabricatorInlineCommentController | ||||
| extends PhabricatorController { | extends PhabricatorController { | ||||
| abstract protected function createComment(); | abstract protected function createComment(); | ||||
| abstract protected function loadComment($id); | abstract protected function loadComment($id); | ||||
| abstract protected function loadCommentForEdit($id); | abstract protected function loadCommentForEdit($id); | ||||
| abstract protected function loadCommentForDone($id); | |||||
| abstract protected function loadCommentByPHID($phid); | abstract protected function loadCommentByPHID($phid); | ||||
| abstract protected function deleteComment( | abstract protected function deleteComment( | ||||
| PhabricatorInlineCommentInterface $inline); | PhabricatorInlineCommentInterface $inline); | ||||
| abstract protected function saveComment( | abstract protected function saveComment( | ||||
| PhabricatorInlineCommentInterface $inline); | PhabricatorInlineCommentInterface $inline); | ||||
| private $changesetID; | private $changesetID; | ||||
| private $isNewFile; | private $isNewFile; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | abstract class PhabricatorInlineCommentController | ||||
| public function processRequest() { | public function processRequest() { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $this->readRequestParameters(); | $this->readRequestParameters(); | ||||
| $op = $this->getOperation(); | $op = $this->getOperation(); | ||||
| switch ($op) { | switch ($op) { | ||||
| case 'done': | |||||
| if (!$request->validateCSRF()) { | |||||
| return new Aphront404Response(); | |||||
| } | |||||
| $inline = $this->loadCommentForDone($this->getCommentID()); | |||||
| switch ($inline->getFixedState()) { | |||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | |||||
| $next_state = PhabricatorInlineCommentInterface::STATE_UNDONE; | |||||
| break; | |||||
| case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | |||||
| $next_state = PhabricatorInlineCommentInterface::STATE_DONE; | |||||
| break; | |||||
| case PhabricatorInlineCommentInterface::STATE_DONE: | |||||
| $next_state = PhabricatorInlineCommentInterface::STATE_UNDRAFT; | |||||
| break; | |||||
| default: | |||||
| case PhabricatorInlineCommentInterface::STATE_UNDONE: | |||||
| $next_state = PhabricatorInlineCommentInterface::STATE_DRAFT; | |||||
| break; | |||||
| } | |||||
| $inline->setFixedState($next_state)->save(); | |||||
| return $this->buildEmptyResponse(); | |||||
| case 'delete': | case 'delete': | ||||
| case 'undelete': | case 'undelete': | ||||
| case 'refdelete': | case 'refdelete': | ||||
| if (!$request->validateCSRF()) { | if (!$request->validateCSRF()) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| // NOTE: For normal deletes, we just process the delete immediately | // NOTE: For normal deletes, we just process the delete immediately | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | private function buildRenderedCommentResponse( | ||||
| $handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
| $view = id(new PHUIDiffInlineCommentDetailView()) | $view = id(new PHUIDiffInlineCommentDetailView()) | ||||
| ->setInlineComment($inline) | ->setInlineComment($inline) | ||||
| ->setIsOnRight($on_right) | ->setIsOnRight($on_right) | ||||
| ->setMarkupEngine($engine) | ->setMarkupEngine($engine) | ||||
| ->setHandles($handles) | ->setHandles($handles) | ||||
| ->setEditable(true); | ->setEditable(true) | ||||
| ->setCanMarkDone(false); | |||||
| $view = $this->buildScaffoldForView($view); | $view = $this->buildScaffoldForView($view); | ||||
| return id(new AphrontAjaxResponse()) | return id(new AphrontAjaxResponse()) | ||||
| ->setContent( | ->setContent( | ||||
| array( | array( | ||||
| 'inlineCommentID' => $inline->getID(), | 'inlineCommentID' => $inline->getID(), | ||||
| 'markup' => $view->render(), | 'markup' => $view->render(), | ||||
| Show All 23 Lines | |||||