mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
bfc1ccfdf1
Summary: man I sure hate Javascript I removed the ajax-edit and ajax-remove interactions, becuase they were prohibitively complex to get working given that the entire menu has to change too. Instead, the page just reloads. This works perfectly fine in practice. If we want to restore these in the future, we should have the server re-render the entire transaction group or something. I think very little is lost here, though. Test Plan: - Took all the actions. - Used existing dropdown menus. {F150196} Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D8966
79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationTransactionCommentRemoveController
|
|
extends PhabricatorApplicationTransactionController {
|
|
|
|
private $phid;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->phid = $data['phid'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$xaction = id(new PhabricatorObjectQuery())
|
|
->withPHIDs(array($this->phid))
|
|
->setViewer($viewer)
|
|
->executeOne();
|
|
if (!$xaction) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if (!$xaction->getComment()) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if ($xaction->getComment()->getIsRemoved()) {
|
|
// You can't remove an already-removed comment.
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$obj_phid = $xaction->getObjectPHID();
|
|
$obj_handle = id(new PhabricatorHandleQuery())
|
|
->setViewer($viewer)
|
|
->withPHIDs(array($obj_phid))
|
|
->executeOne();
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
$comment = $xaction->getApplicationTransactionCommentObject()
|
|
->setContent('')
|
|
->setIsRemoved(true);
|
|
|
|
$editor = id(new PhabricatorApplicationTransactionCommentEditor())
|
|
->setActor($viewer)
|
|
->setContentSource(PhabricatorContentSource::newFromRequest($request))
|
|
->applyEdit($xaction, $comment);
|
|
|
|
if ($request->isAjax()) {
|
|
return id(new AphrontAjaxResponse())->setContent(array());
|
|
} else {
|
|
return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
|
|
}
|
|
}
|
|
|
|
$form = id(new AphrontFormView())
|
|
->setUser($viewer);
|
|
|
|
$dialog = $this->newDialog()
|
|
->setTitle(pht('Remove Comment'));
|
|
|
|
$dialog
|
|
->addHiddenInput('anchor', $request->getStr('anchor'))
|
|
->appendParagraph(
|
|
pht(
|
|
"Removing a comment prevents anyone (including you) from reading ".
|
|
"it. Removing a comment also hides the comment's edit history ".
|
|
"and prevents it from being edited."))
|
|
->appendParagraph(
|
|
pht('Really remove this comment?'));
|
|
|
|
$dialog
|
|
->addSubmitButton(pht('Remove Comment'))
|
|
->addCancelButton($obj_handle->getURI());
|
|
|
|
return $dialog;
|
|
}
|
|
|
|
}
|