mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
b902005bed
Summary: Ref T603. Killing this class is cool because the classes that replace it are policy-aware. Tried to keep my wits about me as I did this and fixed a few random things along the way. (Ones I remember right now are pulling a query outside of a foreach loop in Releeph and fixing the text in UIExample to note that the ace of hearts if "a powerful" card and not the "most powerful" card (Q of spades gets that honor IMO)) Test Plan: tested the first few changes (execute, executeOne X handle, object) then got real mechanical / careful with the other changes. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran, FacebookPOC Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D6941
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationTransactionCommentEditController
|
|
extends PhabricatorApplicationTransactionController {
|
|
|
|
private $phid;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->phid = $data['phid'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$xaction = id(new PhabricatorObjectQuery())
|
|
->withPHIDs(array($this->phid))
|
|
->setViewer($user)
|
|
->executeOne();
|
|
|
|
if (!$xaction) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if (!$xaction->getComment()) {
|
|
// You can't currently edit a transaction which doesn't have a comment.
|
|
// Some day you may be able to edit the visibility.
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$obj_phid = $xaction->getObjectPHID();
|
|
$obj_handle = id(new PhabricatorHandleQuery())
|
|
->setViewer($user)
|
|
->withPHIDs(array($obj_phid))
|
|
->executeOne();
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
$text = $request->getStr('text');
|
|
|
|
$comment = $xaction->getApplicationTransactionCommentObject();
|
|
$comment->setContent($text);
|
|
if (!strlen($text)) {
|
|
$comment->setIsDeleted(true);
|
|
}
|
|
|
|
$editor = id(new PhabricatorApplicationTransactionCommentEditor())
|
|
->setActor($user)
|
|
->setContentSource(PhabricatorContentSource::newFromRequest($request))
|
|
->applyEdit($xaction, $comment);
|
|
|
|
if ($request->isAjax()) {
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
|
->setViewer($user)
|
|
->setTransactions(array($xaction))
|
|
->setAnchorOffset($request->getStr('anchor'));
|
|
} else {
|
|
return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
|
|
}
|
|
}
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($user)
|
|
->setTitle(pht('Edit Comment'));
|
|
|
|
$dialog
|
|
->addHiddenInput('anchor', $request->getStr('anchor'))
|
|
->appendChild(
|
|
id(new PHUIFormLayoutView())
|
|
->setFullWidth(true)
|
|
->appendChild(
|
|
id(new PhabricatorRemarkupControl())
|
|
->setName('text')
|
|
->setValue($xaction->getComment()->getContent())));
|
|
|
|
$dialog
|
|
->addSubmitButton(pht('Edit Comment'))
|
|
->addCancelButton($obj_handle->getURI());
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|