Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentController.php
Show First 20 Lines • Show All 73 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(); | ||||
switch ($this->getOperation()) { | $op = $this->getOperation(); | ||||
switch ($op) { | |||||
case 'delete': | case 'delete': | ||||
$inline = $this->loadCommentForEdit($this->getCommentID()); | case 'undelete': | ||||
case 'refdelete': | |||||
if ($request->isFormPost()) { | if (!$request->validateCSRF()) { | ||||
$this->deleteComment($inline); | return new Aphront404Response(); | ||||
return $this->buildEmptyResponse(); | } | ||||
// NOTE: For normal deletes, we just process the delete immediately | |||||
// and show an "Undo" action. For deletes by reference from the | |||||
// preview ("refdelete"), we prompt first (because the "Undo" may | |||||
// not draw, or may not be easy to locate). | |||||
if ($op == 'refdelete') { | |||||
if (!$request->isFormPost()) { | |||||
return $this->newDialog() | |||||
->setTitle(pht('Really delete comment?')) | |||||
->addHiddenInput('id', $this->getCommentID()) | |||||
->addHiddenInput('op', $op) | |||||
->appendParagraph(pht('Delete this inline comment?')) | |||||
->addCancelButton('#') | |||||
->addSubmitButton(pht('Delete')); | |||||
} | |||||
} | } | ||||
$dialog = new AphrontDialogView(); | $is_delete = ($op == 'delete' || $op == 'refdelete'); | ||||
$dialog->setUser($user); | |||||
$dialog->setSubmitURI($request->getRequestURI()); | |||||
$dialog->setTitle(pht('Really delete this comment?')); | |||||
$dialog->addHiddenInput('id', $this->getCommentID()); | |||||
$dialog->addHiddenInput('op', 'delete'); | |||||
$dialog->appendChild( | |||||
phutil_tag('p', array(), pht('Delete this inline comment?'))); | |||||
$dialog->addCancelButton('#'); | $inline = $this->loadCommentForEdit($this->getCommentID()); | ||||
$dialog->addSubmitButton(pht('Delete')); | $inline->setIsDeleted((int)$is_delete)->save(); | ||||
return id(new AphrontDialogResponse())->setDialog($dialog); | return $this->buildEmptyResponse(); | ||||
case 'edit': | case 'edit': | ||||
$inline = $this->loadCommentForEdit($this->getCommentID()); | $inline = $this->loadCommentForEdit($this->getCommentID()); | ||||
$text = $this->getCommentText(); | $text = $this->getCommentText(); | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
if (strlen($text)) { | if (strlen($text)) { | ||||
$inline->setContent($text); | $inline->setContent($text); | ||||
$this->saveComment($inline); | $this->saveComment($inline); | ||||
return $this->buildRenderedCommentResponse( | return $this->buildRenderedCommentResponse( | ||||
$inline, | $inline, | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |