diff --git a/adminlib.php b/adminlib.php index 76afb02e086d0f681dcfa10108e9f9cd03b484f3..f4657ff88b3c334763ffca4feff4c02ee6a5be1c 100644 --- a/adminlib.php +++ b/adminlib.php @@ -636,17 +636,18 @@ class workflow_settings { \core\notification::add( get_string('active_workflow_not_changeable', 'tool_lifecycle'), \core\notification::WARNING); - } else { - if (!empty($data->id)) { - $step = step_manager::get_step_instance($data->id); + } + if (!empty($data->id)) { + $step = step_manager::get_step_instance($data->id); + if ($data->instancename) { $step->instancename = $data->instancename; - } else { - $step = step_subplugin::from_record($data); } - step_manager::insert_or_update($step); - // Save local subplugin settings. - settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data); + } else { + $step = step_subplugin::from_record($data); } + step_manager::insert_or_update($step); + // Save local subplugin settings. + settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data); } else { $this->view_step_instance_form($form); return true; diff --git a/classes/local/form/form_step_instance.php b/classes/local/form/form_step_instance.php index 542817c8446ae647ec03b635aef5dc244ab7e745..6a6fc769dcb052374711e1fa20117352598c0135 100644 --- a/classes/local/form/form_step_instance.php +++ b/classes/local/form/form_step_instance.php @@ -130,11 +130,7 @@ class form_step_instance extends \moodleform { } // For active workflows, we do not want the form to be editable. - if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) { - $this->add_cancel_button(); - } else { - $this->add_action_buttons(); - } + $this->add_action_buttons(); } /** @@ -183,7 +179,13 @@ class form_step_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); } } diff --git a/classes/local/manager/settings_manager.php b/classes/local/manager/settings_manager.php index 7e76238a773697f5c1f81892b320b42a34fb6277..cda7a688629399723486043a3d341b82dbee64ff 100644 --- a/classes/local/manager/settings_manager.php +++ b/classes/local/manager/settings_manager.php @@ -63,6 +63,8 @@ class settings_manager { global $DB; self::validate_type($type); + // TODO before PR merges: Saveguard for changing settings + if (!$data) { return; } diff --git a/step/email/lib.php b/step/email/lib.php index b2477417accffe99e6a1bbc8604ef2635c10cd35..e71040c75c6c82c2c3a7cce3f30c4f0c0623336a 100644 --- a/step/email/lib.php +++ b/step/email/lib.php @@ -221,10 +221,10 @@ class email extends libbase { */ public function instance_settings() { return array( - new instance_setting('responsetimeout', PARAM_INT), - new instance_setting('subject', PARAM_TEXT), - new instance_setting('content', PARAM_RAW), - new instance_setting('contenthtml', PARAM_RAW), + new instance_setting('responsetimeout', PARAM_INT, true), + new instance_setting('subject', PARAM_TEXT, true), + new instance_setting('content', PARAM_RAW, true), + new instance_setting('contenthtml', PARAM_RAW, true), ); } diff --git a/step/lib.php b/step/lib.php index f5cbb9faa2668260d784f6c2db43c84637b7c624..86b20b7def0acb07b80dce00894cadae40a0106e 100644 --- a/step/lib.php +++ b/step/lib.php @@ -149,14 +149,19 @@ class instance_setting { /** @var string param type of the setting, e.g. PARAM_INT */ public $paramtype; + /** @var bool if editable after activation */ + public $editable; + /** * Create a local settings object. * @param string $name name of the setting * @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT. + * @param bool $editable if setting is editable after activation */ - public function __construct($name, $paramtype) { + public function __construct(string $name, string $paramtype, bool $editable = false) { $this->name = $name; $this->paramtype = $paramtype; + $this->editable = $editable; } } diff --git a/trigger/lib.php b/trigger/lib.php index 5ec5ad787bd783f49a9067881211443630b1072f..79e6f9e45337098677638f5c381810fee02a91cb 100644 --- a/trigger/lib.php +++ b/trigger/lib.php @@ -179,14 +179,19 @@ class instance_setting { /** @var string param type of the setting, e.g. PARAM_INT */ public $paramtype; + /** @var bool if editable after activation */ + public $editable; + /** * Create a local settings object. * @param string $name name of the setting * @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT. + * @param bool $editable if setting is editable after activation */ - public function __construct($name, $paramtype) { + public function __construct(string $name, string $paramtype, bool $editable = false) { $this->name = $name; $this->paramtype = $paramtype; + $this->editable = $editable; } }