[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DiffusionRepositoryEditActionsController 4 extends DiffusionRepositoryEditController { 5 6 public function processRequest() { 7 $request = $this->getRequest(); 8 $viewer = $request->getUser(); 9 $drequest = $this->diffusionRequest; 10 $repository = $drequest->getRepository(); 11 12 $repository = id(new PhabricatorRepositoryQuery()) 13 ->setViewer($viewer) 14 ->requireCapabilities( 15 array( 16 PhabricatorPolicyCapability::CAN_VIEW, 17 PhabricatorPolicyCapability::CAN_EDIT, 18 )) 19 ->withIDs(array($repository->getID())) 20 ->executeOne(); 21 22 if (!$repository) { 23 return new Aphront404Response(); 24 } 25 26 $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); 27 28 // NOTE: We're inverting these here, because the storage is silly. 29 $v_notify = !$repository->getHumanReadableDetail('herald-disabled'); 30 $v_autoclose = !$repository->getHumanReadableDetail('disable-autoclose'); 31 32 if ($request->isFormPost()) { 33 $v_notify = $request->getBool('notify'); 34 $v_autoclose = $request->getBool('autoclose'); 35 36 $xactions = array(); 37 $template = id(new PhabricatorRepositoryTransaction()); 38 39 $type_notify = PhabricatorRepositoryTransaction::TYPE_NOTIFY; 40 $type_autoclose = PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE; 41 42 $xactions[] = id(clone $template) 43 ->setTransactionType($type_notify) 44 ->setNewValue($v_notify); 45 46 $xactions[] = id(clone $template) 47 ->setTransactionType($type_autoclose) 48 ->setNewValue($v_autoclose); 49 50 id(new PhabricatorRepositoryEditor()) 51 ->setContinueOnNoEffect(true) 52 ->setContentSourceFromRequest($request) 53 ->setActor($viewer) 54 ->applyTransactions($repository, $xactions); 55 56 return id(new AphrontRedirectResponse())->setURI($edit_uri); 57 } 58 59 $content = array(); 60 61 $crumbs = $this->buildApplicationCrumbs(); 62 $crumbs->addTextCrumb(pht('Edit Actions')); 63 64 $title = pht('Edit Actions (%s)', $repository->getName()); 65 66 $policies = id(new PhabricatorPolicyQuery()) 67 ->setViewer($viewer) 68 ->setObject($repository) 69 ->execute(); 70 71 $form = id(new AphrontFormView()) 72 ->setUser($viewer) 73 ->appendRemarkupInstructions( 74 pht( 75 "Normally, Phabricator publishes notifications when it discovers ". 76 "new commits. You can disable publishing for this repository by ". 77 "turning off **Notify/Publish**. This will disable notifications, ". 78 "feed, and Herald (including audits and build plans) for this ". 79 "repository.". 80 "\n\n". 81 "When Phabricator discovers a new commit, it can automatically ". 82 "close associated revisions and tasks. If you don't want ". 83 "Phabricator to close objects when it discovers new commits in ". 84 "this repository, you can disable **Autoclose**.")) 85 ->appendChild( 86 id(new AphrontFormSelectControl()) 87 ->setName('notify') 88 ->setLabel(pht('Notify/Publish')) 89 ->setValue((int)$v_notify) 90 ->setOptions( 91 array( 92 1 => pht('Enable Notifications, Feed and Herald'), 93 0 => pht('Disable Notifications, Feed and Herald'), 94 ))) 95 ->appendChild( 96 id(new AphrontFormSelectControl()) 97 ->setName('autoclose') 98 ->setLabel(pht('Autoclose')) 99 ->setValue((int)$v_autoclose) 100 ->setOptions( 101 array( 102 1 => pht('Enable Autoclose'), 103 0 => pht('Disable Autoclose'), 104 ))) 105 ->appendChild( 106 id(new AphrontFormSubmitControl()) 107 ->setValue(pht('Save Actions')) 108 ->addCancelButton($edit_uri)); 109 110 $form_box = id(new PHUIObjectBoxView()) 111 ->setHeaderText($title) 112 ->setForm($form); 113 114 return $this->buildApplicationPage( 115 array( 116 $crumbs, 117 $form_box, 118 ), 119 array( 120 'title' => $title, 121 )); 122 } 123 124 }
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 |