Differential D12033 Diff 29183 src/applications/diffusion/controller/DiffusionInlineCommentController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionInlineCommentController.php
| Show First 20 Lines • Show All 52 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('Failed to load comment "%d".', $id)); | |||||
| } | |||||
| $commit = id(new DiffusionCommitQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($inline->getCommitPHID())) | |||||
| ->exeucteOne(); | |||||
| if (!$commit) { | |||||
| throw new Exception(pht('Failed to load commit.')); | |||||
| } | |||||
| if ((!$commit->getAuthorPHID()) || | |||||
| ($commit->getAuthorPHID() != $viewer->getPHID())) { | |||||
| throw new Exception(pht('You can not mark this comment as complete.')); | |||||
| } | |||||
| return $inline; | |||||
| } | |||||
| private function canEditInlineComment( | private function canEditInlineComment( | ||||
| PhabricatorUser $user, | PhabricatorUser $user, | ||||
| PhabricatorAuditInlineComment $inline) { | PhabricatorAuditInlineComment $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 23 Lines | |||||