From 1d8ee52e4f869e6c980f356c328768cf7b7e5ead Mon Sep 17 00:00:00 2001
From: Tobias Reischmann <tobias.reischmann@wi.uni-muenster.de>
Date: Wed, 28 Aug 2019 18:07:48 +0200
Subject: [PATCH] Show cancle button in non-editing mode of step and trigger
 forms

---
 classes/form/form_step_instance.php    | 7 +++----
 classes/form/form_trigger_instance.php | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/classes/form/form_step_instance.php b/classes/form/form_step_instance.php
index 9d3b6e4..010558d 100644
--- a/classes/form/form_step_instance.php
+++ b/classes/form/form_step_instance.php
@@ -88,8 +88,7 @@ class form_step_instance extends \moodleform {
         $this->lib = lib_manager::get_step_lib($this->subpluginname);
         $this->stepsettings = $stepsettings;
 
-        $editable = workflow_manager::is_editable($workflowid);
-        parent::__construct($url, null, 'post', '', null, $editable);
+        parent::__construct($url, null, 'post', '', null);
     }
 
     /**
@@ -130,7 +129,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_active($this->workflowid)) {
+        if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) {
             $this->add_cancel_button();
         } else {
             $this->add_action_buttons();
@@ -181,7 +180,7 @@ class form_step_instance extends \moodleform {
         $this->lib->extend_add_instance_form_definition_after_data($mform, $this->stepsettings);
 
         // For active workflows, we do not want the form to be editable.
-        if ($this->workflowid && workflow_manager::is_active($this->workflowid)) {
+        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'));
         }
diff --git a/classes/form/form_trigger_instance.php b/classes/form/form_trigger_instance.php
index e15a04b..3ca5047 100644
--- a/classes/form/form_trigger_instance.php
+++ b/classes/form/form_trigger_instance.php
@@ -93,8 +93,7 @@ class form_trigger_instance extends \moodleform {
             $this->lib = lib_manager::get_trigger_lib($this->subpluginname);
         }
 
-        $editable = workflow_manager::is_editable($workflowid);
-        parent::__construct($url, null, 'post', '', null, $editable);
+        parent::__construct($url, null, 'post', '', null);
     }
 
     /**
@@ -136,7 +135,7 @@ class form_trigger_instance extends \moodleform {
         }
 
         // For active workflows, we do not want the form to be editable.
-        if ($this->workflowid && workflow_manager::is_active($this->workflowid)) {
+        if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) {
             $this->add_cancel_button();
         } else {
             $this->add_action_buttons();
@@ -184,7 +183,7 @@ class form_trigger_instance extends \moodleform {
         }
 
         // For active workflows, we do not want the form to be editable.
-        if ($this->workflowid && workflow_manager::is_active($this->workflowid)) {
+        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'));
         }
-- 
GitLab