Skip to content
Snippets Groups Projects
Commit df0626a6 authored by Yorick Reum's avatar Yorick Reum
Browse files

made disabling action work (with confirm step)

parent 2897c5c2
No related branches found
No related tags found
No related merge requests found
......@@ -196,6 +196,7 @@ class workflow_manager {
*/
public static function handle_action($action, $workflowid) {
global $OUTPUT;
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if ($action === ACTION_WORKFLOW_ACTIVATE) {
self::activate_workflow($workflowid);
}
......@@ -208,6 +209,21 @@ class workflow_manager {
if ($action === ACTION_WORKFLOW_DUPLICATE) {
self::duplicate_workflow($workflowid);
}
if ($action === ACTION_WORKFLOW_DISABLE) {
if ($confirm and confirm_sesskey()) {
self::disable($workflowid);
} else {
self::render_demand_confirm($action, $workflowid, get_string('disableworkflow_confirm', 'tool_lifecycle'));
}
}
if ($action === ACTION_WORKFLOW_ABORTDISABLE) {
if ($confirm and confirm_sesskey()) {
self::abortprocesses($workflowid);
self::disable($workflowid);
} else {
self::render_demand_confirm($action, $workflowid, get_string('abortdisableworkflow_confirm', 'tool_lifecycle'));
}
}
if ($action === ACTION_WORKFLOW_DELETE) {
if (self::is_active($workflowid)) {
echo $OUTPUT->notification(get_string('active_workflow_not_removeable', 'tool_lifecycle')
......@@ -219,6 +235,17 @@ class workflow_manager {
}
}
private static function render_demand_confirm($action, $workflowid, $message)
{
global $OUTPUT, $PAGE;
$yesurl = new \moodle_url($PAGE->url, array('workflowid' => $workflowid, 'action' => $action, 'sesskey' => sesskey(), 'confirm' => 1));
$nourl = new \moodle_url('/admin/tool/lifecycle/adminsettings.php');
$output = $OUTPUT->header();
$output .= $OUTPUT->confirm($message, $yesurl, $nourl);
$output .= $OUTPUT->footer();
echo $output;
}
/**
* Changes the sortindex of a workflow by swapping it with another.
* @param int $workflowid id of the workflow
......
......@@ -41,5 +41,9 @@ if (!$workflow) {
$workflowsettings = new tool_lifecycle\workflow_settings($workflowid);
// Execute the controller.
$workflowsettings->execute(optional_param('action', null, PARAM_TEXT),
optional_param('subplugin', null, PARAM_INT));
\ No newline at end of file
// @TODO what's the purpose of subplugin? why not workflowid?
$subplugin = optional_param('subplugin', null, PARAM_INT);
if($subplugin == null && $workflowid) {
$subplugin = $workflowid;
}
$workflowsettings->execute(optional_param('action', null, PARAM_TEXT), $subplugin);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment