[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterPlanDisableController 4 extends HarbormasterPlanController { 5 6 private $id; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['id']; 10 } 11 12 public function processRequest() { 13 $request = $this->getRequest(); 14 $viewer = $request->getUser(); 15 16 $this->requireApplicationCapability( 17 HarbormasterManagePlansCapability::CAPABILITY); 18 19 $plan = id(new HarbormasterBuildPlanQuery()) 20 ->setViewer($viewer) 21 ->withIDs(array($this->id)) 22 ->executeOne(); 23 if (!$plan) { 24 return new Aphront404Response(); 25 } 26 27 $plan_uri = $this->getApplicationURI('plan/'.$plan->getID().'/'); 28 29 if ($request->isFormPost()) { 30 31 $type_status = HarbormasterBuildPlanTransaction::TYPE_STATUS; 32 33 $v_status = $plan->isDisabled() 34 ? HarbormasterBuildPlan::STATUS_ACTIVE 35 : HarbormasterBuildPlan::STATUS_DISABLED; 36 37 $xactions = array(); 38 39 $xactions[] = id(new HarbormasterBuildPlanTransaction()) 40 ->setTransactionType($type_status) 41 ->setNewValue($v_status); 42 43 $editor = id(new HarbormasterBuildPlanEditor()) 44 ->setActor($viewer) 45 ->setContinueOnNoEffect(true) 46 ->setContinueOnMissingFields(true) 47 ->setContentSourceFromRequest($request); 48 49 $editor->applyTransactions($plan, $xactions); 50 51 return id(new AphrontRedirectResponse())->setURI($plan_uri); 52 } 53 54 if ($plan->isDisabled()) { 55 $title = pht('Enable Build Plan'); 56 $body = pht('Enable this build plan?'); 57 $button = pht('Enable Plan'); 58 } else { 59 $title = pht('Disable Build Plan'); 60 $body = pht( 61 'Disable this build plan? It will no longer be executed '. 62 'automatically.'); 63 $button = pht('Disable Plan'); 64 } 65 66 $dialog = id(new AphrontDialogView()) 67 ->setUser($viewer) 68 ->setTitle($title) 69 ->appendChild($body) 70 ->addSubmitButton($button) 71 ->addCancelButton($plan_uri); 72 73 return id(new AphrontDialogResponse())->setDialog($dialog); 74 } 75 76 }
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 |