Differential D21186 Diff 50453 src/applications/differential/controller/DifferentialInlineCommentEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/controller/DifferentialInlineCommentEditController.php
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | return id(new DifferentialInlineCommentQuery()) | ||||
| ->needHidden(true) | ->needHidden(true) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| } | } | ||||
| protected function loadCommentForEdit($id) { | protected function loadCommentForEdit($id) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $inline = $this->loadComment($id); | $inline = $this->loadComment($id); | ||||
| if (!$inline) { | |||||
| throw new Exception( | |||||
| pht('Unable to load inline "%s".', $id)); | |||||
| } | |||||
| if (!$this->canEditInlineComment($viewer, $inline)) { | if (!$this->canEditInlineComment($viewer, $inline)) { | ||||
| throw new Exception(pht('That comment is not editable!')); | throw new Exception(pht('That comment is not editable!')); | ||||
| } | } | ||||
| return $inline; | return $inline; | ||||
| } | } | ||||
| protected function loadCommentForDone($id) { | protected function loadCommentForDone($id) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $inline = $this->loadComment($id); | $inline = $this->loadComment($id); | ||||
| if (!$inline) { | if (!$inline) { | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | private function canEditInlineComment( | ||||
| // Inline must be attached to the active revision. | // Inline must be attached to the active revision. | ||||
| if ($inline->getRevisionID() != $this->getRevisionID()) { | if ($inline->getRevisionID() != $this->getRevisionID()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| protected function deleteComment(PhabricatorInlineCommentInterface $inline) { | protected function deleteComment(PhabricatorInlineComment $inline) { | ||||
| $inline->openTransaction(); | $inline->openTransaction(); | ||||
| $inline->setIsDeleted(1)->save(); | $inline->setIsDeleted(1)->save(); | ||||
| $this->syncDraft(); | $this->syncDraft(); | ||||
| $inline->saveTransaction(); | $inline->saveTransaction(); | ||||
| } | } | ||||
| protected function undeleteComment( | protected function undeleteComment( | ||||
| PhabricatorInlineCommentInterface $inline) { | PhabricatorInlineComment $inline) { | ||||
| $inline->openTransaction(); | $inline->openTransaction(); | ||||
| $inline->setIsDeleted(0)->save(); | $inline->setIsDeleted(0)->save(); | ||||
| $this->syncDraft(); | $this->syncDraft(); | ||||
| $inline->saveTransaction(); | $inline->saveTransaction(); | ||||
| } | } | ||||
| protected function saveComment(PhabricatorInlineCommentInterface $inline) { | protected function saveComment(PhabricatorInlineComment $inline) { | ||||
| $inline->openTransaction(); | $inline->openTransaction(); | ||||
| $inline->save(); | $inline->save(); | ||||
| $this->syncDraft(); | $this->syncDraft(); | ||||
| $inline->saveTransaction(); | $inline->saveTransaction(); | ||||
| } | } | ||||
| protected function loadObjectOwnerPHID( | protected function loadObjectOwnerPHID( | ||||
| PhabricatorInlineCommentInterface $inline) { | PhabricatorInlineComment $inline) { | ||||
| return $this->loadRevision()->getAuthorPHID(); | return $this->loadRevision()->getAuthorPHID(); | ||||
| } | } | ||||
| protected function hideComments(array $ids) { | protected function hideComments(array $ids) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $table = new DifferentialHiddenComment(); | $table = new DifferentialHiddenComment(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| Show All 40 Lines | |||||