3 final class PhabricatorApplicationTransactionCommentRemoveController
4 extends PhabricatorApplicationTransactionController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
8 $phid = $request->getURIData('phid');
10 $xaction = id(new PhabricatorObjectQuery())
11 ->withPHIDs(array($phid))
15 return new Aphront404Response();
18 if (!$xaction->getComment()) {
19 return new Aphront404Response();
22 if ($xaction->getComment()->getIsRemoved()) {
23 // You can't remove an already-removed comment.
24 return new Aphront400Response();
27 $obj_phid = $xaction->getObjectPHID();
28 $obj_handle = id(new PhabricatorHandleQuery())
30 ->withPHIDs(array($obj_phid))
33 $done_uri = $obj_handle->getURI();
35 // We allow administrative removal of comments even if an object is locked,
36 // so you can lock a flamewar and then go clean it up. Locked threads may
37 // not otherwise be edited, and non-administrators can not remove comments
38 // from locked threads.
40 $object = $xaction->getObject();
41 $can_interact = PhabricatorPolicyFilter
::canInteract(
44 if (!$can_interact && !$viewer->getIsAdmin()) {
45 return $this->newDialog()
46 ->setTitle(pht('Conversation Locked'))
49 'You can not remove this comment because the conversation is '.
51 ->addCancelButton($done_uri);
54 if ($request->isFormOrHisecPost()) {
55 $comment = $xaction->getApplicationTransactionCommentObject()
59 $editor = id(new PhabricatorApplicationTransactionCommentEditor())
61 ->setRequest($request)
62 ->setCancelURI($done_uri)
63 ->setContentSource(PhabricatorContentSource
::newFromRequest($request))
64 ->applyEdit($xaction, $comment);
66 if ($request->isAjax()) {
67 return id(new AphrontAjaxResponse())->setContent(array());
69 return id(new AphrontReloadResponse())->setURI($done_uri);
73 $form = id(new AphrontFormView())
76 $dialog = $this->newDialog()
77 ->setTitle(pht('Remove Comment'));
82 "Removing a comment prevents anyone (including you) from reading ".
83 "it. Removing a comment also hides the comment's edit history ".
84 "and prevents it from being edited."))
86 pht('Really remove this comment?'));
89 ->addSubmitButton(pht('Remove Comment'))
90 ->addCancelButton($done_uri);