2012-12-11 23:01:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationTransactionCommentHistoryController
|
|
|
|
extends PhabricatorApplicationTransactionController {
|
|
|
|
|
2013-09-25 22:44:52 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-02 04:46:57 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$phid = $request->getURIData('phid');
|
2012-12-11 23:01:51 +01:00
|
|
|
|
2013-08-23 01:45:14 +02:00
|
|
|
$xaction = id(new PhabricatorObjectQuery())
|
2015-12-02 04:46:57 +01:00
|
|
|
->withPHIDs(array($phid))
|
|
|
|
->setViewer($viewer)
|
2013-08-23 01:45:14 +02:00
|
|
|
->executeOne();
|
2012-12-11 23:01:51 +01:00
|
|
|
|
|
|
|
if (!$xaction) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$xaction->getComment()) {
|
|
|
|
// You can't view history of a transaction with no comments.
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2014-05-05 19:55:32 +02:00
|
|
|
if ($xaction->getComment()->getIsRemoved()) {
|
|
|
|
// You can't view history of a transaction with a removed comment.
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
2015-03-09 20:15:54 +01:00
|
|
|
$comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery())
|
2015-12-02 04:46:57 +01:00
|
|
|
->setViewer($viewer)
|
2012-12-11 23:01:51 +01:00
|
|
|
->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);
|
|
|
|
}
|
|
|
|
|
2013-08-23 01:45:14 +02:00
|
|
|
$obj_phid = $xaction->getObjectPHID();
|
2013-09-11 21:27:28 +02:00
|
|
|
$obj_handle = id(new PhabricatorHandleQuery())
|
2015-12-02 04:46:57 +01:00
|
|
|
->setViewer($viewer)
|
2013-09-11 21:27:28 +02:00
|
|
|
->withPHIDs(array($obj_phid))
|
|
|
|
->executeOne();
|
2013-08-23 01:45:14 +02:00
|
|
|
|
2012-12-11 23:01:51 +01:00
|
|
|
$view = id(new PhabricatorApplicationTransactionView())
|
2015-12-02 04:46:57 +01:00
|
|
|
->setUser($viewer)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($obj_phid)
|
2012-12-11 23:01:51 +01:00
|
|
|
->setTransactions($xactions)
|
2015-01-12 23:14:36 +01:00
|
|
|
->setShowEditActions(false)
|
|
|
|
->setHideCommentOptions(true);
|
2012-12-11 23:01:51 +01:00
|
|
|
|
|
|
|
$dialog = id(new AphrontDialogView())
|
2015-12-02 04:46:57 +01:00
|
|
|
->setUser($viewer)
|
2012-12-11 23:01:51 +01:00
|
|
|
->setWidth(AphrontDialogView::WIDTH_FULL)
|
2014-08-08 19:21:13 +02:00
|
|
|
->setFlush(true)
|
2012-12-11 23:01:51 +01:00
|
|
|
->setTitle(pht('Comment History'));
|
|
|
|
|
|
|
|
$dialog->appendChild($view);
|
|
|
|
|
|
|
|
$dialog
|
|
|
|
->addCancelButton($obj_handle->getURI());
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|