diff --git a/admin/editors.php b/admin/editors.php index 1a8f530854ae3..f115a9287f045 100644 --- a/admin/editors.php +++ b/admin/editors.php @@ -8,14 +8,18 @@ require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/tablelib.php'); +$action = required_param('action', PARAM_ALPHANUMEXT); +$editor = required_param('editor', PARAM_PLUGIN); +$confirm = optional_param('confirm', 0, PARAM_BOOL); + +$PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor)); +$PAGE->set_context(context_system::instance()); + require_login(); require_capability('moodle/site:config', context_system::instance()); $returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors"; -$action = optional_param('action', '', PARAM_ALPHANUMEXT); -$editor = optional_param('editor', '', PARAM_PLUGIN); - // get currently installed and enabled auth plugins $available_editors = editors_get_available(); if (!empty($editor) and empty($available_editors[$editor])) { @@ -78,6 +82,48 @@ } } break; + + case 'uninstall': + if ($editor === 'textarea') { + redirect($returnurl); + } + if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) { + $strplugin = get_string('pluginname', 'editor_'.$editor); + } else { + $strplugin = $editor; + } + + echo $PAGE->set_title($strplugin); + echo $OUTPUT->header(); + + if (!$confirm) { + echo $OUTPUT->heading(get_string('editors', 'core_editor')); + + $deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1)); + + echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin), + $deleteurl, $returnurl); + echo $OUTPUT->footer(); + die(); + + } else { + // Remove from enabled list. + $key = array_search($editor, $active_editors); + unset($active_editors[$key]); + set_config('texteditors', implode(',', $active_editors)); + + // Delete everything!! + uninstall_plugin('editor', $editor); + + $a = new stdClass(); + $a->name = $strplugin; + $a->directory = "$CFG->dirroot/lib/editor/$editor"; + echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); + echo $OUTPUT->continue_button($returnurl); + echo $OUTPUT->footer(); + die(); + } + default: break; } diff --git a/lang/en/editor.php b/lang/en/editor.php index d2922d6f26dd5..aad66efcbdbcf 100644 --- a/lang/en/editor.php +++ b/lang/en/editor.php @@ -52,6 +52,7 @@ $string['cut'] = 'Cut selection'; $string['cutpastemozilla'] = 'Unfortunately, you cannot currently use normal keyboard shortcuts (or even the Paste button) for pasting text into this online editor. This is because of a security feature that is built into some versions of Mozilla and Firefox browsers.

There are three known workarounds you can try:
(1) Instead of CTRL-v, use SHIFT-Insert
(2) Use the Edit->Paste menu in your browser
(3) Change the preferences in your browser by editing the user.js file.

Click the OK button below for more help, or Cancel to return to the editor'; $string['delete'] = 'Delete'; +$string['editordeleteconfirm'] = 'You are about to completely delete the editor plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; $string['editors'] = 'Text editors'; $string['editorsettings'] = 'Manage editors'; $string['enterurlfirst'] = 'You have to enter an URL first'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 34c5d30c0ee75..3813b4d46dd58 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5706,6 +5706,8 @@ public function output_html($data, $query='') { // display strings $txt = get_strings(array('administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none')); + $struninstall = get_string('uninstallplugin', 'admin'); + $txt->updown = "$txt->up/$txt->down"; $editors_available = editors_get_available(); @@ -5729,8 +5731,8 @@ public function output_html($data, $query='') { $return .= $OUTPUT->box_start('generalbox editorsui'); $table = new html_table(); - $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings); - $table->align = array('left', 'center', 'center', 'center'); + $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->settings, $struninstall); + $table->align = array('left', 'center', 'center', 'center', 'center'); $table->width = '90%'; $table->data = array(); @@ -5783,8 +5785,15 @@ public function output_html($data, $query='') { $settings = ''; } + if ($editor === 'textarea') { + $uninstall = ''; + } else { + $uurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey())); + $uninstall = html_writer::link($uurl, $struninstall); + } + // add a row to the table - $table->data[] =array($displayname, $hideshow, $updown, $settings); + $table->data[] =array($displayname, $hideshow, $updown, $settings, $uninstall); } $return .= html_writer::table($table); $return .= get_string('configeditorplugins', 'editor').'
'.get_string('tablenosave', 'admin');