[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/releeph/controller/branch/ -> ReleephBranchAccessController.php (source)

   1  <?php
   2  
   3  final class ReleephBranchAccessController extends ReleephBranchController {
   4  
   5    private $action;
   6    private $branchID;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->action = $data['action'];
  10      $this->branchID = $data['branchID'];
  11    }
  12  
  13    public function processRequest() {
  14      $request = $this->getRequest();
  15      $viewer = $request->getUser();
  16  
  17      $branch = id(new ReleephBranchQuery())
  18        ->setViewer($viewer)
  19        ->withIDs(array($this->branchID))
  20        ->requireCapabilities(
  21          array(
  22            PhabricatorPolicyCapability::CAN_VIEW,
  23            PhabricatorPolicyCapability::CAN_EDIT,
  24          ))
  25        ->executeOne();
  26      if (!$branch) {
  27        return new Aphront404Response();
  28      }
  29      $this->setBranch($branch);
  30  
  31      $action = $this->action;
  32      switch ($action) {
  33        case 'close':
  34        case 're-open':
  35          break;
  36        default:
  37          return new Aphront404Response();
  38      }
  39  
  40      $branch_uri = $this->getBranchViewURI($branch);
  41      if ($request->isFormPost()) {
  42  
  43        if ($action == 're-open') {
  44          $is_active = 1;
  45        } else {
  46          $is_active = 0;
  47        }
  48  
  49        id(new ReleephBranchEditor())
  50          ->setActor($request->getUser())
  51          ->setReleephBranch($branch)
  52          ->changeBranchAccess($is_active);
  53  
  54        return id(new AphrontReloadResponse())->setURI($branch_uri);
  55      }
  56  
  57      if ($action == 'close') {
  58        $title_text = pht('Really Close Branch?');
  59        $short = pht('Close Branch');
  60        $body_text = pht(
  61          'Really close the branch "%s"?',
  62          phutil_tag('strong', array(), $branch->getBasename()));
  63        $button_text = pht('Close Branch');
  64      } else {
  65        $title_text = pht('Really Reopen Branch?');
  66        $short = pht('Reopen Branch');
  67        $body_text = pht(
  68          'Really reopen the branch "%s"?',
  69          phutil_tag('strong', array(), $branch->getBasename()));
  70        $button_text = pht('Reopen Branch');
  71      }
  72  
  73      return $this->newDialog()
  74        ->setTitle($title_text)
  75        ->setShortTitle($short)
  76        ->appendChild($body_text)
  77        ->addSubmitButton($button_text)
  78        ->addCancelButton($branch_uri);
  79    }
  80  
  81  }


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