Differential D12033 Diff 29183 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 51 Lines • ▼ Show 20 Lines | protected function loadCommentForEdit($id) { | ||||
| $inline = $this->loadComment($id); | $inline = $this->loadComment($id); | ||||
| if (!$this->canEditInlineComment($user, $inline)) { | if (!$this->canEditInlineComment($user, $inline)) { | ||||
| throw new Exception('That comment is not editable!'); | throw new Exception('That comment is not editable!'); | ||||
| } | } | ||||
| return $inline; | return $inline; | ||||
| } | } | ||||
| protected function loadCommentForDone($id) { | |||||
| $request = $this->getRequest(); | |||||
| $viewer = $request->getUser(); | |||||
| $inline = $this->loadComment($id); | |||||
| if (!$inline) { | |||||
| throw new Exception(pht('Unable to load inline "%d".', $id)); | |||||
| } | |||||
| $changeset = id(new DifferentialChangesetQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($inline->getChangesetID())) | |||||
| ->executeOne(); | |||||
| if (!$changeset) { | |||||
| throw new Exception(pht('Unable to load changeset.')); | |||||
| } | |||||
| $diff = id(new DifferentialDiffQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($changeset->getDiffID())) | |||||
| ->executeOne(); | |||||
| if (!$diff) { | |||||
| throw new Exception(pht('Unable to load diff.')); | |||||
| } | |||||
| $revision = id(new DifferentialRevisionQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withIDs(array($diff->getRevisionID())) | |||||
| ->executeOne(); | |||||
| if (!$revision) { | |||||
| throw new Exception(pht('Unable to load revision.')); | |||||
| } | |||||
| if ($revision->getAuthorPHID() !== $viewer->getPHID()) { | |||||
| throw new Exception(pht('You are not the revision owner.')); | |||||
| } | |||||
| return $inline; | |||||
| } | |||||
| private function canEditInlineComment( | private function canEditInlineComment( | ||||
| PhabricatorUser $user, | PhabricatorUser $user, | ||||
| DifferentialInlineComment $inline) { | DifferentialInlineComment $inline) { | ||||
| // Only the author may edit a comment. | // Only the author may edit a comment. | ||||
| if ($inline->getAuthorPHID() != $user->getPHID()) { | if ($inline->getAuthorPHID() != $user->getPHID()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| Show All 35 Lines | |||||