[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/macro/controller/ -> PhabricatorMacroDisableController.php (source)

   1  <?php
   2  
   3  final class PhabricatorMacroDisableController
   4    extends PhabricatorMacroController {
   5  
   6    private $id;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->id = $data['id'];
  10    }
  11  
  12    public function processRequest() {
  13      $this->requireApplicationCapability(
  14        PhabricatorMacroManageCapability::CAPABILITY);
  15  
  16      $request = $this->getRequest();
  17      $user = $request->getUser();
  18  
  19      $macro = id(new PhabricatorMacroQuery())
  20        ->setViewer($user)
  21        ->withIDs(array($this->id))
  22        ->executeOne();
  23      if (!$macro) {
  24        return new Aphront404Response();
  25      }
  26  
  27      $view_uri = $this->getApplicationURI('/view/'.$this->id.'/');
  28  
  29      if ($request->isDialogFormPost() || $macro->getIsDisabled()) {
  30        $xaction = id(new PhabricatorMacroTransaction())
  31          ->setTransactionType(PhabricatorMacroTransactionType::TYPE_DISABLED)
  32          ->setNewValue($macro->getIsDisabled() ? 0 : 1);
  33  
  34        $editor = id(new PhabricatorMacroEditor())
  35          ->setActor($user)
  36          ->setContentSourceFromRequest($request);
  37  
  38        $xactions = $editor->applyTransactions($macro, array($xaction));
  39  
  40        return id(new AphrontRedirectResponse())->setURI($view_uri);
  41      }
  42  
  43      $dialog = new AphrontDialogView();
  44      $dialog
  45        ->setUser($request->getUser())
  46        ->setTitle(pht('Really disable macro?'))
  47        ->appendChild(phutil_tag('p', array(), pht(
  48          'Really disable the much-beloved image macro %s? '.
  49            'It will be sorely missed.',
  50          $macro->getName())))
  51        ->setSubmitURI($this->getApplicationURI('/disable/'.$this->id.'/'))
  52        ->addSubmitButton(pht('Disable'))
  53        ->addCancelButton($view_uri);
  54  
  55      return id(new AphrontDialogResponse())->setDialog($dialog);
  56    }
  57  
  58  }


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