From 6390c93cdf348cb2fd21d2bdaa6a462de40621b3 Mon Sep 17 00:00:00 2001
From: Justus Dieckmann <justusdieckmann@wwu.de>
Date: Wed, 12 Jan 2022 02:34:23 +0100
Subject: [PATCH] Fix editable bug in step instance form; Make response time in
 email step not editable

---
 classes/local/form/form_step_instance.php    | 1 -
 classes/local/form/form_trigger_instance.php | 7 +------
 lang/de/tool_lifecycle.php                   | 2 +-
 lang/en/tool_lifecycle.php                   | 2 +-
 step/email/lib.php                           | 2 +-
 5 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/classes/local/form/form_step_instance.php b/classes/local/form/form_step_instance.php
index 6a6fc76..8e64abc 100644
--- a/classes/local/form/form_step_instance.php
+++ b/classes/local/form/form_step_instance.php
@@ -129,7 +129,6 @@ class form_step_instance extends \moodleform {
             $this->lib->extend_add_instance_form_definition($mform);
         }
 
-        // For active workflows, we do not want the form to be editable.
         $this->add_action_buttons();
     }
 
diff --git a/classes/local/form/form_trigger_instance.php b/classes/local/form/form_trigger_instance.php
index 036e256..0ac8f90 100644
--- a/classes/local/form/form_trigger_instance.php
+++ b/classes/local/form/form_trigger_instance.php
@@ -135,12 +135,7 @@ class form_trigger_instance extends \moodleform {
             $this->lib->extend_add_instance_form_definition($mform);
         }
 
-        // 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();
     }
 
     /**
diff --git a/lang/de/tool_lifecycle.php b/lang/de/tool_lifecycle.php
index d4857f1..ebee509 100644
--- a/lang/de/tool_lifecycle.php
+++ b/lang/de/tool_lifecycle.php
@@ -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. Je nach Schritt-Typ können dessen Einstellungen eventuell noch geändert werden.';
+$string['active_workflow_not_changeable'] = 'Die Workflow-Instanz wurde bereits aktiviert. Je nach Schritt-Typ können dessen Einstellungen eventuell noch geändert werden. Änderungen an Trigger-Instanzen wirken sich nicht auf bereits getriggerte Kurse aus.';
 $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';
diff --git a/lang/en/tool_lifecycle.php b/lang/en/tool_lifecycle.php
index 155f270..e5ef763 100644
--- a/lang/en/tool_lifecycle.php
+++ b/lang/en/tool_lifecycle.php
@@ -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. Depending on the step type, some of its settings might be still editable.';
+$string['active_workflow_not_changeable'] = 'The workflow instance was already activated. Depending on the step type, some of its settings might be still editable. Changes to triggers will not affect already triggered courses.';
 $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.';
diff --git a/step/email/lib.php b/step/email/lib.php
index e71040c..89d64f9 100644
--- a/step/email/lib.php
+++ b/step/email/lib.php
@@ -221,7 +221,7 @@ class email extends libbase {
      */
     public function instance_settings() {
         return array(
-            new instance_setting('responsetimeout', PARAM_INT, true),
+            new instance_setting('responsetimeout', PARAM_INT, false),
             new instance_setting('subject', PARAM_TEXT, true),
             new instance_setting('content', PARAM_RAW, true),
             new instance_setting('contenthtml', PARAM_RAW, true),
-- 
GitLab