Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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   * 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.5.0 release upgrade line.
  36      // Put any upgrade step following this.
  37  
  38      // Automatically generated Moodle v3.6.0 release upgrade line.
  39      // Put any upgrade step following this.
  40  
  41      // Automatically generated Moodle v3.7.0 release upgrade line.
  42      // Put any upgrade step following this.
  43  
  44      if ($oldversion < 2019090900) {
  45          $toolbar = get_config('editor_atto', 'toolbar');
  46  
  47          if (strpos($toolbar, 'h5p') === false) {
  48              $glue = "\r\n";
  49              if (strpos($toolbar, $glue) === false) {
  50                  $glue = "\n";
  51              }
  52              $groups = explode($glue, $toolbar);
  53              // Try to put h5p in the 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]) . ', h5p';
  58                      // Update config variable.
  59                      $toolbar = implode($glue, $groups);
  60                      set_config('toolbar', $toolbar, 'editor_atto');
  61                  }
  62              }
  63          }
  64          // Atto editor savepoint reached.
  65          upgrade_plugin_savepoint(true, 2019090900, 'editor', 'atto');
  66      }
  67      // Automatically generated Moodle v3.8.0 release upgrade line.
  68      // Put any upgrade step following this.
  69  
  70      if ($oldversion < 2020052100) {
  71          // The old default toolbar config for 38 and below.
  72          $oldtoolbar = 'collapse = collapse
  73  style1 = title, bold, italic
  74  list = unorderedlist, orderedlist
  75  links = link
  76  files = image, media, recordrtc, managefiles, h5p
  77  style2 = underline, strike, subscript, superscript
  78  align = align
  79  indent = indent
  80  insert = equation, charmap, table, clear
  81  undo = undo
  82  accessibility = accessibilitychecker, accessibilityhelper
  83  other = html';
  84  
  85          // Check if the current toolbar config matches the old toolbar config.
  86          if (get_config('editor_atto', 'toolbar') === $oldtoolbar) {
  87              // If the site is still using the old defaults, upgrade to the new default.
  88              $newtoolbar = 'collapse = collapse
  89  style1 = title, bold, italic
  90  list = unorderedlist, orderedlist, indent
  91  links = link
  92  files = emojipicker, image, media, recordrtc, managefiles, h5p
  93  style2 = underline, strike, subscript, superscript
  94  align = align
  95  insert = equation, charmap, table, clear
  96  undo = undo
  97  accessibility = accessibilitychecker, accessibilityhelper
  98  other = html';
  99              set_config('toolbar', $newtoolbar, 'editor_atto');
 100          }
 101  
 102          upgrade_plugin_savepoint(true, 2020052100, 'editor', 'atto');
 103      }
 104  
 105      // Automatically generated Moodle v3.9.0 release upgrade line.
 106      // Put any upgrade step following this.
 107  
 108      return true;
 109  }