Merge branch 'MDL-76800-master' of https://github.com/raortegar/moodle
[moodle.git] / lib / editor / tiny / subplugins.php
blob1f8e16bd4798c4dfb91d2f225acb7d821108fe45
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.
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/>.
17 /**
18 * Tiny subplugin management.
20 * @package editor_tinymce
21 * @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require(__DIR__ . '/../../../config.php');
26 require_once("{$CFG->libdir}/adminlib.php");
28 $action = optional_param('action', '', PARAM_ALPHA);
29 $plugin = optional_param('plugin', '', PARAM_PLUGIN);
31 $PAGE->set_context(context_system::instance());
32 $PAGE->set_url('/lib/editor/tinymce/subplugins.php');
34 require_login();
35 require_capability('moodle/site:config', context_system::instance());
36 require_sesskey();
38 $tinymanager = \core_plugin_manager::resolve_plugininfo_class('tiny');
39 $pluginname = get_string('pluginname', "tiny_{$plugin}");
41 switch ($action) {
42 case 'disable':
43 if ($tinymanager::enable_plugin($plugin, 0)) {
44 \core\notification::add(
45 get_string('plugin_disabled', 'editor_tiny', $pluginname),
46 \core\notification::SUCCESS
49 break;
50 case 'enable':
51 if ($tinymanager::enable_plugin($plugin, 1)) {
52 \core\notification::add(
53 get_string('plugin_enabled', 'editor_tiny', $pluginname),
54 \core\notification::SUCCESS
57 break;
58 default:
61 redirect(new moodle_url('/admin/settings.php', [
62 'section' => 'editorsettingstiny',
63 ]));