See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]
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 * Upgrade code for install 19 * 20 * @package tool_usertours 21 * @copyright 2016 Ryan Wyllie <ryan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 use tool_usertours\manager; 28 use tool_usertours\tour; 29 30 /** 31 * Upgrade the user tours plugin. 32 * 33 * @param int $oldversion The old version of the user tours plugin 34 * @return bool 35 */ 36 function xmldb_tool_usertours_upgrade($oldversion) { 37 global $CFG, $DB; 38 39 $dbman = $DB->get_manager(); 40 41 // Automatically generated Moodle v3.9.0 release upgrade line. 42 // Put any upgrade step following this. 43 44 if ($oldversion < 2021052501) { 45 // Clean up user preferences of deleted tours. 46 $select = $DB->sql_like('name', ':lastcompleted') . ' OR ' . $DB->sql_like('name', ':requested'); 47 $params = [ 48 'lastcompleted' => tour::TOUR_LAST_COMPLETED_BY_USER . '%', 49 'requested' => tour::TOUR_REQUESTED_BY_USER . '%', 50 ]; 51 52 $preferences = $DB->get_records_select('user_preferences', $select, $params, '', 'DISTINCT name'); 53 foreach ($preferences as $preference) { 54 // Match tour ID at the end of the preference name, remove all of that preference type if tour ID doesn't exist. 55 if (preg_match('/(?<tourid>\d+)$/', $preference->name, $matches) && 56 !$DB->record_exists('tool_usertours_tours', ['id' => $matches['tourid']])) { 57 58 $DB->delete_records('user_preferences', ['name' => $preference->name]); 59 } 60 } 61 62 upgrade_plugin_savepoint(true, 2021052501, 'tool', 'usertours'); 63 } 64 65 if ($oldversion < 2021092300) { 66 // Define field endtourlabel to be added to tool_usertours_tours. 67 $table = new xmldb_table('tool_usertours_tours'); 68 $field = new xmldb_field('endtourlabel', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'sortorder'); 69 70 // Conditionally launch add field endtourlabel. 71 if (!$dbman->field_exists($table, $field)) { 72 $dbman->add_field($table, $field); 73 } 74 75 // Usertours savepoint reached. 76 upgrade_plugin_savepoint(true, 2021092300, 'tool', 'usertours'); 77 } 78 79 if ($oldversion < 2021100700) { 80 81 // Define field displaystepnumbers to be added to tool_usertours_tours. 82 $table = new xmldb_table('tool_usertours_tours'); 83 $field = new xmldb_field('displaystepnumbers', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'configdata'); 84 85 // Conditionally launch add field displaystepnumbers. 86 if (!$dbman->field_exists($table, $field)) { 87 $dbman->add_field($table, $field); 88 } 89 90 // Usertours savepoint reached. 91 upgrade_plugin_savepoint(true, 2021100700, 'tool', 'usertours'); 92 } 93 94 if ($oldversion < 2022040601) { 95 // Define field contentformat to be added to tool_usertours_steps. 96 $table = new xmldb_table('tool_usertours_steps'); 97 $field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, FORMAT_MOODLE, 'content'); 98 99 // Conditionally launch add field contentformat. 100 if (!$dbman->field_exists($table, $field)) { 101 $dbman->add_field($table, $field); 102 } else { 103 // Field was added by previous upgrade step with the default value is FORMAT_HTML. 104 // Need to drop the field and re-create with the new structure to make sure all the existing tours use FORMAT_MOODLE. 105 // FORMAT_MOODLE will force the external_format_text method to use nl2br to convert the new line to line break tag. 106 $dbman->drop_field($table, $field); 107 // Add the field again. 108 $dbman->add_field($table, $field); 109 } 110 111 // Usertours savepoint reached. 112 upgrade_plugin_savepoint(true, 2022040601, 'tool', 'usertours'); 113 } 114 115 if ($oldversion < 2022040602) { 116 // Update shipped tours. 117 // Normally, we just bump the version numbers because we need to call update_shipped_tours only once. 118 manager::update_shipped_tours(); 119 120 upgrade_plugin_savepoint(true, 2022040602, 'tool', 'usertours'); 121 } 122 123 if ($oldversion < 2022061600) { 124 // Update shipped tours. 125 // Normally, we just bump the version numbers because we need to call update_shipped_tours only once. 126 manager::update_shipped_tours(); 127 128 upgrade_plugin_savepoint(true, 2022061600, 'tool', 'usertours'); 129 } 130 131 // Automatically generated Moodle v4.0.0 release upgrade line. 132 // Put any upgrade step following this. 133 134 // Automatically generated Moodle v4.1.0 release upgrade line. 135 // Put any upgrade step following this. 136 137 return true; 138 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body