2222 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323 */
2424
25+ use tool_lifecycle \local \manager \lib_manager ;
26+ use tool_lifecycle \local \manager \trigger_manager ;
27+ use tool_lifecycle \local \manager \workflow_manager ;
28+
2529/**
2630 * Fix any gaps in the workflows sortindex.
2731 */
@@ -36,6 +40,24 @@ function tool_lifecycle_fix_workflow_sortindex() {
3640 }
3741}
3842
43+ /**
44+ * Removes a directory from filesystem
45+ * @param string $dir
46+ * @return void
47+ */
48+ function tool_lifecycle_upgrade_removeDir (string $ dir ): void {
49+ $ it = new RecursiveDirectoryIterator ($ dir , RecursiveDirectoryIterator::SKIP_DOTS );
50+ $ files = new RecursiveIteratorIterator ($ it , RecursiveIteratorIterator::CHILD_FIRST );
51+ foreach ($ files as $ file ) {
52+ if ($ file ->isDir ()){
53+ rmdir ($ file ->getPathname ());
54+ } else {
55+ unlink ($ file ->getPathname ());
56+ }
57+ }
58+ rmdir ($ dir );
59+ }
60+
3961/**
4062 * Update script for tool_lifecycle.
4163 * @param int $oldversion Version id of the previously installed version.
@@ -259,13 +281,13 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
259281 }
260282
261283 if ($ oldversion < 2018022005 ) {
262- $ workflows = \ tool_lifecycle \ local \ manager \ workflow_manager::get_active_workflows ();
284+ $ workflows = workflow_manager::get_active_workflows ();
263285 foreach ($ workflows as $ workflow ) {
264286 if ($ workflow ->manual === null ) {
265- $ trigger = \ tool_lifecycle \ local \ manager \ trigger_manager::get_triggers_for_workflow ($ workflow ->id )[0 ];
266- $ lib = \ tool_lifecycle \ local \ manager \ lib_manager::get_trigger_lib ($ trigger ->subpluginname );
287+ $ trigger = trigger_manager::get_triggers_for_workflow ($ workflow ->id )[0 ];
288+ $ lib = lib_manager::get_trigger_lib ($ trigger ->subpluginname );
267289 $ workflow ->manual = $ lib ->is_manual_trigger ();
268- \ tool_lifecycle \ local \ manager \ workflow_manager::insert_or_update ($ workflow );
290+ workflow_manager::insert_or_update ($ workflow );
269291 }
270292 }
271293 // Lifecycle savepoint reached.
@@ -571,6 +593,14 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
571593 $ dbman ->add_field ($ table , $ field );
572594 }
573595
596+ if ($ dir = core_component::get_plugin_directory ('lifecycletrigger ' , 'sitecourse ' )) {
597+ tool_lifecycle_upgrade_removeDir ($ dir );
598+ }
599+
600+ if ($ dir = core_component::get_plugin_directory ('lifecycletrigger ' , 'delayedcourses ' )) {
601+ tool_lifecycle_upgrade_removeDir ($ dir );
602+ }
603+
574604 upgrade_plugin_savepoint (true , 2025041600 , 'tool ' , 'lifecycle ' );
575605
576606 }
0 commit comments