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 loadCommentForDone($id); | ||||
| abstract protected function loadCommentByPHID($phid); | abstract protected function loadCommentByPHID($phid); | ||||
| abstract protected function loadObjectOwnerPHID( | |||||
| PhabricatorInlineCommentInterface $inline); | |||||
| 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; | ||||
| private $isOnRight; | private $isOnRight; | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public function processRequest() { | ||||
| $op = $this->getOperation(); | $op = $this->getOperation(); | ||||
| switch ($op) { | switch ($op) { | ||||
| case 'done': | case 'done': | ||||
| if (!$request->validateCSRF()) { | if (!$request->validateCSRF()) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $inline = $this->loadCommentForDone($this->getCommentID()); | $inline = $this->loadCommentForDone($this->getCommentID()); | ||||
| $is_draft_state = false; | |||||
| switch ($inline->getFixedState()) { | switch ($inline->getFixedState()) { | ||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | case PhabricatorInlineCommentInterface::STATE_DRAFT: | ||||
| $next_state = PhabricatorInlineCommentInterface::STATE_UNDONE; | $next_state = PhabricatorInlineCommentInterface::STATE_UNDONE; | ||||
| break; | break; | ||||
| case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | ||||
| $next_state = PhabricatorInlineCommentInterface::STATE_DONE; | $next_state = PhabricatorInlineCommentInterface::STATE_DONE; | ||||
| break; | break; | ||||
| case PhabricatorInlineCommentInterface::STATE_DONE: | case PhabricatorInlineCommentInterface::STATE_DONE: | ||||
| $next_state = PhabricatorInlineCommentInterface::STATE_UNDRAFT; | $next_state = PhabricatorInlineCommentInterface::STATE_UNDRAFT; | ||||
| $is_draft_state = true; | |||||
| break; | break; | ||||
| default: | default: | ||||
| case PhabricatorInlineCommentInterface::STATE_UNDONE: | case PhabricatorInlineCommentInterface::STATE_UNDONE: | ||||
| $next_state = PhabricatorInlineCommentInterface::STATE_DRAFT; | $next_state = PhabricatorInlineCommentInterface::STATE_DRAFT; | ||||
| $is_draft_state = true; | |||||
| break; | break; | ||||
| } | } | ||||
| $inline->setFixedState($next_state)->save(); | $inline->setFixedState($next_state)->save(); | ||||
| return $this->buildEmptyResponse(); | return id(new AphrontAjaxResponse()) | ||||
| ->setContent( | |||||
| array( | |||||
| 'draftState' => $is_draft_state, | |||||
| )); | |||||
| 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 183 Lines • ▼ Show 20 Lines | private function buildRenderedCommentResponse( | ||||
| $engine->addObject( | $engine->addObject( | ||||
| $inline, | $inline, | ||||
| PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | ||||
| $engine->process(); | $engine->process(); | ||||
| $phids = array($user->getPHID()); | $phids = array($user->getPHID()); | ||||
| $handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
| $object_owner_phid = $this->loadObjectOwnerPHID($inline); | |||||
| // TODO: This is not correct, but figuring it out is a little bit | |||||
| // involved and it only affects drafts. | |||||
| $object_owner_phid = null; | |||||
| $view = id(new PHUIDiffInlineCommentDetailView()) | $view = id(new PHUIDiffInlineCommentDetailView()) | ||||
| ->setUser($user) | |||||
| ->setInlineComment($inline) | ->setInlineComment($inline) | ||||
| ->setIsOnRight($on_right) | ->setIsOnRight($on_right) | ||||
| ->setMarkupEngine($engine) | ->setMarkupEngine($engine) | ||||
| ->setHandles($handles) | ->setHandles($handles) | ||||
| ->setEditable(true) | ->setEditable(true) | ||||
| ->setCanMarkDone(false) | ->setCanMarkDone(false) | ||||
| ->setObjectOwnerPHID($object_owner_phid); | ->setObjectOwnerPHID($object_owner_phid); | ||||
| Show All 30 Lines | |||||