[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DiffusionRepositoryEditDangerousController 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 if (!$repository->canAllowDangerousChanges()) { 27 return new Aphront400Response(); 28 } 29 30 $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); 31 32 if ($request->isFormPost()) { 33 $xaction = id(new PhabricatorRepositoryTransaction()) 34 ->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS) 35 ->setNewValue(!$repository->shouldAllowDangerousChanges()); 36 37 $editor = id(new PhabricatorRepositoryEditor()) 38 ->setContinueOnNoEffect(true) 39 ->setContentSourceFromRequest($request) 40 ->setActor($viewer) 41 ->applyTransactions($repository, array($xaction)); 42 43 return id(new AphrontReloadResponse())->setURI($edit_uri); 44 } 45 46 $dialog = id(new AphrontDialogView()) 47 ->setUser($viewer); 48 49 $force = phutil_tag('tt', array(), '--force'); 50 51 if ($repository->shouldAllowDangerousChanges()) { 52 $dialog 53 ->setTitle(pht('Prevent Dangerous changes?')) 54 ->appendChild( 55 pht( 56 'It will no longer be possible to delete branches from this '. 57 'repository, or %s push to this repository.', 58 $force)) 59 ->addSubmitButton(pht('Prevent Dangerous Changes')) 60 ->addCancelButton($edit_uri); 61 } else { 62 $dialog 63 ->setTitle(pht('Allow Dangerous Changes?')) 64 ->appendChild( 65 pht( 66 'If you allow dangerous changes, it will be possible to delete '. 67 'branches and %s push this repository. These operations can '. 68 'alter a repository in a way that is difficult to recover from.', 69 $force)) 70 ->addSubmitButton(pht('Allow Dangerous Changes')) 71 ->addCancelButton($edit_uri); 72 } 73 74 return id(new AphrontDialogResponse()) 75 ->setDialog($dialog); 76 } 77 78 }
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 |