1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-11 08:06:13 +01:00
phorge-phorge/src/applications/transactions/controller/PhabricatorApplicationTransactionCommentHistoryController.php
Bob Trahan 320498d3d0 Transactions - make the details stuff generic and ajaxy
Summary: Fixes T2213

Test Plan: Updated a pholio mock description. Observed that when I first showed details there was a round trip made. Toggled show / hide noting no more trips made to server.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T2213

Differential Revision: https://secure.phabricator.com/D6801
2013-08-22 16:45:14 -07:00

77 lines
2.2 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) {
// TODO: This may also mean you don't have permission to edit the object,
// but we can't make that distinction via PhabricatorObjectHandleData
// at the moment.
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 = PhabricatorObjectHandleData::loadOneHandle($obj_phid, $user);
$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);
}
}