MDL-68568 editor_atto: Upgrade step for the new toolbar default layout
authorJun Pataleta <jun@moodle.com>
Wed, 20 May 2020 16:18:52 +0000 (00:18 +0800)
committerJun Pataleta <jun@moodle.com>
Wed, 20 May 2020 16:39:00 +0000 (00:39 +0800)
* emojipicker added to files
* indent moved to list

lib/editor/atto/db/upgrade.php
lib/editor/atto/version.php

index f181ca3..c304197 100644 (file)
@@ -67,5 +67,40 @@ function xmldb_editor_atto_upgrade($oldversion) {
     // Automatically generated Moodle v3.8.0 release upgrade line.
     // Put any upgrade step following this.
 
+    if ($oldversion < 2020052100) {
+        // The old default toolbar config for 38 and below.
+        $oldtoolbar = 'collapse = collapse
+style1 = title, bold, italic
+list = unorderedlist, orderedlist
+links = link
+files = image, media, recordrtc, managefiles, h5p
+style2 = underline, strike, subscript, superscript
+align = align
+indent = indent
+insert = equation, charmap, table, clear
+undo = undo
+accessibility = accessibilitychecker, accessibilityhelper
+other = html';
+
+        // Check if the current toolbar config matches the old toolbar config.
+        if (get_config('editor_atto', 'toolbar') === $oldtoolbar) {
+            // If the site is still using the old defaults, upgrade to the new default.
+            $newtoolbar = 'collapse = collapse
+style1 = title, bold, italic
+list = unorderedlist, orderedlist, indent
+links = link
+files = emojipicker, image, media, recordrtc, managefiles, h5p
+style2 = underline, strike, subscript, superscript
+align = align
+insert = equation, charmap, table, clear
+undo = undo
+accessibility = accessibilitychecker, accessibilityhelper
+other = html';
+            set_config('toolbar', $newtoolbar, 'editor_atto');
+        }
+
+        upgrade_plugin_savepoint(true, 2020052100, 'editor', 'atto');
+    }
+
     return true;
 }
index 904c882..1086322 100644 (file)
@@ -24,6 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2020051200;        // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version   = 2020052100;        // The current plugin version (Date: YYYYMMDDXX).
 $plugin->requires  = 2019111200;        // Requires this Moodle version.
 $plugin->component = 'editor_atto';  // Full name of the plugin (used for diagnostics).