diff --git a/lib/editor/tinymce/adminlib.php b/lib/editor/tinymce/adminlib.php new file mode 100644 index 00000000000..8e599d63b91 --- /dev/null +++ b/lib/editor/tinymce/adminlib.php @@ -0,0 +1,37 @@ +. + +/** + * TinyMCE admin setting stuff. + * + * @package editor_tinymce + * @copyright 2012 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +require_once("$CFG->libdir/pluginlib.php"); + +/** + * Editor subplugin info class. + */ +class plugininfo_tinymce extends plugininfo_base { + + public function get_uninstall_url() { + return new moodle_url('/lib/editor/tinymce/subplugins.php', array('delete' => $this->name, 'sesskey' => sesskey())); + } +} diff --git a/lib/editor/tinymce/lang/en/editor_tinymce.php b/lib/editor/tinymce/lang/en/editor_tinymce.php index dc48ba37e53..c52236fa153 100644 --- a/lib/editor/tinymce/lang/en/editor_tinymce.php +++ b/lib/editor/tinymce/lang/en/editor_tinymce.php @@ -29,6 +29,7 @@ $string['common:browsemedia'] = 'Find or upload a sound, video or applet...'; $string['fontselectlist'] = 'Available fonts list'; $string['media_dlg:filename'] = 'Filename'; $string['pluginname'] = 'TinyMCE HTML editor'; +$string['subplugindeleteconfirm'] = 'You are about to completely delete TinyMCE subplugin \'{$a}\'. This will completely delete everything in the database associated with this subplugin. Are you SURE you want to continue?'; // == TinyMCE upstream lang strings from all standard upstream plugins == diff --git a/lib/editor/tinymce/subplugins.php b/lib/editor/tinymce/subplugins.php new file mode 100644 index 00000000000..0c24080fd6e --- /dev/null +++ b/lib/editor/tinymce/subplugins.php @@ -0,0 +1,74 @@ +. + +/** + * TinyMCE subplugin management. + * + * @package editor_tinymce + * @copyright 2012 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require(__DIR__ . '/../../../config.php'); +require_once($CFG->libdir.'/adminlib.php'); + +$delete = optional_param('delete', '', PARAM_PLUGIN); +$confirm = optional_param('confirm', '', PARAM_BOOL); +$return = optional_param('return', 'overview', PARAM_ALPHA); + +$PAGE->set_context(null); +$PAGE->set_url('/lib/editor/tinymce/subplugins.php', array('delete'=>$delete)); + +require_login(); +require_capability('moodle/site:config', context_system::instance()); +require_sesskey(); + +if ($return === 'settings') { + $returnurl = new moodle_url('/admin/settings.php', array('section'=>'editorsettingstinymce')); +} else { + $returnurl = new moodle_url('/admin/plugins.php'); +} + +if ($delete) { + echo $OUTPUT->header(); + echo $OUTPUT->heading(get_string('pluginname', 'editor_tinymce')); + + if (!$confirm) { + if (get_string_manager()->string_exists('pluginname', 'tinymce_' . $delete)) { + $strpluginname = get_string('pluginname', 'tinymce_' . $delete); + } else { + $strpluginname = $delete; + } + echo $OUTPUT->confirm(get_string('subplugindeleteconfirm', 'editor_tinymce', $strpluginname), + new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1, 'return'=>$return)), + $returnurl); + echo $OUTPUT->footer(); + die(); + + } else { + uninstall_plugin('tinymce', $delete); + $a = new stdclass(); + $a->name = $delete; + $pluginlocation = get_plugin_types(); + $a->directory = $pluginlocation['tinymce'] . '/' . $delete; + echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); + echo $OUTPUT->continue_button($returnurl); + echo $OUTPUT->footer(); + die(); + } +} + +redirect($returnurl);