Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
/admin/ -> editors.php (source)
<?php
> // This file is part of Moodle - http://moodle.org/ > // /** > // Moodle is free software: you can redistribute it and/or modify * Allows admin to configure editors. > // it under the terms of the GNU General Public License as published by */ > // the Free Software Foundation, either version 3 of the License, or > // (at your option) any later version. require_once('../config.php'); > // require_once($CFG->libdir.'/adminlib.php'); > // Moodle is distributed in the hope that it will be useful, require_once($CFG->libdir.'/tablelib.php'); > // but WITHOUT ANY WARRANTY; without even the implied warranty of > // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the $action = required_param('action', PARAM_ALPHANUMEXT); > // GNU General Public License for more details. $editor = required_param('editor', PARAM_PLUGIN); > // $confirm = optional_param('confirm', 0, PARAM_BOOL); > // You should have received a copy of the GNU General Public License > // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
< * Allows admin to configure editors.
> * A page to manage editor plugins. > * > * @package core_admin > * @copyright 2023 Andrew Lyons <andrew@nicols.co.uk> > * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
< $editor = required_param('editor', PARAM_PLUGIN); < $confirm = optional_param('confirm', 0, PARAM_BOOL);
> $plugin = required_param('plugin', PARAM_PLUGIN);
< $PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
> $PAGE->set_url('/admin/editors.php', ['action' => $action, 'editor' => $plugin]);
> require_sesskey();
< $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
> $returnurl = new moodle_url('/admin/settings.php', ['section' => 'manageeditors']);
< // get currently installed and enabled auth plugins < $available_editors = editors_get_available(); < if (!empty($editor) and empty($available_editors[$editor])) {
> // Get currently installed and enabled auth plugins. > $availableeditors = editors_get_available(); > if (!empty($plugin) && empty($availableeditors[$plugin])) {
redirect ($returnurl); }
< $active_editors = explode(',', $CFG->texteditors); < foreach ($active_editors as $key=>$active) { < if (empty($available_editors[$active])) { < unset($active_editors[$key]);
> $activeeditors = explode(',', $CFG->texteditors); > foreach ($activeeditors as $key => $active) { > if (empty($availableeditors[$active])) { > unset($activeeditors[$key]);
} }
< //////////////////////////////////////////////////////////////////////////////// < // process actions < < if (!confirm_sesskey()) { < redirect($returnurl); < } < < $return = true;
switch ($action) { case 'disable': // Remove from enabled list. $class = \core_plugin_manager::resolve_plugininfo_class('editor');
< $class::enable_plugin($editor, false);
> $class::enable_plugin($plugin, false);
break; case 'enable': // Add to enabled list.
< if (!in_array($editor, $active_editors)) {
> if (!in_array($plugin, $activeeditors)) {
$class = \core_plugin_manager::resolve_plugininfo_class('editor');
< $class::enable_plugin($editor, true);
> $class::enable_plugin($plugin, true);
} break; case 'down':
< $key = array_search($editor, $active_editors); < // check auth plugin is valid
> $key = array_search($plugin, $activeeditors);
if ($key !== false) {
< // move down the list < if ($key < (count($active_editors) - 1)) { < $fsave = $active_editors[$key]; < $active_editors[$key] = $active_editors[$key + 1]; < $active_editors[$key + 1] = $fsave; < add_to_config_log('editor_position', $key, $key + 1, $editor); < set_config('texteditors', implode(',', $active_editors));
> // Move down the list. > if ($key < (count($activeeditors) - 1)) { > $fsave = $activeeditors[$key]; > $activeeditors[$key] = $activeeditors[$key + 1]; > $activeeditors[$key + 1] = $fsave; > add_to_config_log('editor_position', $key, $key + 1, $plugin); > set_config('texteditors', implode(',', $activeeditors));
core_plugin_manager::reset_caches(); } } break; case 'up':
< $key = array_search($editor, $active_editors); < // check auth is valid
> $key = array_search($plugin, $activeeditors);
if ($key !== false) {
< // move up the list
> // Move up the list.
if ($key >= 1) {
< $fsave = $active_editors[$key]; < $active_editors[$key] = $active_editors[$key - 1]; < $active_editors[$key - 1] = $fsave; < add_to_config_log('editor_position', $key, $key - 1, $editor); < set_config('texteditors', implode(',', $active_editors));
> $fsave = $activeeditors[$key]; > $activeeditors[$key] = $activeeditors[$key - 1]; > $activeeditors[$key - 1] = $fsave; > add_to_config_log('editor_position', $key, $key - 1, $plugin); > set_config('texteditors', implode(',', $activeeditors));
core_plugin_manager::reset_caches(); } } break; default: break; }
< if ($return) {
redirect ($returnurl);
< }