|
| 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 | + * Remove trigger subplugins sitecourse and delayedcourses. |
| 19 | + * |
| 20 | + * @package tool_lifecycle |
| 21 | + * @copyright 2025 Thomas Niedermaier University Münster |
| 22 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 23 | + */ |
| 24 | + |
| 25 | +require_once(__DIR__ . '/../../../config.php'); |
| 26 | + |
| 27 | +$PAGE->set_context(context_system::instance()); |
| 28 | + |
| 29 | +require_login(null, false); |
| 30 | +require_capability('moodle/site:config', context_system::instance()); |
| 31 | + |
| 32 | +echo "<div>Start ".userdate(time())."</div>"; |
| 33 | + |
| 34 | +// Remove sitecourse subplugin if there is one, otherwise set all workflows to includesitecourse = 1. |
| 35 | +$purgecaches = false; |
| 36 | +$pluginmanager = core_plugin_manager::instance(); |
| 37 | +if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_sitecourse')) { |
| 38 | + echo "<div>Sitecourse Start ".userdate(time())."</div>"; |
| 39 | + $trace = new \null_progress_trace(); |
| 40 | + $plugininfo->uninstall($trace); |
| 41 | + echo "<div>Sitecourse After Plugin uninstall ".userdate(time())."</div>"; |
| 42 | + if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) { |
| 43 | + $pluginmanager->uninstall_plugin($plugininfo->component, $trace); |
| 44 | + $pluginmanager->remove_plugin_folder($plugininfo); |
| 45 | + echo "<div>Sitecourse Removed ".userdate(time())."</div>"; |
| 46 | + } |
| 47 | + $purgecaches = true; |
| 48 | + echo "<div>Sitecourse End ".userdate(time())."</div>"; |
| 49 | +} else { |
| 50 | + echo "<div>Sitecourse No Plugin Found ".userdate(time())."</div>"; |
| 51 | + $DB->set_field('tool_lifecycle_workflow', 'includesitecourse', 1); |
| 52 | +} |
| 53 | + |
| 54 | +// Remove delayedcourses subplugin if there is one, otherwise set all workflows to includedelayedcourses = 1. |
| 55 | +$pluginmanager = core_plugin_manager::instance(); |
| 56 | +if ($plugininfo = $pluginmanager->get_plugin_info('lifecycletrigger_delayedcourses')) { |
| 57 | + echo "<div>Delayedcourses Start ".userdate(time())."</div>"; |
| 58 | + $trace = new \null_progress_trace(); |
| 59 | + $plugininfo->uninstall($trace); |
| 60 | + echo "<div>Delayedcourses After Plugin Uninstall ".userdate(time())."</div>"; |
| 61 | + if ($pluginmanager->is_plugin_folder_removable($plugininfo->component)) { |
| 62 | + $pluginmanager->uninstall_plugin($plugininfo->component, $trace); |
| 63 | + $pluginmanager->remove_plugin_folder($plugininfo); |
| 64 | + echo "<div>Delayedcourses Removed ".userdate(time())."</div>"; |
| 65 | + } |
| 66 | + $purgecaches = true; |
| 67 | + echo "<div>Delayedcourses End ".userdate(time())."</div>"; |
| 68 | +} else { |
| 69 | + echo "<div>Delayedcourses No Plugin Found ".userdate(time())."</div>"; |
| 70 | + $DB->set_field('tool_lifecycle_workflow', 'includedelayedcourses', 1); |
| 71 | +} |
| 72 | + |
| 73 | +if ($purgecaches) { |
| 74 | + echo "<div>Purge Caches ".userdate(time())."</div>"; |
| 75 | + purge_all_caches(); |
| 76 | +} |
| 77 | + |
| 78 | +echo "<div>End ".userdate(time())."</div>"; |
0 commit comments