Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96194193
DiffusionRepositoryEditDangerousController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 15:48
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 15:48 (2 d)
Engine
blob
Format
Raw Data
Handle
23141893
Attached To
rPH Phabricator
DiffusionRepositoryEditDangerousController.php
View Options
<?php
final
class
DiffusionRepositoryEditDangerousController
extends
DiffusionRepositoryEditController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$drequest
=
$this
->
diffusionRequest
;
$repository
=
$drequest
->
getRepository
();
$repository
=
id
(
new
PhabricatorRepositoryQuery
())
->
setViewer
(
$viewer
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
withIDs
(
array
(
$repository
->
getID
()))
->
executeOne
();
if
(!
$repository
)
{
return
new
Aphront404Response
();
}
if
(!
$repository
->
canAllowDangerousChanges
())
{
return
new
Aphront400Response
();
}
$edit_uri
=
$this
->
getRepositoryControllerURI
(
$repository
,
'edit/'
);
if
(
$request
->
isFormPost
())
{
$xaction
=
id
(
new
PhabricatorRepositoryTransaction
())
->
setTransactionType
(
PhabricatorRepositoryTransaction
::
TYPE_DANGEROUS
)
->
setNewValue
(!
$repository
->
shouldAllowDangerousChanges
());
$editor
=
id
(
new
PhabricatorRepositoryEditor
())
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromRequest
(
$request
)
->
setActor
(
$viewer
)
->
applyTransactions
(
$repository
,
array
(
$xaction
));
return
id
(
new
AphrontReloadResponse
())->
setURI
(
$edit_uri
);
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
);
$force
=
phutil_tag
(
'tt'
,
array
(),
'--force'
);
if
(
$repository
->
shouldAllowDangerousChanges
())
{
$dialog
->
setTitle
(
pht
(
'Prevent Dangerous changes?'
))
->
appendChild
(
pht
(
'It will no longer be possible to delete branches from this '
.
'repository, or %s push to this repository.'
,
$force
))
->
addSubmitButton
(
pht
(
'Prevent Dangerous Changes'
))
->
addCancelButton
(
$edit_uri
);
}
else
{
$dialog
->
setTitle
(
pht
(
'Allow Dangerous Changes?'
))
->
appendChild
(
pht
(
'If you allow dangerous changes, it will be possible to delete '
.
'branches and %s push this repository. These operations can '
.
'alter a repository in a way that is difficult to recover from.'
,
$force
))
->
addSubmitButton
(
pht
(
'Allow Dangerous Changes'
))
->
addCancelButton
(
$edit_uri
);
}
return
id
(
new
AphrontDialogResponse
())
->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment