Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   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   * Atto upgrade script.
  19   *
  20   * @package    editor_atto
  21   * @copyright  2014 Damyon Wiese
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  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
  31   */
  32  function xmldb_editor_atto_upgrade($oldversion) {
  33      global $CFG;
  34  
  35      // Automatically generated Moodle v3.6.0 release upgrade line.
  36      // Put any upgrade step following this.
  37  
  38      // Automatically generated Moodle v3.7.0 release upgrade line.
  39      // Put any upgrade step following this.
  40  
  41      if ($oldversion < 2019090900) {
  42          $toolbar = get_config('editor_atto', 'toolbar');
  43  
  44          if (strpos($toolbar, 'h5p') === false) {
  45              $glue = "\r\n";
  46              if (strpos($toolbar, $glue) === false) {
  47                  $glue = "\n";
  48              }
  49              $groups = explode($glue, $toolbar);
  50              // Try to put h5p in the files group.
  51              foreach ($groups as $i => $group) {
  52                  $parts = explode('=', $group);
  53                  if (trim($parts[0]) == 'files') {
  54                      $groups[$i] = 'files = ' . trim($parts[1]) . ', h5p';
  55                      // Update config variable.
  56                      $toolbar = implode($glue, $groups);
  57                      set_config('toolbar', $toolbar, 'editor_atto');
  58                  }
  59              }
  60          }
  61          // Atto editor savepoint reached.
  62          upgrade_plugin_savepoint(true, 2019090900, 'editor', 'atto');
  63      }
  64      // Automatically generated Moodle v3.8.0 release upgrade line.
  65      // Put any upgrade step following this.
  66  
  67      if ($oldversion < 2020052100) {
  68          // The old default toolbar config for 38 and below.
  69          $oldtoolbar = 'collapse = collapse
  70  style1 = title, bold, italic
  71  list = unorderedlist, orderedlist
  72  links = link
  73  files = image, media, recordrtc, managefiles, h5p
  74  style2 = underline, strike, subscript, superscript
  75  align = align
  76  indent = indent
  77  insert = equation, charmap, table, clear
  78  undo = undo
  79  accessibility = accessibilitychecker, accessibilityhelper
  80  other = html';
  81  
  82          // Check if the current toolbar config matches the old toolbar config.
  83          if (get_config('editor_atto', 'toolbar') === $oldtoolbar) {
  84              // If the site is still using the old defaults, upgrade to the new default.
  85              $newtoolbar = 'collapse = collapse
  86  style1 = title, bold, italic
  87  list = unorderedlist, orderedlist, indent
  88  links = link
  89  files = emojipicker, image, media, recordrtc, managefiles, h5p
  90  style2 = underline, strike, subscript, superscript
  91  align = align
  92  insert = equation, charmap, table, clear
  93  undo = undo
  94  accessibility = accessibilitychecker, accessibilityhelper
  95  other = html';
  96              set_config('toolbar', $newtoolbar, 'editor_atto');
  97          }
  98  
  99          upgrade_plugin_savepoint(true, 2020052100, 'editor', 'atto');
 100      }
 101  
 102      // Automatically generated Moodle v3.9.0 release upgrade line.
 103      // Put any upgrade step following this.
 104  
 105      // Automatically generated Moodle v3.10.0 release upgrade line.
 106      // Put any upgrade step following this.
 107  
 108      // Automatically generated Moodle v3.11.0 release upgrade line.
 109      // Put any upgrade step following this.
 110  
 111      return true;
 112  }