Skip to content
Snippets Groups Projects
Commit 8f77fee6 authored by yorickreum's avatar yorickreum
Browse files

started implementing: making it impossible to edit already/former activated workflows

parent 500160b0
Branches
Tags
No related merge requests found
...@@ -314,14 +314,14 @@ class workflow_settings { ...@@ -314,14 +314,14 @@ class workflow_settings {
echo $OUTPUT->heading(get_string('adminsettings_workflow_definition_steps_heading', 'tool_lifecycle')); echo $OUTPUT->heading(get_string('adminsettings_workflow_definition_steps_heading', 'tool_lifecycle'));
if (!workflow_manager::is_active($this->workflowid)) { if (workflow_manager::is_editable($this->workflowid)) {
$triggers = trigger_manager::get_chooseable_trigger_types(); $triggers = trigger_manager::get_chooseable_trigger_types();
echo $OUTPUT->single_select(new \moodle_url($PAGE->url, echo $OUTPUT->single_select(new \moodle_url($PAGE->url,
array('action' => ACTION_TRIGGER_INSTANCE_FORM, 'sesskey' => sesskey(), 'workflowid' => $this->workflowid)), array('action' => ACTION_TRIGGER_INSTANCE_FORM, 'sesskey' => sesskey(), 'workflowid' => $this->workflowid)),
'triggername', $triggers, '', array('' => get_string('add_new_trigger_instance', 'tool_lifecycle'))); 'triggername', $triggers, '', array('' => get_string('add_new_trigger_instance', 'tool_lifecycle')));
} }
if (!workflow_manager::is_active($this->workflowid)) { if (workflow_manager::is_editable($this->workflowid)) {
$steps = step_manager::get_step_types(); $steps = step_manager::get_step_types();
echo $OUTPUT->single_select(new \moodle_url($PAGE->url, echo $OUTPUT->single_select(new \moodle_url($PAGE->url,
array('action' => ACTION_STEP_INSTANCE_FORM, 'sesskey' => sesskey(), 'workflowid' => $this->workflowid)), array('action' => ACTION_STEP_INSTANCE_FORM, 'sesskey' => sesskey(), 'workflowid' => $this->workflowid)),
...@@ -408,6 +408,8 @@ class workflow_settings { ...@@ -408,6 +408,8 @@ class workflow_settings {
* This is the entry point for this controller class. * This is the entry point for this controller class.
*/ */
public function execute($action, $subplugin) { public function execute($action, $subplugin) {
global $OUTPUT;
$this->check_permissions(); $this->check_permissions();
// Handle other actions. // Handle other actions.
...@@ -460,8 +462,8 @@ class workflow_settings { ...@@ -460,8 +462,8 @@ class workflow_settings {
// Skip this part and continue with requiring a trigger if still null. // Skip this part and continue with requiring a trigger if still null.
if (!$form->is_cancelled()) { if (!$form->is_cancelled()) {
if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) { if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) {
// In case the workflow is active, we do not allow changes to the steps or trigger. // In case the workflow was active, we do not allow changes to the steps or trigger.
if (workflow_manager::is_active($this->workflowid)) { if (! workflow_manager::is_editable($this->workflowid)) {
echo $OUTPUT->notification( echo $OUTPUT->notification(
get_string('active_workflow_not_changeable', 'tool_lifecycle'), get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning'); 'warning');
...@@ -515,8 +517,8 @@ class workflow_settings { ...@@ -515,8 +517,8 @@ class workflow_settings {
if ($form->is_cancelled()) { if ($form->is_cancelled()) {
return false; return false;
} else if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) { } else if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) {
// In case the workflow is active, we do not allow changes to the steps or trigger. // In case the workflow was active, we do not allow changes to the steps or trigger.
if (workflow_manager::is_active($this->workflowid)) { if (! workflow_manager::is_editable($this->workflowid)) {
echo $OUTPUT->notification( echo $OUTPUT->notification(
get_string('active_workflow_not_changeable', 'tool_lifecycle'), get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning'); 'warning');
......
...@@ -85,7 +85,8 @@ class form_step_instance extends \moodleform { ...@@ -85,7 +85,8 @@ class form_step_instance extends \moodleform {
$this->lib = lib_manager::get_step_lib($this->subpluginname); $this->lib = lib_manager::get_step_lib($this->subpluginname);
$this->stepsettings = $stepsettings; $this->stepsettings = $stepsettings;
parent::__construct($url); $editable = workflow_manager::is_editable($workflowid);
parent::__construct($url,null, 'post', '', null, $editable);
} }
/** /**
......
...@@ -90,7 +90,8 @@ class form_trigger_instance extends \moodleform { ...@@ -90,7 +90,8 @@ class form_trigger_instance extends \moodleform {
$this->lib = lib_manager::get_trigger_lib($this->subpluginname); $this->lib = lib_manager::get_trigger_lib($this->subpluginname);
} }
parent::__construct($url); $editable = workflow_manager::is_editable($workflowid);
parent::__construct($url,null, 'post', '', null, $editable);
} }
/** /**
......
...@@ -86,10 +86,10 @@ class deactivated_workflows_table extends workflow_table { ...@@ -86,10 +86,10 @@ class deactivated_workflows_table extends workflow_table {
$icon = 't/copy'; $icon = 't/copy';
$output .= $this->format_icon_link($action, $row->id, $icon, $alt); $output .= $this->format_icon_link($action, $row->id, $icon, $alt);
// $action = ACTION_WORKFLOW_INSTANCE_FROM; $action = ACTION_WORKFLOW_INSTANCE_FROM;
// $alt = get_string('editworkflow', 'tool_lifecycle'); $alt = get_string('editworkflow', 'tool_lifecycle');
// $icon = 't/edit'; $icon = 't/edit';
// $output .= $this->format_icon_link($action, $row->id, $icon, $alt); $output .= $this->format_icon_link($action, $row->id, $icon, $alt);
if (!workflow_manager::is_active($row->id)) { if (!workflow_manager::is_active($row->id)) {
$action = ACTION_WORKFLOW_DELETE; // @todo make sure the action checks if no more processes are running $action = ACTION_WORKFLOW_DELETE; // @todo make sure the action checks if no more processes are running
......
...@@ -38,6 +38,11 @@ class step_table extends \table_sql { ...@@ -38,6 +38,11 @@ class step_table extends \table_sql {
/** int workflowid */ /** int workflowid */
private $workflowid; private $workflowid;
/**
* step_table constructor.
* @param string $uniqueid
* @param int $workflowid
*/
public function __construct($uniqueid, $workflowid) { public function __construct($uniqueid, $workflowid) {
parent::__construct($uniqueid); parent::__construct($uniqueid);
global $PAGE, $DB; global $PAGE, $DB;
...@@ -75,7 +80,7 @@ class step_table extends \table_sql { ...@@ -75,7 +80,7 @@ class step_table extends \table_sql {
get_string('step_instancename', 'tool_lifecycle'), get_string('step_instancename', 'tool_lifecycle'),
get_string('step_subpluginname', 'tool_lifecycle'), get_string('step_subpluginname', 'tool_lifecycle'),
]; ];
if (workflow_manager::is_active($this->workflowid)) { if (! workflow_manager::is_editable($this->workflowid)) {
$columns [] = 'show'; $columns [] = 'show';
$headers [] = get_string('step_show', 'tool_lifecycle'); $headers [] = get_string('step_show', 'tool_lifecycle');
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment