MDL-39088 migrate editor uninstallation to plugin_manager

This commit is contained in:
Petr Škoda 2013-06-26 13:19:00 +02:00
parent 8a953d629f
commit b07526e8de
4 changed files with 14 additions and 47 deletions

View File

@ -83,47 +83,6 @@ switch ($action) {
}
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;
}
$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;
}

View File

@ -52,7 +52,6 @@ $string['createlink'] = 'Insert Web Link';
$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.<br /><br />There are three known workarounds you can try: <br /> (1) Instead of CTRL-v, use SHIFT-Insert <br /> (2) Use the Edit->Paste menu in your browser <br /> (3) Change the preferences in your browser by editing the user.js file. <br /><br />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';

View File

@ -5943,11 +5943,9 @@ class admin_setting_manageeditors extends admin_setting {
$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);
$uninstall = '';
if ($deleteurl = plugin_manager::instance()->get_uninstall_url('editor_'.$editor)) {
$uninstall = html_writer::link($deleteurl, $struninstall);
}
// add a row to the table

View File

@ -3878,6 +3878,17 @@ class plugininfo_editor extends plugininfo_base {
}
}
/**
* Basic textarea editor can not be uninstalled.
*/
public function is_uninstall_allowed() {
if ($this->name === 'textarea') {
return false;
} else {
return true;
}
}
/**
* Returns the information about plugin availability
*