MDL-39088 migrate admin tool uninstallation to plugin_manager
[moodle.git] / lib / editor / tinymce / subplugins.php
CommitLineData
f8c93972
PS
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 * TinyMCE subplugin management.
19 *
20 * @package editor_tinymce
21 * @copyright 2012 Petr Skoda {@link http://skodak.org}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25require(__DIR__ . '/../../../config.php');
26require_once($CFG->libdir.'/adminlib.php');
27
28$delete = optional_param('delete', '', PARAM_PLUGIN);
29$confirm = optional_param('confirm', '', PARAM_BOOL);
0b785822
PS
30$disable = optional_param('disable', '', PARAM_PLUGIN);
31$enable = optional_param('enable', '', PARAM_PLUGIN);
f8c93972
PS
32$return = optional_param('return', 'overview', PARAM_ALPHA);
33
2cd58c83 34$PAGE->set_context(context_system::instance());
f8c93972
PS
35$PAGE->set_url('/lib/editor/tinymce/subplugins.php', array('delete'=>$delete));
36
37require_login();
38require_capability('moodle/site:config', context_system::instance());
39require_sesskey();
40
41if ($return === 'settings') {
42 $returnurl = new moodle_url('/admin/settings.php', array('section'=>'editorsettingstinymce'));
43} else {
44 $returnurl = new moodle_url('/admin/plugins.php');
45}
46
47if ($delete) {
48 echo $OUTPUT->header();
49 echo $OUTPUT->heading(get_string('pluginname', 'editor_tinymce'));
50
51 if (!$confirm) {
52 if (get_string_manager()->string_exists('pluginname', 'tinymce_' . $delete)) {
53 $strpluginname = get_string('pluginname', 'tinymce_' . $delete);
54 } else {
55 $strpluginname = $delete;
56 }
57 echo $OUTPUT->confirm(get_string('subplugindeleteconfirm', 'editor_tinymce', $strpluginname),
58 new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1, 'return'=>$return)),
59 $returnurl);
60 echo $OUTPUT->footer();
61 die();
62
63 } else {
64 uninstall_plugin('tinymce', $delete);
65 $a = new stdclass();
66 $a->name = $delete;
67 $pluginlocation = get_plugin_types();
68 $a->directory = $pluginlocation['tinymce'] . '/' . $delete;
69 echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
70 echo $OUTPUT->continue_button($returnurl);
71 echo $OUTPUT->footer();
72 die();
73 }
0b785822
PS
74
75} else {
76 $disabled = array();
77 $disabledsubplugins = get_config('editor_tinymce', 'disabledsubplugins');
78 if ($disabledsubplugins) {
79 $disabledsubplugins = explode(',', $disabledsubplugins);
80 foreach ($disabledsubplugins as $sp) {
81 $sp = trim($sp);
82 if ($sp !== '') {
83 $disabled[$sp] = $sp;
84 }
85 }
86 }
87
88 if ($disable) {
89 $disabled[$disable] = $disable;
90 } else if ($enable) {
91 unset($disabled[$enable]);
92 }
93
94 set_config('disabledsubplugins', implode(',', $disabled), 'editor_tinymce');
f8c93972
PS
95}
96
97redirect($returnurl);