MDL-62478 upgrade: add 3.5.0 separation line to all upgrade scripts
[moodle.git] / lib / editor / atto / db / upgrade.php
blob1ae13a6a7a083d10d3680510c06a16cdbc1f4c4a
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.
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/>.
17 /**
18 * Atto upgrade script.
20 * @package editor_atto
21 * @copyright 2014 Damyon Wiese
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Run all Atto upgrade steps between the current DB version and the current version on disk.
29 * @param int $oldversion The old version of atto in the DB.
30 * @return bool
32 function xmldb_editor_atto_upgrade($oldversion) {
33 global $CFG;
35 // Automatically generated Moodle v3.2.0 release upgrade line.
36 // Put any upgrade step following this.
38 // Automatically generated Moodle v3.3.0 release upgrade line.
39 // Put any upgrade step following this.
41 // Automatically generated Moodle v3.4.0 release upgrade line.
42 // Put any upgrade step following this.
44 if ($oldversion < 2018041100) {
45 $toolbar = get_config('editor_atto', 'toolbar');
47 if (strpos($toolbar, 'recordrtc') === false) {
48 $glue = "\r\n";
49 if (strpos($toolbar, $glue) === false) {
50 $glue = "\n";
52 $groups = explode($glue, $toolbar);
53 // Try to put recordrtc in files group.
54 foreach ($groups as $i => $group) {
55 $parts = explode('=', $group);
56 if (trim($parts[0]) == 'files') {
57 $groups[$i] = 'files = ' . trim($parts[1]) . ', recordrtc';
58 // Update config variable.
59 $toolbar = implode($glue, $groups);
60 set_config('toolbar', $toolbar, 'editor_atto');
65 // Atto editor savepoint reached.
66 upgrade_plugin_savepoint(true, 2018041100, 'editor', 'atto');
69 if ($oldversion < 2018051401) {
70 $toolbar = get_config('editor_atto', 'toolbar');
71 $glue = "\r\n";
72 $iconorderold = 'image, media, managefiles, recordrtc';
73 $iconordernew = 'image, media, recordrtc, managefiles';
75 if (strpos($toolbar, $glue) === false) {
76 $glue = "\n";
79 $groups = explode($glue, $toolbar);
81 // Reorder atto media icons if in default configuration.
82 foreach ($groups as $i => $group) {
83 $parts = explode('=', $group);
85 if (trim($parts[0]) == 'files') {
86 if (trim(preg_replace('/,\s*/', ', ', $parts[1])) == $iconorderold) {
87 $groups[$i] = 'files = ' . $iconordernew;
89 // Update config variable.
90 $toolbar = implode($glue, $groups);
91 set_config('toolbar', $toolbar, 'editor_atto');
96 // Atto editor savepoint reached.
97 upgrade_plugin_savepoint(true, 2018051401, 'editor', 'atto');
100 // Automatically generated Moodle v3.5.0 release upgrade line.
101 // Put any upgrade step following this.
103 return true;