@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 82 lines 2.3 kB view raw
1<?php 2 3final class PhabricatorApplicationTransactionCommentHistoryController 4 extends PhabricatorApplicationTransactionController { 5 6 public function shouldAllowPublic() { 7 return true; 8 } 9 10 public function handleRequest(AphrontRequest $request) { 11 $viewer = $this->getViewer(); 12 $phid = $request->getURIData('phid'); 13 14 $xaction = id(new PhabricatorObjectQuery()) 15 ->withPHIDs(array($phid)) 16 ->setViewer($viewer) 17 ->executeOne(); 18 19 if (!$xaction) { 20 return new Aphront404Response(); 21 } 22 23 if (!$xaction->getComment()) { 24 // You can't view history of a transaction with no comments. 25 return new Aphront404Response(); 26 } 27 28 if ($xaction->getComment()->getIsRemoved()) { 29 // You can't view history of a transaction with a removed comment. 30 return new Aphront400Response(); 31 } 32 33 $comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery()) 34 ->setViewer($viewer) 35 ->setTemplate($xaction->getApplicationTransactionCommentObject()) 36 ->withTransactionPHIDs(array($xaction->getPHID())) 37 ->execute(); 38 39 if (!$comments) { 40 return new Aphront404Response(); 41 } 42 43 $comments = msort($comments, 'getCommentVersion'); 44 45 $xactions = array(); 46 foreach ($comments as $comment) { 47 $xactions[] = id(clone $xaction) 48 ->makeEphemeral() 49 ->setCommentVersion($comment->getCommentVersion()) 50 ->setContentSource($comment->getContentSource()) 51 ->setDateCreated($comment->getDateCreated()) 52 ->attachComment($comment); 53 } 54 55 $obj_phid = $xaction->getObjectPHID(); 56 $obj_handle = id(new PhabricatorHandleQuery()) 57 ->setViewer($viewer) 58 ->withPHIDs(array($obj_phid)) 59 ->executeOne(); 60 61 $view = id(new PhabricatorApplicationTransactionView()) 62 ->setUser($viewer) 63 ->setObjectPHID($obj_phid) 64 ->setTransactions($xactions) 65 ->setShowEditActions(false) 66 ->setHideCommentOptions(true); 67 68 $dialog = id(new AphrontDialogView()) 69 ->setUser($viewer) 70 ->setWidth(AphrontDialogView::WIDTH_FULL) 71 ->setFlush(true) 72 ->setTitle(pht('Comment History')); 73 74 $dialog->appendChild($view); 75 76 $dialog 77 ->addCancelButton($obj_handle->getURI()); 78 79 return id(new AphrontDialogResponse())->setDialog($dialog); 80 } 81 82}