Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / controller / DiffusionRepositoryEditDangerousController.php
blob9503a9e3863828ef80c018d1900d8c66c2a9316b
1 <?php
3 final class DiffusionRepositoryEditDangerousController
4 extends DiffusionRepositoryManageController {
6 public function handleRequest(AphrontRequest $request) {
7 $response = $this->loadDiffusionContextForEdit();
8 if ($response) {
9 return $response;
12 $viewer = $this->getViewer();
13 $drequest = $this->getDiffusionRequest();
14 $repository = $drequest->getRepository();
16 $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
17 ->setRepository($repository)
18 ->getPanelURI();
20 if (!$repository->canAllowDangerousChanges()) {
21 return $this->newDialog()
22 ->setTitle(pht('Unprotectable Repository'))
23 ->appendParagraph(
24 pht(
25 'This repository can not be protected from dangerous changes '.
26 'because Phabricator does not control what users are allowed '.
27 'to push to it.'))
28 ->addCancelButton($panel_uri);
31 if ($request->isFormPost()) {
32 $xaction = id(new PhabricatorRepositoryTransaction())
33 ->setTransactionType(
34 PhabricatorRepositoryDangerousTransaction::TRANSACTIONTYPE)
35 ->setNewValue(!$repository->shouldAllowDangerousChanges());
37 $editor = id(new PhabricatorRepositoryEditor())
38 ->setContinueOnNoEffect(true)
39 ->setContentSourceFromRequest($request)
40 ->setActor($viewer)
41 ->applyTransactions($repository, array($xaction));
43 return id(new AphrontReloadResponse())->setURI($panel_uri);
46 $force = phutil_tag('tt', array(), '--force');
48 if ($repository->shouldAllowDangerousChanges()) {
49 $title = pht('Prevent Dangerous Changes');
51 if ($repository->isSVN()) {
52 $body = pht(
53 'It will no longer be possible to edit revprops in this '.
54 'repository.');
55 } else {
56 $body = pht(
57 'It will no longer be possible to delete branches from this '.
58 'repository, or %s push to this repository.',
59 $force);
62 $submit = pht('Prevent Dangerous Changes');
63 } else {
64 $title = pht('Allow Dangerous Changes');
65 if ($repository->isSVN()) {
66 $body = pht(
67 'If you allow dangerous changes, it will be possible to edit '.
68 'reprops in this repository, including arbitrarily rewriting '.
69 'commit messages. These operations can alter a repository in a '.
70 'way that is difficult to recover from.');
71 } else {
72 $body = pht(
73 'If you allow dangerous changes, it will be possible to delete '.
74 'branches and %s push this repository. These operations can '.
75 'alter a repository in a way that is difficult to recover from.',
76 $force);
78 $submit = pht('Allow Dangerous Changes');
81 return $this->newDialog()
82 ->setTitle($title)
83 ->appendParagraph($body)
84 ->addSubmitButton($submit)
85 ->addCancelButton($panel_uri);