Skip to content
Snippets Groups Projects
Commit efd11b6b authored by Justus Dieckmann's avatar Justus Dieckmann
Browse files

Only validate editablity of settings when user changes settings in the...

Only validate editablity of settings when user changes settings in the interface; Add editability for trigger
parent 625e6939
No related branches found
No related tags found
No related merge requests found
......@@ -647,7 +647,7 @@ class workflow_settings {
}
step_manager::insert_or_update($step);
// Save local subplugin settings.
settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data);
settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data, true);
} else {
$this->view_step_instance_form($form);
return true;
......
......@@ -186,7 +186,13 @@ class form_trigger_instance extends \moodleform {
// For active workflows, we do not want the form to be editable.
if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) {
// The group buttonar is the array of submit buttons. For inactive workflows this is only a cancel button.
$mform->hardFreezeAllVisibleExcept(array('buttonar'));
$notfreeze = ['buttonar'];
foreach ($this->lib->instance_settings() as $setting) {
if ($setting->editable) {
$notfreeze[] = $setting->name;
}
}
$mform->hardFreezeAllVisibleExcept($notfreeze);
}
}
......
......@@ -58,9 +58,11 @@ class settings_manager {
* @param 'step'|'trigger' $type type of the subplugin.
* @param string $subpluginname name of the subplugin.
* @param mixed $data submitted data of the form.
* @param bool $accessvalidation whether to do only change settings that are editable once the workflow has started.
* Then also calls the on_setting_changed listener. Defaults to false.
* @throws \moodle_exception
*/
public static function save_settings($instanceid, $type, $subpluginname, $data) {
public static function save_settings($instanceid, $type, $subpluginname, $data, $accessvalidation = false) {
global $DB;
self::validate_type($type);
......@@ -88,7 +90,7 @@ class settings_manager {
throw new \moodle_exception('id of the step instance has to be set!');
}
foreach ($settingsfields as $setting) {
if (!$wfeditable && !$setting->editable) {
if ($accessvalidation && !$wfeditable && !$setting->editable) {
continue;
}
if (array_key_exists($setting->name, $data)) {
......@@ -117,7 +119,7 @@ class settings_manager {
$oldvalue = $record->value;
$record->value = $cleanedvalue;
$DB->update_record('tool_lifecycle_settings', $record);
if (!$wfeditable) {
if ($accessvalidation && !$wfeditable) {
$lib->on_setting_changed($setting->name, $cleanedvalue, $oldvalue);
}
}
......
......@@ -51,7 +51,7 @@ $string['general_settings_header'] = 'Allgemeine Einstellungen';
$string['followedby_none'] = 'Keine';
$string['invalid_workflow'] = 'Ungültige Workflowkonfiguration';
$string['invalid_workflow_details'] = 'Gehe zur Detailanzeige, um einen Trigger für diesen Workflow zu erstellen.';
$string['active_workflow_not_changeable'] = 'Die Workflow-Instanz wurde bereits aktiviert. Es ist nicht mehr möglich, Schritte zu ändern.';
$string['active_workflow_not_changeable'] = 'Die Workflow-Instanz wurde bereits aktiviert. Je nach Schritt-Typ können dessen Einstellungen eventuell noch geändert werden.';
$string['active_workflow_not_removeable'] = 'Die Workflow-Instanz ist aktiv. Es ist nicht möglich, sie zu entfernen.';
$string['workflow_not_removeable'] = 'Es ist nicht möglich, diese Workflow-Instanz zu entfernen. Vielleicht hat sie noch laufende Prozesse?';
$string['invalid_workflow_cannot_be_activated'] = 'Der Workflow kann nicht aktiviert werden, da die Workflowdefinition ungültig ist';
......
......@@ -54,7 +54,7 @@ $string['general_settings_header'] = 'General settings';
$string['followedby_none'] = 'None';
$string['invalid_workflow'] = 'Invalid workflow configuration';
$string['invalid_workflow_details'] = 'Go to details view, to create a trigger for this workflow';
$string['active_workflow_not_changeable'] = 'The workflow instance was already activated. It is not possible to change any of its steps anymore.';
$string['active_workflow_not_changeable'] = 'The workflow instance was already activated. Depending on the step type, some of its settings might be still editable.';
$string['active_workflow_not_removeable'] = 'The workflow instance is active. It is not possible to remove it.';
$string['workflow_not_removeable'] = 'It is not possible to remove this workflow instance. Maybe it still has running processes?';
$string['invalid_workflow_cannot_be_activated'] = 'The workflow definition is invalid, thus it cannot be activated.';
......
......@@ -103,8 +103,8 @@ class categories extends base_automatic {
*/
public function instance_settings() {
return array(
new instance_setting('categories', PARAM_SEQUENCE),
new instance_setting('exclude', PARAM_BOOL),
new instance_setting('categories', PARAM_SEQUENCE, true),
new instance_setting('exclude', PARAM_BOOL, true),
);
}
......
......@@ -80,7 +80,7 @@ class startdatedelay extends base_automatic {
*/
public function instance_settings() {
return array(
new instance_setting('delay', PARAM_INT)
new instance_setting('delay', PARAM_INT, true)
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment