[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephProductActionController extends ReleephProductController { 4 5 private $id; 6 private $action; 7 8 public function willProcessRequest(array $data) { 9 $this->id = $data['projectID']; 10 $this->action = $data['action']; 11 } 12 13 public function processRequest() { 14 $request = $this->getRequest(); 15 $viewer = $request->getUser(); 16 17 $product = id(new ReleephProductQuery()) 18 ->withIDs(array($this->id)) 19 ->requireCapabilities( 20 array( 21 PhabricatorPolicyCapability::CAN_VIEW, 22 PhabricatorPolicyCapability::CAN_EDIT, 23 )) 24 ->setViewer($viewer) 25 ->executeOne(); 26 if (!$product) { 27 return new Aphront404Response(); 28 } 29 30 $this->setProduct($product); 31 32 $product_id = $product->getID(); 33 $product_uri = $this->getProductViewURI($product); 34 35 $action = $this->action; 36 switch ($action) { 37 case 'deactivate': 38 case 'activate': 39 break; 40 default: 41 throw new Aphront404Response(); 42 } 43 44 if ($request->isFormPost()) { 45 $type_active = ReleephProductTransaction::TYPE_ACTIVE; 46 47 $xactions = array(); 48 if ($action == 'activate') { 49 $xactions[] = id(new ReleephProductTransaction()) 50 ->setTransactionType($type_active) 51 ->setNewValue(1); 52 } else { 53 $xactions[] = id(new ReleephProductTransaction()) 54 ->setTransactionType($type_active) 55 ->setNewValue(0); 56 } 57 58 $editor = id(new ReleephProductEditor()) 59 ->setActor($viewer) 60 ->setContentSourceFromRequest($request) 61 ->setContinueOnNoEffect(true) 62 ->setContinueOnMissingFields(true); 63 64 $editor->applyTransactions($product, $xactions); 65 66 return id(new AphrontRedirectResponse())->setURI($product_uri); 67 } 68 69 if ($action == 'activate') { 70 $title = pht('Activate Product?'); 71 $body = pht( 72 'Reactivate the product %s?', 73 phutil_tag('strong', array(), $product->getName())); 74 $submit = pht('Reactivate Product'); 75 $short = pht('Deactivate'); 76 } else { 77 $title = pht('Really Deactivate Product?'); 78 $body = pht( 79 'Really deactivate the product %s?', 80 phutil_tag('strong', array(), $product->getName())); 81 $submit = pht('Deactivate Product'); 82 $short = pht('Activate'); 83 } 84 85 return $this->newDialog() 86 ->setTitle($title) 87 ->setShortTitle($short) 88 ->appendParagraph($body) 89 ->addSubmitButton($submit) 90 ->addCancelButton($product_uri); 91 } 92 93 }
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 |