Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93618598
HeraldDisableController.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
Sat, Nov 30, 05:04
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 05:04 (2 d)
Engine
blob
Format
Raw Data
Handle
22677269
Attached To
rPH Phabricator
HeraldDisableController.php
View Options
<?php
final
class
HeraldDisableController
extends
HeraldController
{
private
$id
;
private
$action
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
$this
->
action
=
$data
[
'action'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$id
=
$this
->
id
;
$rule
=
id
(
new
HeraldRuleQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$rule
)
{
return
new
Aphront404Response
();
}
if
(
$rule
->
isGlobalRule
())
{
$this
->
requireApplicationCapability
(
HeraldCapabilityManageGlobalRules
::
CAPABILITY
);
}
$view_uri
=
$this
->
getApplicationURI
(
"rule/{$id}/"
);
$is_disable
=
(
$this
->
action
===
'disable'
);
if
(
$request
->
isFormPost
())
{
$xaction
=
id
(
new
HeraldRuleTransaction
())
->
setTransactionType
(
HeraldRuleTransaction
::
TYPE_DISABLE
)
->
setNewValue
(
$is_disable
);
id
(
new
HeraldRuleEditor
())
->
setActor
(
$viewer
)
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromRequest
(
$request
)
->
applyTransactions
(
$rule
,
array
(
$xaction
));
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$view_uri
);
}
if
(
$is_disable
)
{
$title
=
pht
(
'Really disable this rule?'
);
$body
=
pht
(
'This rule will no longer activate.'
);
$button
=
pht
(
'Disable Rule'
);
}
else
{
$title
=
pht
(
'Really enable this rule?'
);
$body
=
pht
(
'This rule will become active again.'
);
$button
=
pht
(
'Enable Rule'
);
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
$title
)
->
appendChild
(
$body
)
->
addSubmitButton
(
$button
)
->
addCancelButton
(
$view_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment