[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/transactions/controller/ -> PhabricatorApplicationTransactionCommentHistoryController.php (source)

   1  <?php
   2  
   3  final class PhabricatorApplicationTransactionCommentHistoryController
   4    extends PhabricatorApplicationTransactionController {
   5  
   6    private $phid;
   7  
   8    public function shouldAllowPublic() {
   9      return true;
  10    }
  11  
  12    public function willProcessRequest(array $data) {
  13      $this->phid = $data['phid'];
  14    }
  15  
  16    public function processRequest() {
  17      $request = $this->getRequest();
  18      $user = $request->getUser();
  19  
  20      $xaction = id(new PhabricatorObjectQuery())
  21        ->withPHIDs(array($this->phid))
  22        ->setViewer($user)
  23        ->executeOne();
  24  
  25      if (!$xaction) {
  26        return new Aphront404Response();
  27      }
  28  
  29      if (!$xaction->getComment()) {
  30        // You can't view history of a transaction with no comments.
  31        return new Aphront404Response();
  32      }
  33  
  34      if ($xaction->getComment()->getIsRemoved()) {
  35        // You can't view history of a transaction with a removed comment.
  36        return new Aphront400Response();
  37      }
  38  
  39      $comments = id(new PhabricatorApplicationTransactionCommentQuery())
  40        ->setViewer($user)
  41        ->setTemplate($xaction->getApplicationTransactionCommentObject())
  42        ->withTransactionPHIDs(array($xaction->getPHID()))
  43        ->execute();
  44  
  45      if (!$comments) {
  46        return new Aphront404Response();
  47      }
  48  
  49      $comments = msort($comments, 'getCommentVersion');
  50  
  51      $xactions = array();
  52      foreach ($comments as $comment) {
  53        $xactions[] = id(clone $xaction)
  54          ->makeEphemeral()
  55          ->setCommentVersion($comment->getCommentVersion())
  56          ->setContentSource($comment->getContentSource())
  57          ->setDateCreated($comment->getDateCreated())
  58          ->attachComment($comment);
  59      }
  60  
  61      $obj_phid = $xaction->getObjectPHID();
  62      $obj_handle = id(new PhabricatorHandleQuery())
  63        ->setViewer($user)
  64        ->withPHIDs(array($obj_phid))
  65        ->executeOne();
  66  
  67      $view = id(new PhabricatorApplicationTransactionView())
  68        ->setUser($user)
  69        ->setObjectPHID($obj_phid)
  70        ->setTransactions($xactions)
  71        ->setShowEditActions(false);
  72  
  73      $dialog = id(new AphrontDialogView())
  74        ->setUser($user)
  75        ->setWidth(AphrontDialogView::WIDTH_FULL)
  76        ->setFlush(true)
  77        ->setTitle(pht('Comment History'));
  78  
  79      $dialog->appendChild($view);
  80  
  81      $dialog
  82        ->addCancelButton($obj_handle->getURI());
  83  
  84      return id(new AphrontDialogResponse())->setDialog($dialog);
  85    }
  86  
  87  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1