[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PhabricatorApplicationTransactionCommentRemoveController
   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      $viewer = $request->getUser();
  15  
  16      $xaction = id(new PhabricatorObjectQuery())
  17        ->withPHIDs(array($this->phid))
  18        ->setViewer($viewer)
  19        ->executeOne();
  20      if (!$xaction) {
  21        return new Aphront404Response();
  22      }
  23  
  24      if (!$xaction->getComment()) {
  25        return new Aphront404Response();
  26      }
  27  
  28      if ($xaction->getComment()->getIsRemoved()) {
  29        // You can't remove an already-removed comment.
  30        return new Aphront400Response();
  31      }
  32  
  33      $obj_phid = $xaction->getObjectPHID();
  34      $obj_handle = id(new PhabricatorHandleQuery())
  35        ->setViewer($viewer)
  36        ->withPHIDs(array($obj_phid))
  37        ->executeOne();
  38  
  39      if ($request->isDialogFormPost()) {
  40        $comment = $xaction->getApplicationTransactionCommentObject()
  41          ->setContent('')
  42          ->setIsRemoved(true);
  43  
  44        $editor = id(new PhabricatorApplicationTransactionCommentEditor())
  45          ->setActor($viewer)
  46          ->setContentSource(PhabricatorContentSource::newFromRequest($request))
  47          ->applyEdit($xaction, $comment);
  48  
  49        if ($request->isAjax()) {
  50          return id(new AphrontAjaxResponse())->setContent(array());
  51        } else {
  52          return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
  53        }
  54      }
  55  
  56      $form = id(new AphrontFormView())
  57        ->setUser($viewer);
  58  
  59      $dialog = $this->newDialog()
  60        ->setTitle(pht('Remove Comment'));
  61  
  62      $dialog
  63        ->addHiddenInput('anchor', $request->getStr('anchor'))
  64        ->appendParagraph(
  65          pht(
  66            "Removing a comment prevents anyone (including you) from reading ".
  67            "it. Removing a comment also hides the comment's edit history ".
  68            "and prevents it from being edited."))
  69        ->appendParagraph(
  70          pht('Really remove this comment?'));
  71  
  72      $dialog
  73        ->addSubmitButton(pht('Remove Comment'))
  74        ->addCancelButton($obj_handle->getURI());
  75  
  76      return $dialog;
  77    }
  78  
  79  }


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