[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HeraldDisableController extends HeraldController { 4 5 private $id; 6 private $action; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 $this->action = $data['action']; 11 } 12 13 public function processRequest() { 14 $request = $this->getRequest(); 15 $viewer = $request->getUser(); 16 $id = $this->id; 17 18 $rule = id(new HeraldRuleQuery()) 19 ->setViewer($viewer) 20 ->withIDs(array($id)) 21 ->requireCapabilities( 22 array( 23 PhabricatorPolicyCapability::CAN_VIEW, 24 PhabricatorPolicyCapability::CAN_EDIT, 25 )) 26 ->executeOne(); 27 if (!$rule) { 28 return new Aphront404Response(); 29 } 30 31 if ($rule->isGlobalRule()) { 32 $this->requireApplicationCapability( 33 HeraldManageGlobalRulesCapability::CAPABILITY); 34 } 35 36 $view_uri = $this->getApplicationURI("rule/{$id}/"); 37 38 $is_disable = ($this->action === 'disable'); 39 40 if ($request->isFormPost()) { 41 $xaction = id(new HeraldRuleTransaction()) 42 ->setTransactionType(HeraldRuleTransaction::TYPE_DISABLE) 43 ->setNewValue($is_disable); 44 45 id(new HeraldRuleEditor()) 46 ->setActor($viewer) 47 ->setContinueOnNoEffect(true) 48 ->setContentSourceFromRequest($request) 49 ->applyTransactions($rule, array($xaction)); 50 51 return id(new AphrontRedirectResponse())->setURI($view_uri); 52 } 53 54 if ($is_disable) { 55 $title = pht('Really disable this rule?'); 56 $body = pht('This rule will no longer activate.'); 57 $button = pht('Disable Rule'); 58 } else { 59 $title = pht('Really enable this rule?'); 60 $body = pht('This rule will become active again.'); 61 $button = pht('Enable Rule'); 62 } 63 64 $dialog = id(new AphrontDialogView()) 65 ->setUser($viewer) 66 ->setTitle($title) 67 ->appendChild($body) 68 ->addSubmitButton($button) 69 ->addCancelButton($view_uri); 70 71 return id(new AphrontDialogResponse())->setDialog($dialog); 72 } 73 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |