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
78 lines
2.0 KiB
PHP
78 lines
2.0 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationTransactionCommentHistoryController
|
|
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 view history of a transaction with no comments.
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$comments = id(new PhabricatorApplicationTransactionCommentQuery())
|
|
->setViewer($user)
|
|
->setTemplate($xaction->getApplicationTransactionCommentObject())
|
|
->withTransactionPHIDs(array($xaction->getPHID()))
|
|
->execute();
|
|
|
|
if (!$comments) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$comments = msort($comments, 'getCommentVersion');
|
|
|
|
$xactions = array();
|
|
foreach ($comments as $comment) {
|
|
$xactions[] = id(clone $xaction)
|
|
->makeEphemeral()
|
|
->setCommentVersion($comment->getCommentVersion())
|
|
->setContentSource($comment->getContentSource())
|
|
->setDateCreated($comment->getDateCreated())
|
|
->attachComment($comment);
|
|
}
|
|
|
|
$obj_phid = $xaction->getObjectPHID();
|
|
$obj_handle = id(new PhabricatorHandleQuery())
|
|
->setViewer($user)
|
|
->withPHIDs(array($obj_phid))
|
|
->executeOne();
|
|
|
|
$view = id(new PhabricatorApplicationTransactionView())
|
|
->setUser($user)
|
|
->setObjectPHID($obj_phid)
|
|
->setTransactions($xactions)
|
|
->setShowEditActions(false);
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($user)
|
|
->setWidth(AphrontDialogView::WIDTH_FULL)
|
|
->setTitle(pht('Comment History'));
|
|
|
|
$dialog->appendChild($view);
|
|
|
|
$dialog
|
|
->addCancelButton($obj_handle->getURI());
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|