Skip to content

Commit 653e43d

Browse files
committed
fix sql comparison bug manual trigger, verion.php, upgrade.php
1 parent f908578 commit 653e43d

File tree

23 files changed

+142
-80
lines changed

23 files changed

+142
-80
lines changed

classes/local/manager/trigger_manager.php

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ private static function remove($triggerinstanceid) {
151151
$transaction->allow_commit();
152152
}
153153

154-
155154
/**
156155
* Returns the triggers instances for the workflow id.
157156
* @param int $workflowid Id of the workflow definition.

classes/local/manager/workflow_manager.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public static function get_active_automatic_workflows() {
194194
$records = $DB->get_records_sql(
195195
'SELECT * FROM {tool_lifecycle_workflow}
196196
WHERE timeactive IS NOT NULL AND
197-
manual = ? ORDER BY sortindex', [false]);
197+
manual IS NULL OR manual = 0 ORDER BY sortindex', []);
198198
$result = [];
199199
foreach ($records as $record) {
200200
$result[] = workflow::from_record($record);
@@ -261,9 +261,11 @@ public static function activate_workflow($workflowid) {
261261
$workflow = self::get_workflow($workflowid);
262262
if (!self::is_active($workflow->id)) {
263263
// Software enhancement: Rethink behaviour for multiple triggers.
264-
$trigger = trigger_manager::get_triggers_for_workflow($workflowid)[0];
265-
$lib = lib_manager::get_trigger_lib($trigger->subpluginname);
266-
$workflow->manual = $lib->is_manual_trigger();
264+
$triggers = trigger_manager::get_triggers_for_workflow($workflowid);
265+
foreach ($triggers as $trigger) {
266+
$lib = lib_manager::get_trigger_lib($trigger->subpluginname);
267+
$workflow->manual |= $lib->is_manual_trigger();
268+
}
267269
$workflow->timeactive = time();
268270
if (!$workflow->manual) {
269271
$workflow->sortindex = count(self::get_active_automatic_workflows()) + 1;

classes/local/table/active_automatic_workflows_table.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ class active_automatic_workflows_table extends active_workflows_table {
5050
*/
5151
public function __construct($uniqueid) {
5252
parent::__construct($uniqueid);
53-
global $PAGE, $DB;
54-
list($sqlwheremanual, $paramsmanual) = $DB->get_in_or_equal(false);
55-
$sqlwhere = 'timeactive IS NOT NULL AND manual ' . $sqlwheremanual;
56-
$params[1] = $paramsmanual[0];
53+
global $PAGE;
54+
$sqlwhere = 'timeactive IS NOT NULL AND (manual IS NULL OR manual = 0)';
5755
$this->set_sql("id, title, displaytitle, timeactive, sortindex", '{tool_lifecycle_workflow}',
58-
$sqlwhere, $params);
56+
$sqlwhere, []);
5957
$this->define_baseurl($PAGE->url);
6058
$this->pageable(false);
6159
$this->init();

db/upgrade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
498498

499499
}
500500

501-
if ($oldversion < 2025031300.02) {
501+
if ($oldversion < 2025032400) {
502502

503503
// Changing precision of field instancename on table tool_lifecycle_trigger to (100).
504504
$table = new xmldb_table('tool_lifecycle_trigger');
@@ -526,7 +526,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
526526
// Launch change of precision for field instancename.
527527
$dbman->change_field_precision($table, $field);
528528

529-
upgrade_plugin_savepoint(true, 2025031300.02, 'tool', 'lifecycle');
529+
upgrade_plugin_savepoint(true, 2025032400, 'tool', 'lifecycle');
530530

531531
}
532532

lang/de/tool_lifecycle.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
$string['adminsettings_edit_trigger_instance_heading'] = 'Trigger-Instanz für Workflow \'{$a}\'';
4242
$string['adminsettings_edit_workflow_definition_heading'] = 'Workflowdefinition';
4343
$string['adminsettings_heading'] = 'Workflow-Einstellungen';
44-
$string['adminsettings_nosteps'] = 'Keine zusätzlichen Schritt-Subplugins installiert';
45-
$string['adminsettings_notriggers'] = 'Keine zusätzlichen Trigger-Subplugins installiert';
44+
$string['adminsettings_nosteps'] = 'Keine Schritt-Subplugins installiert';
45+
$string['adminsettings_notriggers'] = 'Keine Trigger-Subplugins installiert';
4646
$string['adminsettings_workflow_definition_steps_heading'] = 'Workflowschritte';
4747
$string['backupcreated'] = 'Erstellt am';
4848
$string['backupworkflow'] = 'Workflow sichern';
@@ -89,8 +89,8 @@
8989
$string['deleteworkflow_confirm'] = 'Sie sind dabei, den Workflow zu löschen. Das kann nicht rückgängig gemacht werden. Sind Sie sicher?';
9090
$string['details:finishdelay'] = 'Verzögerung nach Abschluß';
9191
$string['details:finishdelay_help'] = 'Nachdem ein Kurs einen Workflow beendet, wird er für den angegebenen Zeitraum verzögert.';
92-
$string['details:globaldelay_no'] = 'Diese Verzögerungen gelten <b>nur für diesen Workflow</b>.';
93-
$string['details:globaldelay_yes'] = 'Diese Verzögerungen gelten <b>für alle Workflows</b>.';
92+
$string['details:globaldelay_no'] = 'Diese Verzögerungen gelten nur für diesen Workflow.';
93+
$string['details:globaldelay_yes'] = 'Diese Verzögerungen gelten für alle Workflows.';
9494
$string['details:rollbackdelay'] = 'Verzögerung nach Zurücksetzen';
9595
$string['details:rollbackdelay_help'] = 'Nachdem ein Kurs zurückgesetzt wird, wird er für den angegebenen Zeitraum verzögert.';
9696
$string['disableworkflow'] = 'Workflow deaktivieren (Prozesse laufen weiter)';
@@ -109,7 +109,7 @@
109109
$string['find_course_list_header'] = 'Kurse finden';
110110
$string['followedby_none'] = 'Keine';
111111
$string['forselected'] = 'Für alle ausgewählten Prozesse';
112-
$string['general_config_header'] = "Allgemein & Subplugins";
112+
$string['general_config_header'] = 'Allgemein & Subplugins';
113113
$string['general_settings_header'] = 'Allgemeine Einstellungen';
114114
$string['interaction_success'] = 'Aktion erfolgreich gespeichert.';
115115
$string['invalid_workflow'] = 'Workflowkonfiguration noch nicht aktivierbar';

lang/en/tool_lifecycle.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
$string['adminsettings_edit_trigger_instance_heading'] = 'Trigger for workflow \'{$a}\'';
4242
$string['adminsettings_edit_workflow_definition_heading'] = 'Workflow definition';
4343
$string['adminsettings_heading'] = 'Workflow settings';
44-
$string['adminsettings_nosteps'] = 'No additional step subplugins installed';
45-
$string['adminsettings_notriggers'] = 'No additional trigger subplugins installed';
44+
$string['adminsettings_nosteps'] = 'No step subplugins installed';
45+
$string['adminsettings_notriggers'] = 'No trigger subplugins installed';
4646
$string['adminsettings_workflow_definition_steps_heading'] = 'Workflow steps';
4747
$string['all_delays'] = 'All delays';
4848
$string['anonymous_user'] = 'Anonymous User';
@@ -121,14 +121,14 @@
121121
$string['edit_trigger'] = 'Edit trigger';
122122
$string['editworkflow'] = 'Edit workflow';
123123
$string['error_wrong_trigger_selected'] = 'You tried to request a non-manual trigger.';
124-
$string['errorbackuppath'] = "Error while trying to create the backup directory. You might be missing the permission to do so.
125-
Please check your path at Site administration/Plugins/Admin tools/Life Cycle/General & subplugins/backup_path.";
126-
$string['errornobackup'] = "No backup was created at the specified directory, reasons unknown.";
124+
$string['errorbackuppath'] = 'Error while trying to create the backup directory. You might be missing the permission to do so.
125+
Please check your path at Site administration/Plugins/Admin tools/Life Cycle/General & subplugins/backup_path.';
126+
$string['errornobackup'] = 'No backup was created at the specified directory, reasons unknown.';
127127
$string['find_course_list_header'] = 'Find courses';
128128
$string['followedby_none'] = 'None';
129-
$string['force_import'] = 'Try ignoring errors and import the workflow anyway. <b>Use this at your own risk!</b>';
129+
$string['force_import'] = 'Try ignoring errors and import the workflow anyway. Use this at your own risk!';
130130
$string['forselected'] = 'For all selected processes';
131-
$string['general_config_header'] = "General & subplugins";
131+
$string['general_config_header'] = "General & Subplugins";
132132
$string['general_settings_header'] = 'General settings';
133133
$string['globally'] = 'Global delays';
134134
$string['globally_until_date'] = 'Globally until {$a}';

step/adminapprove/db/upgrade.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Update script for lifecyclestep_adminapprove plugin
19+
*
20+
* @package lifecyclestep_adminapprove
21+
* @copyright 2025 Thomas Niedermaier University of Münster
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
/**
26+
* Update script for lifecyclestep_adminapprove.
27+
* @param int $oldversion Version id of the previously installed version.
28+
* @return bool
29+
* @throws ddl_exception
30+
* @throws ddl_field_missing_exception
31+
* @throws ddl_table_missing_exception
32+
* @throws dml_exception
33+
* @throws downgrade_exception
34+
* @throws upgrade_exception
35+
*/
36+
function xmldb_lifecyclestep_adminapprove_upgrade($oldversion) {
37+
38+
global $DB;
39+
$dbman = $DB->get_manager();
40+
if ($oldversion < 2025032400) {
41+
42+
// Define table lifecyclestep_adminapprove to be created.
43+
$table = new xmldb_table('lifecyclestep_adminapprove');
44+
45+
// Adding fields to table lifecyclestep_adminapprove.
46+
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
47+
$table->add_field('processid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
48+
$table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
49+
50+
// Adding keys to table lifecyclestep_adminapprove.
51+
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
52+
$table->add_key('processid_fk-u', XMLDB_KEY_FOREIGN_UNIQUE, ['processid'], 'tool_lifecycle_process', ['id']);
53+
54+
// Conditionally launch create table for lifecyclestep_adminapprove.
55+
if (!$dbman->table_exists($table)) {
56+
$dbman->create_table($table);
57+
}
58+
59+
// Adminapprove savepoint reached.
60+
upgrade_plugin_savepoint(true, 2025032400, 'lifecyclestep', 'adminapprove');
61+
}
62+
return true;
63+
}

step/adminapprove/version.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->component = 'lifecyclestep_adminapprove';
2929
$plugin->dependencies = [
30-
'tool_lifecycle' => 2025031300,
30+
'tool_lifecycle' => 2025032400,
3131
];
3232
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3333
$plugin->release = 'v4.5-r1';

step/createbackup/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_createbackup';

step/deletecourse/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_deletecourse';

step/duplicate/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecyclestep_duplicate';

step/email/db/upgrade.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ function xmldb_lifecyclestep_email_upgrade($oldversion) {
3737

3838
global $DB;
3939
$dbman = $DB->get_manager();
40-
if ($oldversion < 2024061301) {
40+
if ($oldversion < 2025032400) {
4141
$table = new xmldb_table('lifecyclestep_email_notified');
4242

43-
// Adding fields to table tool_lifecycle_proc_error.
43+
// Adding fields to table lifecyclestep_email_notified.
4444
$table->add_field('id', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
4545
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
4646
$table->add_field('userid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
4747
$table->add_field('timemailsent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
4848

49-
// Adding keys to table tool_lifecycle_proc_error.
49+
// Adding keys to table lifecyclestep_email_notified.
5050
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
5151
$table->add_key('courseid_fk', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
5252
$table->add_key('userid_fk', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
5353

54-
// Conditionally launch create table for tool_lifecycle_proc_error.
54+
// Conditionally launch create table for lifecyclestep_email_notified.
5555
if (!$dbman->table_exists($table)) {
5656
$dbman->create_table($table);
5757
}
5858

5959
// Lifecycle savepoint reached.
60-
upgrade_plugin_savepoint(true, 2024061301, 'tool', 'lifecycle');
60+
upgrade_plugin_savepoint(true, 2025032400, 'lifecyclestep', 'email');
6161
}
6262
return true;
6363
}

step/email/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
defined('MOODLE_INTERNAL') || die;
2626

2727

28-
$plugin->version = 2025031300;
28+
$plugin->version = 2025032400;
2929
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3030
$plugin->component = 'lifecyclestep_email';

templates/workflowoverview.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
{{/showcoursecounts}}
101101
<div class="workflow wf-trigger-wrapper">
102102
{{#trigger}}
103-
<div class="workflow-trigger {{sqlresult}}">
103+
<div class="workflow-trigger {{classfires}}">
104104
<div class="wf-header">
105105
<div class="wf-header-text">
106106
<span>{{#shortentext}} 25, {{instancename}} {{/shortentext}}</span><br>

trigger/categories/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecycletrigger_categories';

trigger/delayedcourses/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525

2626
defined('MOODLE_INTERNAL') || die;
2727

28-
$plugin->version = 2025031300;
28+
$plugin->version = 2025032400;
2929
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3030
$plugin->component = 'lifecycletrigger_delayedcourses';

trigger/manual/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecycletrigger_manual';

trigger/sitecourse/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecycletrigger_sitecourse';

trigger/specificdate/lib.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function extend_add_instance_form_definition($mform) {
143143
$mform->setType('dates', PARAM_TEXT);
144144
$mform->addHelpButton('dates', 'dates', 'lifecycletrigger_specificdate');
145145
// Add activate timelastrun.
146-
$mform->addElement('advcheckbox', 'timelastrunactive', get_string('timelastrunactive', 'lifecycletrigger_specificjku'));
146+
$mform->addElement('advcheckbox', 'timelastrunactive', get_string('timelastrunactive', 'lifecycletrigger_specificdate'));
147147
$mform->setDefault('timelastrunactive', 1);
148148
$mform->addElement('hidden', 'timelastrun');
149149
$mform->setDefault('timelastrun', 0);

trigger/specificdate/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecycletrigger_specificdate';

trigger/startdatedelay/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025031300;
27+
$plugin->version = 2025032400;
2828
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
2929
$plugin->component = 'lifecycletrigger_startdatedelay';

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die;
2626

2727
$plugin->maturity = MATURITY_STABLE;
28-
$plugin->version = 2025031300.03;
28+
$plugin->version = 2025032400;
2929
$plugin->component = 'tool_lifecycle';
3030
$plugin->requires = 2024100700; // Requires Moodle 4.5+.
3131
$plugin->release = 'v4.5-r1';

0 commit comments

Comments
 (0)