Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php
12242 views
1
<?php
2
3
final class DiffusionRepositoryEditDangerousController
4
extends DiffusionRepositoryManageController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$response = $this->loadDiffusionContextForEdit();
8
if ($response) {
9
return $response;
10
}
11
12
$viewer = $this->getViewer();
13
$drequest = $this->getDiffusionRequest();
14
$repository = $drequest->getRepository();
15
16
$panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
17
->setRepository($repository)
18
->getPanelURI();
19
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 this server does not control what users are allowed '.
27
'to push to it.'))
28
->addCancelButton($panel_uri);
29
}
30
31
if ($request->isFormPost()) {
32
$xaction = id(new PhabricatorRepositoryTransaction())
33
->setTransactionType(
34
PhabricatorRepositoryDangerousTransaction::TRANSACTIONTYPE)
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($panel_uri);
44
}
45
46
$force = phutil_tag('tt', array(), '--force');
47
48
if ($repository->shouldAllowDangerousChanges()) {
49
$title = pht('Prevent Dangerous Changes');
50
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);
60
}
61
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);
77
}
78
$submit = pht('Allow Dangerous Changes');
79
}
80
81
return $this->newDialog()
82
->setTitle($title)
83
->appendParagraph($body)
84
->addSubmitButton($submit)
85
->addCancelButton($panel_uri);
86
}
87
88
}
89
90