Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / transactions / controller / PhabricatorApplicationTransactionCommentRawController.php
blobc341079e9e3a45ff17d1a0cfb79bc43e110ff6cc
1 <?php
3 final class PhabricatorApplicationTransactionCommentRawController
4 extends PhabricatorApplicationTransactionController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8 $phid = $request->getURIData('phid');
10 $xaction = id(new PhabricatorObjectQuery())
11 ->withPHIDs(array($phid))
12 ->setViewer($viewer)
13 ->executeOne();
15 if (!$xaction) {
16 return new Aphront404Response();
19 if (!$xaction->getComment()) {
20 // You can't view a raw comment if there is no comment.
21 return new Aphront404Response();
24 if ($xaction->getComment()->getIsRemoved()) {
25 // You can't view a raw comment if the comment is deleted.
26 return new Aphront400Response();
29 $obj_phid = $xaction->getObjectPHID();
30 $obj_handle = id(new PhabricatorHandleQuery())
31 ->setViewer($viewer)
32 ->withPHIDs(array($obj_phid))
33 ->executeOne();
35 $title = pht('Raw Comment');
36 $body = $xaction->getComment()->getContent();
37 $addendum = null;
38 if ($request->getExists('email')) {
39 $content_source = $xaction->getContentSource();
40 $source_email = PhabricatorEmailContentSource::SOURCECONST;
41 if ($content_source->getSource() == $source_email) {
42 $source_id = $content_source->getContentSourceParameter('id');
43 if ($source_id) {
44 $message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere(
45 'id = %d',
46 $source_id);
47 if ($message) {
48 $title = pht('Email Body Text');
49 $body = $message->getRawTextBody();
50 $details_text = pht(
51 'For full details, run `/bin/mail show-inbound --id %d`',
52 $source_id);
53 $addendum = new PHUIRemarkupView($viewer, $details_text);
58 $dialog = id(new AphrontDialogView())
59 ->setUser($viewer)
60 ->addCancelButton($obj_handle->getURI())
61 ->setTitle($title);
63 $dialog
64 ->addHiddenInput('anchor', $request->getStr('anchor'))
65 ->appendChild(
66 id(new PHUIFormLayoutView())
67 ->setFullWidth(true)
68 ->appendChild(
69 id(new AphrontFormTextAreaControl())
70 ->setReadOnly(true)
71 ->setValue($body)));
72 if ($addendum) {
73 $dialog->appendParagraph($addendum);
76 return id(new AphrontDialogResponse())->setDialog($dialog);
79 public function shouldAllowPublic() {
80 return true;