[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PhabricatorApplicationTransactionCommentRawController
   4    extends PhabricatorApplicationTransactionController {
   5  
   6    private $phid;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->phid = $data['phid'];
  10    }
  11  
  12    public function processRequest() {
  13      $request = $this->getRequest();
  14      $user = $request->getUser();
  15  
  16      $xaction = id(new PhabricatorObjectQuery())
  17        ->withPHIDs(array($this->phid))
  18        ->setViewer($user)
  19        ->executeOne();
  20  
  21      if (!$xaction) {
  22        return new Aphront404Response();
  23      }
  24  
  25      if (!$xaction->getComment()) {
  26        // You can't view a raw comment if there is no comment.
  27        return new Aphront404Response();
  28      }
  29  
  30      if ($xaction->getComment()->getIsRemoved()) {
  31        // You can't view a raw comment if the comment is deleted.
  32        return new Aphront400Response();
  33      }
  34  
  35      $obj_phid = $xaction->getObjectPHID();
  36      $obj_handle = id(new PhabricatorHandleQuery())
  37        ->setViewer($user)
  38        ->withPHIDs(array($obj_phid))
  39        ->executeOne();
  40  
  41      $title = pht('Raw Comment');
  42      $body = $xaction->getComment()->getContent();
  43      $addendum = null;
  44      if ($request->getExists('email')) {
  45        $content_source = $xaction->getContentSource();
  46        $source_email = PhabricatorContentSource::SOURCE_EMAIL;
  47        if ($content_source->getSource() == $source_email) {
  48          $source_id = $content_source->getParam('id');
  49          if ($source_id) {
  50            $message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere(
  51              'id = %d',
  52              $source_id);
  53            if ($message) {
  54              $title = pht('Email Body Text');
  55              $body = $message->getRawTextBody();
  56              $details_text = pht(
  57                'For full details, run `/bin/mail show-outbound --id %d`',
  58                $source_id);
  59              $addendum = PhabricatorMarkupEngine::renderOneObject(
  60                id(new PhabricatorMarkupOneOff())->setContent($details_text),
  61                'default',
  62                $user);
  63            }
  64          }
  65        }
  66      }
  67      $dialog = id(new AphrontDialogView())
  68        ->setUser($user)
  69        ->addCancelButton($obj_handle->getURI())
  70        ->setTitle($title);
  71  
  72      $dialog
  73        ->addHiddenInput('anchor', $request->getStr('anchor'))
  74        ->appendChild(
  75          id(new PHUIFormLayoutView())
  76          ->setFullWidth(true)
  77          ->appendChild(
  78            id(new AphrontFormTextAreaControl())
  79            ->setReadOnly(true)
  80            ->setValue($body)));
  81      if ($addendum) {
  82        $dialog->appendParagraph($addendum);
  83      }
  84  
  85      return id(new AphrontDialogResponse())->setDialog($dialog);
  86    }
  87  
  88  }


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