From 5081de00d78f1f532713a4a7e018b65e3b5fb554 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 28 Mar 2014 16:04:29 +0800 Subject: [PATCH] MDL-44748 Atto: Make it the default on upgrade. --- lib/editor/atto/db/install.php | 50 +++++++++++++++++++++++++++++++ lib/editor/atto/db/upgrade.php | 55 ++++++++++++++++++++++++++++++++++ lib/editor/atto/version.php | 2 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 lib/editor/atto/db/install.php create mode 100644 lib/editor/atto/db/upgrade.php diff --git a/lib/editor/atto/db/install.php b/lib/editor/atto/db/install.php new file mode 100644 index 00000000000..ad890400d96 --- /dev/null +++ b/lib/editor/atto/db/install.php @@ -0,0 +1,50 @@ +. + +/** + * Atto upgrade script. + * + * @package editor_atto + * @copyright 2014 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Make the Atto the default editor for upgrades from 26. + * + * @return bool + */ +function xmldb_editor_atto_install() { + global $CFG; + + // Make Atto the default. + $currenteditors = $CFG->texteditors; + $neweditors = array(); + + $list = explode(',', $currenteditors); + array_push($neweditors, 'atto'); + foreach ($list as $editor) { + if ($editor != 'atto') { + array_push($neweditors, $editor); + } + } + + set_config('texteditors', implode(',', $neweditors)); + + return true; +} diff --git a/lib/editor/atto/db/upgrade.php b/lib/editor/atto/db/upgrade.php new file mode 100644 index 00000000000..fc738c1587d --- /dev/null +++ b/lib/editor/atto/db/upgrade.php @@ -0,0 +1,55 @@ +. + +/** + * Atto upgrade script. + * + * @package editor_atto + * @copyright 2014 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Run all Atto upgrade steps between the current DB version and the current version on disk. + * @param int $oldversion The old version of atto in the DB. + * @return bool + */ +function xmldb_editor_atto_upgrade($oldversion) { + global $CFG, $DB; + + $dbman = $DB->get_manager(); + + if ($oldversion < 2014032800) { + // Make Atto the default. + $currenteditors = $CFG->texteditors; + $neweditors = array(); + + $list = explode(',', $currenteditors); + array_push($neweditors, 'atto'); + foreach ($list as $editor) { + if ($editor != 'atto') { + array_push($neweditors, $editor); + } + } + + set_config('texteditors', implode(',', $neweditors)); + upgrade_plugin_savepoint(true, 2014032800, 'editor', 'atto'); + } + + return true; +} diff --git a/lib/editor/atto/version.php b/lib/editor/atto/version.php index c2112cb401c..3476671e0f5 100644 --- a/lib/editor/atto/version.php +++ b/lib/editor/atto/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014012800; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2014032800; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2013110500; // Requires this Moodle version. $plugin->component = 'editor_atto'; // Full name of the plugin (used for diagnostics).