Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104089021
HarbormasterPlanDisableController.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
Thu, Mar 6, 10:16
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Mar 8, 10:16 (2 d)
Engine
blob
Format
Raw Data
Handle
24687904
Attached To
rPH Phabricator
HarbormasterPlanDisableController.php
View Options
<?php
final
class
HarbormasterPlanDisableController
extends
HarbormasterPlanController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$this
->
requireApplicationCapability
(
HarbormasterCapabilityManagePlans
::
CAPABILITY
);
$plan
=
id
(
new
HarbormasterBuildPlanQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
executeOne
();
if
(!
$plan
)
{
return
new
Aphront404Response
();
}
$plan_uri
=
$this
->
getApplicationURI
(
'plan/'
.
$plan
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$type_status
=
HarbormasterBuildPlanTransaction
::
TYPE_STATUS
;
$v_status
=
$plan
->
isDisabled
()
?
HarbormasterBuildPlan
::
STATUS_ACTIVE
:
HarbormasterBuildPlan
::
STATUS_DISABLED
;
$xactions
=
array
();
$xactions
[]
=
id
(
new
HarbormasterBuildPlanTransaction
())
->
setTransactionType
(
$type_status
)
->
setNewValue
(
$v_status
);
$editor
=
id
(
new
HarbormasterBuildPlanEditor
())
->
setActor
(
$viewer
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
setContentSourceFromRequest
(
$request
);
$editor
->
applyTransactions
(
$plan
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$plan_uri
);
}
if
(
$plan
->
isDisabled
())
{
$title
=
pht
(
'Enable Build Plan'
);
$body
=
pht
(
'Enable this build plan?'
);
$button
=
pht
(
'Enable Plan'
);
}
else
{
$title
=
pht
(
'Disable Build Plan'
);
$body
=
pht
(
'Disable this build plan? It will no longer be executed '
.
'automatically.'
);
$button
=
pht
(
'Disable Plan'
);
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
$title
)
->
appendChild
(
$body
)
->
addSubmitButton
(
$button
)
->
addCancelButton
(
$plan_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment