Differential D14629 Diff 35408 src/applications/transactions/controller/PhabricatorApplicationTransactionCommentRawController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/controller/PhabricatorApplicationTransactionCommentRawController.php
<?php | <?php | ||||
final class PhabricatorApplicationTransactionCommentRawController | final class PhabricatorApplicationTransactionCommentRawController | ||||
extends PhabricatorApplicationTransactionController { | extends PhabricatorApplicationTransactionController { | ||||
private $phid; | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | |||||
public function willProcessRequest(array $data) { | $phid = $request->getURIData('phid'); | ||||
$this->phid = $data['phid']; | |||||
} | |||||
public function processRequest() { | |||||
$request = $this->getRequest(); | |||||
$user = $request->getUser(); | |||||
$xaction = id(new PhabricatorObjectQuery()) | $xaction = id(new PhabricatorObjectQuery()) | ||||
->withPHIDs(array($this->phid)) | ->withPHIDs(array($phid)) | ||||
->setViewer($user) | ->setViewer($viewer) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$xaction) { | if (!$xaction) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if (!$xaction->getComment()) { | if (!$xaction->getComment()) { | ||||
// You can't view a raw comment if there is no comment. | // You can't view a raw comment if there is no comment. | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if ($xaction->getComment()->getIsRemoved()) { | if ($xaction->getComment()->getIsRemoved()) { | ||||
// You can't view a raw comment if the comment is deleted. | // You can't view a raw comment if the comment is deleted. | ||||
return new Aphront400Response(); | return new Aphront400Response(); | ||||
} | } | ||||
$obj_phid = $xaction->getObjectPHID(); | $obj_phid = $xaction->getObjectPHID(); | ||||
$obj_handle = id(new PhabricatorHandleQuery()) | $obj_handle = id(new PhabricatorHandleQuery()) | ||||
->setViewer($user) | ->setViewer($viewer) | ||||
->withPHIDs(array($obj_phid)) | ->withPHIDs(array($obj_phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
$title = pht('Raw Comment'); | $title = pht('Raw Comment'); | ||||
$body = $xaction->getComment()->getContent(); | $body = $xaction->getComment()->getContent(); | ||||
$addendum = null; | $addendum = null; | ||||
if ($request->getExists('email')) { | if ($request->getExists('email')) { | ||||
$content_source = $xaction->getContentSource(); | $content_source = $xaction->getContentSource(); | ||||
$source_email = PhabricatorContentSource::SOURCE_EMAIL; | $source_email = PhabricatorContentSource::SOURCE_EMAIL; | ||||
if ($content_source->getSource() == $source_email) { | if ($content_source->getSource() == $source_email) { | ||||
$source_id = $content_source->getParam('id'); | $source_id = $content_source->getParam('id'); | ||||
if ($source_id) { | if ($source_id) { | ||||
$message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere( | $message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere( | ||||
'id = %d', | 'id = %d', | ||||
$source_id); | $source_id); | ||||
if ($message) { | if ($message) { | ||||
$title = pht('Email Body Text'); | $title = pht('Email Body Text'); | ||||
$body = $message->getRawTextBody(); | $body = $message->getRawTextBody(); | ||||
$details_text = pht( | $details_text = pht( | ||||
'For full details, run `/bin/mail show-outbound --id %d`', | 'For full details, run `/bin/mail show-outbound --id %d`', | ||||
$source_id); | $source_id); | ||||
$addendum = PhabricatorMarkupEngine::renderOneObject( | $addendum = PhabricatorMarkupEngine::renderOneObject( | ||||
id(new PhabricatorMarkupOneOff())->setContent($details_text), | id(new PhabricatorMarkupOneOff())->setContent($details_text), | ||||
'default', | 'default', | ||||
$user); | $viewer); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$dialog = id(new AphrontDialogView()) | $dialog = id(new AphrontDialogView()) | ||||
->setUser($user) | ->setUser($viewer) | ||||
->addCancelButton($obj_handle->getURI()) | ->addCancelButton($obj_handle->getURI()) | ||||
->setTitle($title); | ->setTitle($title); | ||||
$dialog | $dialog | ||||
->addHiddenInput('anchor', $request->getStr('anchor')) | ->addHiddenInput('anchor', $request->getStr('anchor')) | ||||
->appendChild( | ->appendChild( | ||||
id(new PHUIFormLayoutView()) | id(new PHUIFormLayoutView()) | ||||
->setFullWidth(true) | ->setFullWidth(true) | ||||
Show All 16 Lines |