From 2f87bb03151d1d3a332fabe12e8fba8f8be24c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:04:31 +0200 Subject: [PATCH 01/13] MDL-39088 add new general uninstall url support to plugin manager --- admin/renderer.php | 14 +++++++++----- lib/adminlib.php | 2 ++ lib/pluginlib.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/admin/renderer.php b/admin/renderer.php index e70815296a6..68cdb49bcef 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -375,7 +375,7 @@ class core_admin_renderer extends plugin_renderer_base { * Display a page to confirm the plugin uninstallation. * * @param plugin_manager $pluginman - * @param plugin_info $pluginfo + * @param plugininfo_base $pluginfo * @param moodle_url $continueurl URL to continue after confirmation * @return string */ @@ -384,10 +384,14 @@ class core_admin_renderer extends plugin_renderer_base { $pluginname = $pluginman->plugin_name($pluginfo->component); + $confirm = '

' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '

'; + if ($extraconfirm = $pluginfo->get_uninstall_extra_warning()) { + $confirm .= $extraconfirm; + } + $output .= $this->output->header(); $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname))); - $output .= $this->output->confirm(get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)), - $continueurl, $this->page->url); + $output .= $this->output->confirm($confirm, $continueurl, $this->page->url); $output .= $this->output->footer(); return $output; @@ -397,7 +401,7 @@ class core_admin_renderer extends plugin_renderer_base { * Display a page with results of plugin uninstallation and offer removal of plugin files. * * @param plugin_manager $pluginman - * @param plugin_info $pluginfo + * @param plugininfo_base $pluginfo * @param progress_trace_buffer $progress * @param moodle_url $continueurl URL to continue to remove the plugin folder * @return string @@ -431,7 +435,7 @@ class core_admin_renderer extends plugin_renderer_base { * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually. * * @param plugin_manager $pluginman - * @param plugin_info $pluginfo + * @param plugininfo_base $pluginfo * @param progress_trace_buffer $progress * @return string */ diff --git a/lib/adminlib.php b/lib/adminlib.php index ba67ddd0768..caf3786931c 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -115,6 +115,8 @@ define('INSECURE_DATAROOT_ERROR', 2); /** * Automatically clean-up all plugin data and remove the plugin DB tables * + * NOTE: do not call directly, use new /admin/plugins.php?uninstall=component instead! + * * @param string $type The plugin type, eg. 'mod', 'qtype', 'workshopgrading' etc. * @param string $name The plugin name, eg. 'forum', 'multichoice', 'accumulative' etc. * @uses global $OUTPUT to produce notices and other messages diff --git a/lib/pluginlib.php b/lib/pluginlib.php index f8710dd0516..d5744428a22 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -520,6 +520,26 @@ class plugin_manager { return true; } + /** + * Returns uninstall URL if exists. + * + * @param string $component + * @return moodle_url uninstall URL, null if uninstall not supported + */ + public function get_uninstall_url($component) { + if (!$this->can_uninstall_plugin($component)) { + return null; + } + + $pluginfo = $this->get_plugin_info($component); + + if (is_null($pluginfo)) { + return null; + } + + return $pluginfo->get_uninstall_url(); + } + /** * Uninstall the given plugin. * @@ -2825,6 +2845,15 @@ abstract class plugininfo_base { return true; } + /** + * Optional extra warning before uninstallation, for example number of uses in courses. + * + * @return string + */ + public function get_uninstall_extra_warning() { + return ''; + } + /** * Returns the URL of the screen where this plugin can be uninstalled * From 6584d8a861624c088d5497f5a2536f95f9b00df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:07:23 +0200 Subject: [PATCH 02/13] MDL-39088 migrate block uninstallation to plugin_manager --- admin/blocks.php | 43 +++++++++++-------------------------------- lang/en/moodle.php | 2 -- lang/en/plugin.php | 1 + lib/pluginlib.php | 16 +++++++++++++--- 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/admin/blocks.php b/admin/blocks.php index f2017b912a1..2f255ddc957 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -11,7 +11,6 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); $hide = optional_param('hide', 0, PARAM_INT); $show = optional_param('show', 0, PARAM_INT); - $delete = optional_param('delete', 0, PARAM_INT); $unprotect = optional_param('unprotect', 0, PARAM_INT); $protect = optional_param('protect', 0, PARAM_INT); @@ -81,35 +80,6 @@ admin_get_root(true, false); // settings not required - only pages } - if (!empty($delete) && confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading($strmanageblocks); - - if (!$block = blocks_get_record($delete)) { - print_error('blockdoesnotexist', 'error'); - } - - if (get_string_manager()->string_exists('pluginname', "block_$block->name")) { - $strblockname = get_string('pluginname', "block_$block->name"); - } else { - $strblockname = $block->name; - } - - if (!$confirm) { - echo $OUTPUT->confirm(get_string('blockdeleteconfirm', '', $strblockname), 'blocks.php?delete='.$block->id.'&confirm=1', 'blocks.php'); - echo $OUTPUT->footer(); - exit; - - } else { - uninstall_plugin('block', $block->name); - - $a = new stdClass(); - $a->block = $strblockname; - $a->directory = $CFG->dirroot.'/blocks/'.$block->name; - notice(get_string('blockdeletefiles', '', $a), 'blocks.php'); - } - } - echo $OUTPUT->header(); echo $OUTPUT->heading($strmanageblocks); @@ -170,7 +140,11 @@ } } - $delete = ''.$strdelete.''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) { + $delete = html_writer::link($deleteurl, $strdelete); + } else { + $delete = ''; + } $settings = ''; // By default, no configuration if ($blockobject and $blockobject->has_config()) { @@ -257,9 +231,14 @@ $table->setup(); foreach ($incompatible as $block) { + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) { + $delete = html_writer::link($deleteurl, $strdelete); + } else { + $delete = ''; + } $table->add_data(array( $block->name, - ''.$strdelete.'', + $delete, )); } $table->print_html(); diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 7ec794cfa4d..a7d3b491379 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -197,8 +197,6 @@ $string['badges'] = 'Badges'; $string['block'] = 'Block'; $string['blockconfiga'] = 'Configuring a {$a} block'; $string['blockconfigbad'] = 'This block has not been implemented correctly and thus cannot provide a configuration interface.'; -$string['blockdeleteconfirm'] = 'You are about to completely delete the block \'{$a}\'. This will completely delete everything in the database associated with this block. Are you SURE you want to continue?'; -$string['blockdeletefiles'] = 'All data associated with the block \'{$a->block}\' has been deleted from the database. To complete the deletion (and prevent the block re-installing itself), you should now delete this directory from your server: {$a->directory}'; $string['blocks'] = 'Blocks'; $string['blocksaddedit'] = 'Add/Edit blocks'; $string['blockseditoff'] = 'Blocks editing off'; diff --git a/lang/en/plugin.php b/lang/en/plugin.php index 1bf4fd79a6a..c06848a56cd 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -151,6 +151,7 @@ $string['uninstallconfirm'] = 'You are about to uninstall the plugin {$a->na $string['uninstalldelete'] = 'All data associated with the plugin {$a->name} has been deleted from the database. To prevent the plugin re-installing itself, its folder {$a->rootdir} must be manually removed from your server now. Moodle itself cannot remove the folder due to write permissions.'; $string['uninstalldeleteconfirm'] = 'All data associated with the plugin {$a->name} has been deleted from the database. To prevent the plugin re-installing itself, its folder {$a->rootdir} must be removed from your server. Do you want to remove the plugin folder now?'; $string['uninstalldeleteconfirmexternal'] = 'It appears that the current version of the plugin has been obtained via source code management system ({$a}) checkout. If you remove the plugin folder, you may loose important local modifications of the code. Please ensure that you definitely want to remove the plugin folder before continuing.'; +$string['uninstallextraconfirmblock'] = 'There are {$a->instances} instances of this block.'; $string['uninstalling'] = 'Uninstalling {$a->name}'; $string['version'] = 'Version'; $string['versiondb'] = 'Current version'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index d5744428a22..8fbe49d20d1 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3077,9 +3077,19 @@ class plugininfo_block extends plugininfo_base { return true; } - public function get_uninstall_url() { - $blocksinfo = self::get_blocks_info(); - return new moodle_url('/admin/blocks.php', array('delete' => $blocksinfo[$this->name]->id, 'sesskey' => sesskey())); + /** + * Warnign with number of block instances. + * + * @return string + */ + public function get_uninstall_extra_warning() { + global $DB; + + if (!$count = $DB->count_records('block_instances', array('blockname'=>$this->name))) { + return ''; + } + + return '

'.get_string('uninstallextraconfirmblock', 'core_plugin', array('instances'=>$count)).'

'; } /** From 8a953d629f6c9135fb4d1d94c341061f742700c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:14:31 +0200 Subject: [PATCH 03/13] MDL-39088 migrate course format uninstallation to plugin_manager --- admin/courseformats.php | 48 ----------------------------------------- lang/en/admin.php | 2 -- lib/adminlib.php | 4 ++-- lib/pluginlib.php | 19 +++++++++++++--- 4 files changed, 18 insertions(+), 55 deletions(-) diff --git a/admin/courseformats.php b/admin/courseformats.php index fddcdda750f..7ea15e86d16 100644 --- a/admin/courseformats.php +++ b/admin/courseformats.php @@ -28,7 +28,6 @@ require_once($CFG->libdir.'/pluginlib.php'); $action = required_param('action', PARAM_ALPHANUMEXT); $formatname = required_param('format', PARAM_PLUGIN); -$confirm = optional_param('confirm', 0, PARAM_BOOL); $syscontext = context_system::instance(); $PAGE->set_url('/admin/courseformats.php'); @@ -79,52 +78,5 @@ switch ($action) { set_config('format_plugins_sortorder', implode(',', $seq)); } break; - case 'uninstall': - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('courseformats', 'moodle')); - - $coursecount = $DB->count_records('course', array('format' => $formatname)); - if ($coursecount) { - // Check that default format is set. It will be used to convert courses - // using this format - $defaultformat = get_config('moodlecourse', 'format'); - $defaultformat = $formatplugins[get_config('moodlecourse', 'format')]; - if (!$defaultformat) { - echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin')); - echo $OUTPUT->footer(); - exit; - } - } - - $format = $formatplugins[$formatname]; - $deleteurl = $format->get_uninstall_url(); - if (!$deleteurl) { - // somebody was trying to cheat and type non-existing link - echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname)); - echo $OUTPUT->footer(); - exit; - } - - if (!$confirm) { - if ($coursecount) { - $message = get_string('formatuninstallwithcourses', 'admin', - (object)array('count' => $coursecount, 'format' => $format->displayname, - 'defaultformat' => $defaultformat->displayname)); - } else { - $message = get_string('formatuninstallconfirm', 'admin', $format->displayname); - } - $deleteurl->param('confirm', 1); - echo $OUTPUT->confirm($message, $deleteurl, $return); - } else { - $a = new stdClass(); - $a->plugin = $format->displayname; - $a->directory = $format->rootdir; - uninstall_plugin('format', $formatname); - echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($return); - } - - echo $OUTPUT->footer(); - exit; } redirect($return); diff --git a/lang/en/admin.php b/lang/en/admin.php index ffea8a9f869..b20082ff50b 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -537,8 +537,6 @@ $string['forceloginforprofileimage_help'] = 'If enabled, users must login in ord $string['forceloginforprofiles'] = 'Force users to login for profiles'; $string['forcetimezone'] = 'Force default timezone'; $string['formatuninstallwithcourses'] = 'There are {$a->count} courses using {$a->format}. Their format will be changed to {$a->defaultformat} (default format for this site). Some format-specific data may be lost. Are you sure you want to proceed?'; -$string['formatuninstallconfirm'] = '{$a} will be uninstalled. No courses currently use it. Continue?'; -$string['formatuninstalled'] = 'All data associated with the format plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}'; $string['frontpage'] = 'Front page'; $string['frontpagebackup'] = 'Front page backup'; $string['frontpagedefaultrole'] = 'Default frontpage role'; diff --git a/lib/adminlib.php b/lib/adminlib.php index caf3786931c..25a364641b8 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -6183,8 +6183,8 @@ class admin_setting_manageformats extends admin_setting { $settings = html_writer::link($format->get_settings_url(), $txt->settings); } $uninstall = ''; - if ($defaultformat !== $format->name) { - $uninstall = html_writer::link($format->get_uninstall_url(), $txt->delete); + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('format_'.$format->name)) { + $uninstall = html_writer::link($deleteurl, $txt->delete); } $table->data[] =array($strformatname, $hideshow, $updown, $uninstall, $settings); } diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 8fbe49d20d1..674cbe2b5ba 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -4021,8 +4021,21 @@ class plugininfo_format extends plugininfo_base { } } - public function get_uninstall_url() { - return new moodle_url('/admin/courseformats.php', - array('sesskey' => sesskey(), 'action' => 'uninstall', 'format' => $this->name)); + public function get_uninstall_extra_warning() { + global $DB; + + $coursecount = $DB->count_records('course', array('format' => $this->name)); + + if (!$coursecount) { + return ''; + } + + $defaultformat = $this->get_plugin_manager()->plugin_name('format_'.get_config('moodlecourse', 'format')); + $message = get_string( + 'formatuninstallwithcourses', 'core_admin', + (object)array('count' => $coursecount, 'format' => $this->displayname, + 'defaultformat' => $defaultformat)); + + return $message; } } From b07526e8def45edb5d73a8910e331346cabc79bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:19:00 +0200 Subject: [PATCH 04/13] MDL-39088 migrate editor uninstallation to plugin_manager --- admin/editors.php | 41 ----------------------------------------- lang/en/editor.php | 1 - lib/adminlib.php | 8 +++----- lib/pluginlib.php | 11 +++++++++++ 4 files changed, 14 insertions(+), 47 deletions(-) diff --git a/admin/editors.php b/admin/editors.php index f6e68ff7a8d..da846faf2f8 100644 --- a/admin/editors.php +++ b/admin/editors.php @@ -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; } diff --git a/lang/en/editor.php b/lang/en/editor.php index aad66efcbdb..d2922d6f26d 100644 --- a/lang/en/editor.php +++ b/lang/en/editor.php @@ -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.

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 25a364641b8..849b88a9e1d 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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 diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 674cbe2b5ba..245d339082f 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -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 * From 5643f932e9ab6edfa26840e1e5c48b0f0b9e51f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:24:08 +0200 Subject: [PATCH 05/13] MDL-39088 migrate enrol uninstallation to plugin_manager --- admin/enrol.php | 63 +++++++++++----------------------------------- lang/en/enrol.php | 7 +----- lang/en/plugin.php | 1 + lib/adminlib.php | 12 ++++----- lib/pluginlib.php | 31 +++++++++++++++++++++-- 5 files changed, 50 insertions(+), 64 deletions(-) diff --git a/admin/enrol.php b/admin/enrol.php index 10062a199b9..3c037129fd4 100644 --- a/admin/enrol.php +++ b/admin/enrol.php @@ -31,7 +31,6 @@ require_once($CFG->libdir.'/adminlib.php'); $action = required_param('action', PARAM_ALPHANUMEXT); $enrol = required_param('enrol', PARAM_PLUGIN); $confirm = optional_param('confirm', 0, PARAM_BOOL); -$migrate = optional_param('migrate', 0, PARAM_BOOL); $PAGE->set_url('/admin/enrol.php'); $PAGE->set_context(context_system::instance()); @@ -96,7 +95,7 @@ switch ($action) { set_config('enrol_plugins_enabled', implode(',', $enabled)); break; - case 'uninstall': + case 'migrate': if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) { $strplugin = get_string('pluginname', 'enrol_'.$enrol); } else { @@ -106,58 +105,24 @@ switch ($action) { $PAGE->set_title($strplugin); echo $OUTPUT->header(); - if (!$confirm) { - echo $OUTPUT->heading(get_string('enrolments', 'enrol')); + // This may take a long time. + set_time_limit(0); - $deleteurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>0)); - $migrateurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1, 'migrate'=>1)); + // Disable plugin to prevent concurrent cron execution. + unset($enabled[$enrol]); + set_config('enrol_plugins_enabled', implode(',', array_keys($enabled))); - $migrate = new single_button($migrateurl, get_string('uninstallmigrate', 'enrol')); - $delete = new single_button($deleteurl, get_string('uninstalldelete', 'enrol')); - $cancel = new single_button($return, get_string('cancel'), 'get'); + echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol)); - $buttons = $OUTPUT->render($delete) . $OUTPUT->render($cancel); - if ($enrol !== 'manual') { - $buttons = $OUTPUT->render($migrate) . $buttons; - } + require_once("$CFG->dirroot/enrol/manual/locallib.php"); + enrol_manual_migrate_plugin_enrolments($enrol); - echo $OUTPUT->box_start('generalbox', 'notice'); - echo html_writer::tag('p', markdown_to_html(get_string('uninstallconfirm', 'enrol', $strplugin))); - echo html_writer::tag('div', $buttons, array('class' => 'buttons')); - echo $OUTPUT->box_end(); + echo $OUTPUT->notification(get_string('success'), 'notifysuccess'); - echo $OUTPUT->footer(); - exit; - - } else { - // This may take a long time. - set_time_limit(0); - - // Disable plugin to prevent concurrent cron execution. - unset($enabled[$enrol]); - set_config('enrol_plugins_enabled', implode(',', array_keys($enabled))); - - if ($migrate) { - echo $OUTPUT->heading(get_string('uninstallmigrating', 'enrol', 'enrol_'.$enrol)); - - require_once("$CFG->dirroot/enrol/manual/locallib.php"); - enrol_manual_migrate_plugin_enrolments($enrol); - - echo $OUTPUT->notification(get_string('success'), 'notifysuccess'); - } - - // Delete everything!! - uninstall_plugin('enrol', $enrol); - $syscontext->mark_dirty(); // Resets all enrol caches. - - $a = new stdClass(); - $a->plugin = $strplugin; - $a->directory = "$CFG->dirroot/enrol/$enrol"; - echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($return); - echo $OUTPUT->footer(); - exit; - } + $return = new moodle_url('/admin/plugins.php', array('uninstall'=>'enrol_'.$enrol, 'sesskey'=>sesskey())); + echo $OUTPUT->continue_button($return); + echo $OUTPUT->footer(); + exit; } diff --git a/lang/en/enrol.php b/lang/en/enrol.php index 2458bdf50bf..2beaab14481 100644 --- a/lang/en/enrol.php +++ b/lang/en/enrol.php @@ -81,6 +81,7 @@ $string['invalidenrolinstance'] = 'Invalid enrolment instance'; $string['invalidrole'] = 'Invalid role'; $string['manageenrols'] = 'Manage enrol plugins'; $string['manageinstance'] = 'Manage'; +$string['migratetomanual'] = 'Migrate to manual enrolments'; $string['nochange'] = 'No change'; $string['noexistingparticipants'] = 'No existing participants'; $string['noguestaccess'] = 'Guests can not access this course, please try to log in.'; @@ -110,12 +111,6 @@ $string['unenrolconfirm'] = 'Do you really want to unenrol user "{$a->user}" fro $string['unenrolme'] = 'Unenrol me from {$a}'; $string['unenrolnotpermitted'] = 'You do not have permission or can not unenrol this user from this course.'; $string['unenrolroleusers'] = 'Unenrol users'; -$string['uninstallconfirm'] = 'You are about to uninstall the enrolment plugin \'{$a}\'. This will result in the deletion of all data associated with this enrolment type, including users\' grades, group membership, forum subscriptions and any other course-related data. - -Are you SURE you want to continue?'; -$string['uninstalldelete'] = 'Delete all enrolments and uninstall'; -$string['uninstalldeletefiles'] = 'All data associated with the enrol plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}'; -$string['uninstallmigrate'] = 'Uninstall but keep all enrolments'; $string['uninstallmigrating'] = 'Migrating "{$a}" enrolments'; $string['unknowajaxaction'] = 'Unknown action requested'; $string['unlimitedduration'] = 'Unlimited'; diff --git a/lang/en/plugin.php b/lang/en/plugin.php index c06848a56cd..0b17af6da14 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -152,6 +152,7 @@ $string['uninstalldelete'] = 'All data associated with the plugin {$a->name} $string['uninstalldeleteconfirm'] = 'All data associated with the plugin {$a->name} has been deleted from the database. To prevent the plugin re-installing itself, its folder {$a->rootdir} must be removed from your server. Do you want to remove the plugin folder now?'; $string['uninstalldeleteconfirmexternal'] = 'It appears that the current version of the plugin has been obtained via source code management system ({$a}) checkout. If you remove the plugin folder, you may loose important local modifications of the code. Please ensure that you definitely want to remove the plugin folder before continuing.'; $string['uninstallextraconfirmblock'] = 'There are {$a->instances} instances of this block.'; +$string['uninstallextraconfirmenrol'] = 'There are {$a->enrolments} user enrolments.'; $string['uninstalling'] = 'Uninstalling {$a->name}'; $string['version'] = 'Version'; $string['versiondb'] = 'Current version'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 849b88a9e1d..2c930eef028 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5232,18 +5232,16 @@ class admin_setting_manageenrols extends admin_setting { // Add settings link. if (!$version) { $settings = ''; - } else if ($url = $plugininfo->get_settings_url()) { - $settings = html_writer::link($url, $strsettings); + } else if ($surl = $plugininfo->get_settings_url()) { + $settings = html_writer::link($surl, $strsettings); } else { $settings = ''; } // Add uninstall info. - if ($version) { - $url = new moodle_url($plugininfo->get_uninstall_url(), array('return'=>'settings')); - $uninstall = html_writer::link($url, $struninstall); - } else { - $uninstall = ''; + $uninstall = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) { + $uninstall = html_writer::link($deleteurl, $struninstall); } // Add a row to the table. diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 245d339082f..e82c6882b2b 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3605,11 +3605,38 @@ class plugininfo_enrol extends plugininfo_base { } public function is_uninstall_allowed() { + if ($this->name === 'manual') { + return false; + } return true; } - public function get_uninstall_url() { - return new moodle_url('/admin/enrol.php', array('action' => 'uninstall', 'enrol' => $this->name, 'sesskey' => sesskey())); + /** + * Return warning with number of activities and number of affected courses. + * + * @return string + */ + public function get_uninstall_extra_warning() { + global $DB, $OUTPUT; + + $sql = "SELECT COUNT('x') + FROM {user_enrolments} ue + JOIN {enrol} e ON e.id = ue.enrolid + WHERE e.enrol = :plugin"; + $count = $DB->count_records_sql($sql, array('plugin'=>$this->name)); + + if (!$count) { + return ''; + } + + $migrateurl = new moodle_url('/admin/enrol.php', array('action'=>'migrate', 'enrol'=>$this->name, 'sesskey'=>sesskey())); + $migrate = new single_button($migrateurl, get_string('migratetomanual', 'core_enrol')); + $button = $OUTPUT->render($migrate); + + $result = '

'.get_string('uninstallextraconfirmenrol', 'core_plugin', array('enrolments'=>$count)).'

'; + $result .= $button; + + return $result; } } From ba7ce5e150120a5b28857f958ce860a75e820416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:28:27 +0200 Subject: [PATCH 06/13] MDL-39088 migrate local uninstallation to plugin_manager --- admin/localplugins.php | 40 ++++------------------------------------ lang/en/moodle.php | 1 - 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/admin/localplugins.php b/admin/localplugins.php index cd2f26eb6eb..f4061b76703 100644 --- a/admin/localplugins.php +++ b/admin/localplugins.php @@ -33,40 +33,6 @@ require_once($CFG->libdir.'/tablelib.php'); admin_externalpage_setup('managelocalplugins'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', '', PARAM_BOOL); - -/// If data submitted, then process and store. - -if (!empty($delete) and confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('localplugins')); - - if (!$confirm) { - if (get_string_manager()->string_exists('pluginname', 'local_' . $delete)) { - $strpluginname = get_string('pluginname', 'local_' . $delete); - } else { - $strpluginname = $delete; - } - echo $OUTPUT->confirm(get_string('localplugindeleteconfirm', '', $strpluginname), - new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)), - $PAGE->url); - echo $OUTPUT->footer(); - die(); - - } else { - uninstall_plugin('local', $delete); - $a = new stdclass(); - $a->name = $delete; - $pluginlocation = get_plugin_types(); - $a->directory = $pluginlocation['local'] . '/' . $delete; - echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($PAGE->url); - echo $OUTPUT->footer(); - die(); - } -} - echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('localplugins')); @@ -92,8 +58,10 @@ foreach (get_plugin_list('local') as $plugin => $plugindir) { collatorlib::asort($plugins); foreach ($plugins as $plugin => $name) { - $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey())); - $delete = html_writer::link($delete, get_string('delete')); + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) { + $delete = html_writer::link($deleteurl, get_string('uninstallplugin', 'core_admin')); + } $version = get_config('local_' . $plugin); if (!empty($version->version)) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index a7d3b491379..0ff10e41d7e 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -924,7 +924,6 @@ $string['listofallpeople'] = 'List of all people'; $string['listofcourses'] = 'List of courses'; $string['loadinghelp'] = 'Loading...'; $string['local'] = 'Local'; -$string['localplugindeleteconfirm'] = 'You are about to completely delete the local plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; $string['localplugins'] = 'Local plugins'; $string['localpluginsmanage'] = 'Manage local plugins'; $string['location'] = 'Location'; From cd79930e4ddfcdcd107a69f0a6e812ae3efa5cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:30:24 +0200 Subject: [PATCH 07/13] MDL-39088 migrate module uninstallation to plugin_manager --- admin/modules.php | 39 ++++--------------------------------- lang/en/moodle.php | 2 -- lang/en/plugin.php | 1 + lib/pluginlib.php | 25 ++++++++++++++++++++++-- mod/forum/lang/en/forum.php | 1 - 5 files changed, 28 insertions(+), 40 deletions(-) diff --git a/admin/modules.php b/admin/modules.php index 33d2fbbff4e..1364321b639 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -13,8 +13,6 @@ $show = optional_param('show', '', PARAM_PLUGIN); $hide = optional_param('hide', '', PARAM_PLUGIN); - $delete = optional_param('delete', '', PARAM_PLUGIN); - $confirm = optional_param('confirm', '', PARAM_BOOL); /// Print headings @@ -73,38 +71,6 @@ admin_get_root(true, false); // settings not required - only pages } - if (!empty($delete) and confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading($stractivities); - - if (get_string_manager()->string_exists('modulename', $delete)) { - $strmodulename = get_string('modulename', $delete); - } else { - $strmodulename = $delete; - } - - if (!$confirm) { - echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php"); - echo $OUTPUT->footer(); - exit; - - } else { // Delete everything!! - - if ($delete == "forum") { - print_error("cannotdeleteforummodule", 'forum'); - } - - uninstall_plugin('mod', $delete); - $a = new stdClass(); - $a->module = $strmodulename; - $a->directory = "$CFG->dirroot/mod/$delete"; - echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess'); - echo $OUTPUT->continue_button("modules.php"); - echo $OUTPUT->footer(); - exit; - } - } - echo $OUTPUT->header(); echo $OUTPUT->heading($stractivities); @@ -136,7 +102,10 @@ $missing = false; } - $delete = "name&sesskey=".sesskey()."\">$strdelete"; + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) { + $delete = html_writer::link($deleteurl, $strdelete); + } if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") || file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 0ff10e41d7e..474d7bb7f3a 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1056,8 +1056,6 @@ $string['months'] = 'Months'; $string['modified'] = 'Modified'; $string['modchooserenable'] = 'Activity chooser on'; $string['modchooserdisable'] = 'Activity chooser off'; -$string['moduledeleteconfirm'] = 'You are about to completely delete the module \'{$a}\'. This will completely delete everything in the database associated with this activity module. Are you SURE you want to continue?'; -$string['moduledeletefiles'] = 'All data associated with the module \'{$a->module}\' has been deleted from the database. To complete the deletion (and prevent the module re-installing itself), you should now delete this directory from your server: {$a->directory}'; $string['moduleintro'] = 'Description'; $string['modulesetup'] = 'Setting up module tables'; $string['modulesuccess'] = '{$a} tables have been set up correctly'; diff --git a/lang/en/plugin.php b/lang/en/plugin.php index 0b17af6da14..e65e1ea7f18 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -153,6 +153,7 @@ $string['uninstalldeleteconfirm'] = 'All data associated with the plugin {$a $string['uninstalldeleteconfirmexternal'] = 'It appears that the current version of the plugin has been obtained via source code management system ({$a}) checkout. If you remove the plugin folder, you may loose important local modifications of the code. Please ensure that you definitely want to remove the plugin folder before continuing.'; $string['uninstallextraconfirmblock'] = 'There are {$a->instances} instances of this block.'; $string['uninstallextraconfirmenrol'] = 'There are {$a->enrolments} user enrolments.'; +$string['uninstallextraconfirmmod'] = 'There are {$a->instances} instances of this module in {$a->courses} courses.'; $string['uninstalling'] = 'Uninstalling {$a->name}'; $string['version'] = 'Version'; $string['versiondb'] = 'Current version'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index e82c6882b2b..3be9fc4b579 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3423,8 +3423,29 @@ class plugininfo_mod extends plugininfo_base { } } - public function get_uninstall_url() { - return new moodle_url('/admin/modules.php', array('delete' => $this->name, 'sesskey' => sesskey())); + /** + * Return warning with number of activities and number of affected courses. + * + * @return string + */ + public function get_uninstall_extra_warning() { + global $DB; + + if (!$module = $DB->get_record('modules', array('name'=>$this->name))) { + return ''; + } + + if (!$count = $DB->count_records('course_modules', array('module'=>$module->id))) { + return ''; + } + + $sql = "SELECT COUNT(course) + FROM {course_modules} + WHERE module = :mid + GROUP BY course"; + $courses = $DB->count_records_sql($sql, array('mid'=>$module->id)); + + return '

'.get_string('uninstallextraconfirmmod', 'core_plugin', array('instances'=>$count, 'courses'=>$courses)).'

'; } /** diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index 111a31fa17a..d3cc361d12a 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -57,7 +57,6 @@ $string['cannotaddsubscriber'] = 'Could not add subscriber with id {$a} to this $string['cannotaddteacherforumto'] = 'Could not add converted teacher forum instance to section 0 in the course'; $string['cannotcreatediscussion'] = 'Could not create new discussion'; $string['cannotcreateinstanceforteacher'] = 'Could not create new course module instance for the teacher forum'; -$string['cannotdeleteforummodule'] = 'You can not delete the forum module.'; $string['cannotdeletepost'] = 'You can\'t delete this post!'; $string['cannoteditposts'] = 'You can\'t edit other people\'s posts!'; $string['cannotfinddiscussion'] = 'Could not find the discussion in this forum'; From 142f9d5087162fe8efa579e9db12724e3fe2bc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:33:22 +0200 Subject: [PATCH 08/13] MDL-39088 migrate plagiarism uninstallation to plugin_manager --- admin/plagiarism.php | 38 ++++---------------------------------- lang/en/plagiarism.php | 1 - lib/pluginlib.php | 4 ++++ 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/admin/plagiarism.php b/admin/plagiarism.php index 40ed3aec0f0..ba21e3e5175 100644 --- a/admin/plagiarism.php +++ b/admin/plagiarism.php @@ -32,38 +32,6 @@ require_once($CFG->libdir.'/tablelib.php'); admin_externalpage_setup('manageplagiarismplugins'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', false, PARAM_BOOL); - -if (!empty($delete) and confirm_sesskey()) { // If data submitted, then process and store. - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('manageplagiarism', 'plagiarism')); - - if (!$confirm) { - if (get_string_manager()->string_exists('pluginname', 'plagiarism_' . $delete)) { - $strpluginname = get_string('pluginname', 'plagiarism_' . $delete); - } else { - $strpluginname = $delete; - } - echo $OUTPUT->confirm(get_string('plagiarismplugindeleteconfirm', 'plagiarism', $strpluginname), - new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)), - $PAGE->url); - echo $OUTPUT->footer(); - die(); - - } else { - uninstall_plugin('plagiarism', $delete); - $a = new stdclass(); - $a->name = $delete; - $pluginlocation = get_plugin_types(); - $a->directory = $pluginlocation['plagiarism'] . '/' . $delete; - echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($PAGE->url); - echo $OUTPUT->footer(); - die(); - } -} - echo $OUTPUT->header(); // Print the table of all installed plagiarism plugins. @@ -102,8 +70,10 @@ foreach ($plagiarismplugins as $plugin => $dir) { $version = '?'; } // Delete link. - $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey())); - $delete = html_writer::link($delete, get_string('delete')); + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin)) { + $delete = html_writer::link($deleteurl, get_string('delete')); + } $table->data[] = array($displayname, $version, $delete, $settings); } } diff --git a/lang/en/plagiarism.php b/lang/en/plagiarism.php index 23f89c4102d..7faba073560 100644 --- a/lang/en/plagiarism.php +++ b/lang/en/plagiarism.php @@ -6,4 +6,3 @@ $string['configenableplagiarism'] = 'This will allow administrators to configure $string['manageplagiarism'] = 'Manage plagiarism plugins'; $string['nopluginsinstalled'] = 'No plagiarism plugins are installed.'; $string['plagiarism'] = 'Plagiarism prevention'; -$string['plagiarismplugindeleteconfirm'] = 'You are about to completely delete the plagiarism plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 3be9fc4b579..a99150b8e1a 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3978,6 +3978,10 @@ class plugininfo_plagiarism extends plugininfo_base { $adminroot->add($parentnodename, $settings); } } + + public function is_uninstall_allowed() { + return true; + } } /** From 0a53e5c5ae05247441a5fbecb30b95bdeb3bb456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:36:43 +0200 Subject: [PATCH 09/13] MDL-39088 migrate report uninstallation to plugin_manager --- admin/reports.php | 40 ++++------------------------------------ lang/en/admin.php | 1 - lib/pluginlib.php | 8 ++------ 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/admin/reports.php b/admin/reports.php index e03c9282993..00e9a69b1e3 100644 --- a/admin/reports.php +++ b/admin/reports.php @@ -33,40 +33,6 @@ require_once($CFG->libdir.'/tablelib.php'); admin_externalpage_setup('managereports'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', '', PARAM_BOOL); - -/// If data submitted, then process and store. - -if (!empty($delete) and confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('reports')); - - if (!$confirm) { - if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) { - $strpluginname = get_string('pluginname', 'report_' . $delete); - } else { - $strpluginname = $delete; - } - echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname), - new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)), - $PAGE->url); - echo $OUTPUT->footer(); - die(); - - } else { - uninstall_plugin('report', $delete); - $a = new stdclass(); - $a->name = $delete; - $pluginlocation = get_plugin_types(); - $a->directory = $pluginlocation['report'] . '/' . $delete; - echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($PAGE->url); - echo $OUTPUT->footer(); - die(); - } -} - echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('reports')); @@ -104,8 +70,10 @@ foreach ($installed as $config) { } foreach ($plugins as $plugin => $name) { - $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey())); - $delete = html_writer::link($delete, get_string('delete')); + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('report_'.$plugin)) { + $delete = html_writer::link($deleteurl, get_string('delete')); + } if (!isset($versions[$plugin])) { if (file_exists("$CFG->dirroot/report/$plugin/version.php")) { diff --git a/lang/en/admin.php b/lang/en/admin.php index b20082ff50b..40c6eceec89 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -907,7 +907,6 @@ $string['releasenoteslink'] = 'For information about this version of Moodle, ple $string['rememberusername'] = 'Remember username'; $string['rememberusername_desc'] = 'Enable if you want to store permanent cookies with usernames during user login. Permanent cookies may be considered a privacy issue if used without consent.'; $string['reportsmanage'] = 'Manage reports'; -$string['reportsdeleteconfirm'] = 'You are about to completely delete the report \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; $string['requiredentrieschanged'] = 'IMPORTANT - PLEASE READ
(This warning message will only be displayed during this upgrade)

Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explanation of the changes can be read on the database module forum. The expected behavior of these settings can also be read on Moodle Docs.

This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)
{$a->text}
'; $string['requiremodintro'] = 'Require activity description'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index a99150b8e1a..e0f421702ae 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3883,10 +3883,6 @@ class plugininfo_report extends plugininfo_base { public function is_uninstall_allowed() { return true; } - - public function get_uninstall_url() { - return new moodle_url('/admin/reports.php', array('delete' => $this->name, 'sesskey' => sesskey())); - } } @@ -3895,8 +3891,8 @@ class plugininfo_report extends plugininfo_base { */ class plugininfo_local extends plugininfo_base { - public function get_uninstall_url() { - return new moodle_url('/admin/localplugins.php', array('delete' => $this->name, 'sesskey' => sesskey())); + public function is_uninstall_allowed() { + return true; } } From 958b0af64f95b2096ae9ae99b35ce990b8ba385e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:39:26 +0200 Subject: [PATCH 10/13] MDL-39088 migrate admin tool uninstallation to plugin_manager --- admin/tools.php | 40 ++++------------------------------------ lang/en/admin.php | 1 - lib/pluginlib.php | 4 ---- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/admin/tools.php b/admin/tools.php index 1c4d9158e70..5c7eb38a5c7 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -33,40 +33,6 @@ require_once($CFG->libdir.'/tablelib.php'); admin_externalpage_setup('managetools'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', '', PARAM_BOOL); - -/// If data submitted, then process and store. - -if (!empty($delete) and confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('tools', 'admin')); - - if (!$confirm) { - if (get_string_manager()->string_exists('pluginname', 'tool_' . $delete)) { - $strpluginname = get_string('pluginname', 'tool_' . $delete); - } else { - $strpluginname = $delete; - } - echo $OUTPUT->confirm(get_string('toolsdeleteconfirm', 'admin', $strpluginname), - new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)), - $PAGE->url); - echo $OUTPUT->footer(); - die(); - - } else { - uninstall_plugin('tool', $delete); - $a = new stdclass(); - $a->name = $delete; - $pluginlocation = get_plugin_types(); - $a->directory = $pluginlocation['tool'] . '/' . $delete; - echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($PAGE->url); - echo $OUTPUT->footer(); - die(); - } -} - echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('tools', 'admin')); @@ -104,8 +70,10 @@ foreach ($installed as $config) { } foreach ($plugins as $plugin => $name) { - $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey())); - $delete = html_writer::link($delete, get_string('delete')); + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) { + $delete = html_writer::link($deleteurl, get_string('delete')); + } if (!isset($versions[$plugin])) { if (file_exists("$CFG->dirroot/$CFG->admin/tool/$plugin/version.php")) { diff --git a/lang/en/admin.php b/lang/en/admin.php index 40c6eceec89..6473715c1a3 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1022,7 +1022,6 @@ $string['timezoneisforcedto'] = 'Force all users to use'; $string['timezonenotforced'] = 'Users can choose their own timezone'; $string['tokenizerrecommended'] = 'Installing the optional PHP Tokenizer extension is recommended -- it improves Moodle Networking functionality.'; $string['tools'] = 'Admin tools'; -$string['toolsdeleteconfirm'] = 'You are about to completely delete the admin tool \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; $string['toolsmanage'] = 'Manage admin tools'; $string['unattendedoperation'] = 'Unattended operation'; $string['unbookmarkthispage'] = 'Unbookmark this page'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index e0f421702ae..8b0b32506c8 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3868,10 +3868,6 @@ class plugininfo_tool extends plugininfo_base { public function is_uninstall_allowed() { return true; } - - public function get_uninstall_url() { - return new moodle_url('/admin/tools.php', array('delete' => $this->name, 'sesskey' => sesskey())); - } } From d2fba597efa223fbe989fc1de84b463610b9a9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:43:00 +0200 Subject: [PATCH 11/13] MDL-39088 migrate tinymce plugins uninstallation to plugin_manager --- lib/editor/tinymce/adminlib.php | 12 +--- lib/editor/tinymce/lang/en/editor_tinymce.php | 1 - lib/editor/tinymce/subplugins.php | 64 +++++-------------- 3 files changed, 19 insertions(+), 58 deletions(-) diff --git a/lib/editor/tinymce/adminlib.php b/lib/editor/tinymce/adminlib.php index 6b4b23242e8..982579cd787 100644 --- a/lib/editor/tinymce/adminlib.php +++ b/lib/editor/tinymce/adminlib.php @@ -40,10 +40,6 @@ class plugininfo_tinymce extends plugininfo_base { return true; } - public function get_uninstall_url() { - return new moodle_url('/lib/editor/tinymce/subplugins.php', array('delete' => $this->name, 'sesskey' => sesskey())); - } - public function get_settings_section_name() { return 'tinymce'.$this->name.'settings'; } @@ -235,11 +231,9 @@ class tiynce_subplugins_settings extends admin_setting { } // Add uninstall info. - if ($version) { - $url = new moodle_url($plugininfo->get_uninstall_url(), array('return'=>'settings')); - $uninstall = html_writer::link($url, $struninstall); - } else { - $uninstall = ''; + $uninstall = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('tinymce_' . $name)) { + $uninstall = html_writer::link($deleteurl, $struninstall); } // Add a row to the table. diff --git a/lib/editor/tinymce/lang/en/editor_tinymce.php b/lib/editor/tinymce/lang/en/editor_tinymce.php index 01448775d17..f94de095bc1 100644 --- a/lib/editor/tinymce/lang/en/editor_tinymce.php +++ b/lib/editor/tinymce/lang/en/editor_tinymce.php @@ -34,7 +34,6 @@ $string['customtoolbar_desc'] = 'Each line contains a list of comma separated bu $string['fontselectlist'] = 'Available fonts list'; $string['pluginname'] = 'TinyMCE HTML editor'; $string['settings'] = 'General settings'; -$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?'; $string['subplugintype_tinymce_plural'] = 'Plugins'; diff --git a/lib/editor/tinymce/subplugins.php b/lib/editor/tinymce/subplugins.php index 57c153a7e36..f9818ac9c74 100644 --- a/lib/editor/tinymce/subplugins.php +++ b/lib/editor/tinymce/subplugins.php @@ -25,8 +25,6 @@ require(__DIR__ . '/../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', '', PARAM_BOOL); $disable = optional_param('disable', '', PARAM_PLUGIN); $enable = optional_param('enable', '', PARAM_PLUGIN); $return = optional_param('return', 'overview', PARAM_ALPHA); @@ -44,54 +42,24 @@ if ($return === 'settings') { $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(); - } - -} else { - $disabled = array(); - $disabledsubplugins = get_config('editor_tinymce', 'disabledsubplugins'); - if ($disabledsubplugins) { - $disabledsubplugins = explode(',', $disabledsubplugins); - foreach ($disabledsubplugins as $sp) { - $sp = trim($sp); - if ($sp !== '') { - $disabled[$sp] = $sp; - } +$disabled = array(); +$disabledsubplugins = get_config('editor_tinymce', 'disabledsubplugins'); +if ($disabledsubplugins) { + $disabledsubplugins = explode(',', $disabledsubplugins); + foreach ($disabledsubplugins as $sp) { + $sp = trim($sp); + if ($sp !== '') { + $disabled[$sp] = $sp; } } - - if ($disable) { - $disabled[$disable] = $disable; - } else if ($enable) { - unset($disabled[$enable]); - } - - set_config('disabledsubplugins', implode(',', $disabled), 'editor_tinymce'); } +if ($disable) { + $disabled[$disable] = $disable; +} else if ($enable) { + unset($disabled[$enable]); +} + +set_config('disabledsubplugins', implode(',', $disabled), 'editor_tinymce'); + redirect($returnurl); From dd24dd37ee36010f0ef65a42a7424e35986e418a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:56:24 +0200 Subject: [PATCH 12/13] MDL-39088 use word "Uninstall" consistently in plugin administration UI --- admin/blocks.php | 28 ++++++++++++++-------------- admin/localplugins.php | 12 ++++++------ admin/modules.php | 18 +++++++++--------- admin/plagiarism.php | 17 +++++++++-------- admin/reports.php | 16 +++++++++------- admin/tools.php | 16 +++++++++------- lib/adminlib.php | 21 +++++++++++---------- lib/editor/tinymce/adminlib.php | 6 +++--- 8 files changed, 70 insertions(+), 64 deletions(-) diff --git a/admin/blocks.php b/admin/blocks.php index 2f255ddc957..2ad0a0eced4 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -1,6 +1,6 @@ libdir.'/adminlib.php'); @@ -17,7 +17,7 @@ /// Print headings $strmanageblocks = get_string('manageblocks'); - $strdelete = get_string('delete'); + $struninstall = get_string('uninstallplugin', 'core_admin'); $strversion = get_string('version'); $strhide = get_string('hide'); $strshow = get_string('show'); @@ -97,8 +97,8 @@ $table = new flexible_table('admin-blocks-compatible'); - $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings')); - $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings)); + $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'uninstall', 'settings')); + $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $struninstall, $strsettings)); $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php'); $table->set_attribute('class', 'admintable blockstable generaltable'); $table->set_attribute('id', 'compatibleblockstable'); @@ -140,10 +140,10 @@ } } - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) { - $delete = html_writer::link($deleteurl, $strdelete); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } else { - $delete = ''; + $uninstall = ''; } $settings = ''; // By default, no configuration @@ -209,7 +209,7 @@ ''.$version.'', $visible, $undeletable, - $delete, + $uninstall, $settings ); $table->add_data($row); @@ -222,8 +222,8 @@ $table = new flexible_table('admin-blocks-incompatible'); - $table->define_columns(array('block', 'delete')); - $table->define_headers(array($strname, $strdelete)); + $table->define_columns(array('block', 'uninstall')); + $table->define_headers(array($strname, $struninstall)); $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php'); $table->set_attribute('class', 'incompatibleblockstable generaltable'); @@ -231,14 +231,14 @@ $table->setup(); foreach ($incompatible as $block) { - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) { - $delete = html_writer::link($deleteurl, $strdelete); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } else { - $delete = ''; + $uninstall = ''; } $table->add_data(array( $block->name, - $delete, + $uninstall, )); } $table->print_html(); diff --git a/admin/localplugins.php b/admin/localplugins.php index f4061b76703..782f850f49f 100644 --- a/admin/localplugins.php +++ b/admin/localplugins.php @@ -39,8 +39,8 @@ echo $OUTPUT->heading(get_string('localplugins')); /// Print the table of all installed local plugins $table = new flexible_table('localplugins_administration_table'); -$table->define_columns(array('name', 'version', 'delete')); -$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete'))); +$table->define_columns(array('name', 'version', 'uninstall')); +$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin'))); $table->define_baseurl($PAGE->url); $table->set_attribute('id', 'localplugins'); $table->set_attribute('class', 'admintable generaltable'); @@ -58,9 +58,9 @@ foreach (get_plugin_list('local') as $plugin => $plugindir) { collatorlib::asort($plugins); foreach ($plugins as $plugin => $name) { - $delete = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) { - $delete = html_writer::link($deleteurl, get_string('uninstallplugin', 'core_admin')); + $uninstall = ''; + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) { + $uninstall = html_writer::link($uninstall, get_string('uninstallplugin', 'core_admin')); } $version = get_config('local_' . $plugin); @@ -70,7 +70,7 @@ foreach ($plugins as $plugin => $name) { $version = '?'; } - $table->add_data(array($name, $version, $delete)); + $table->add_data(array($name, $version, $uninstall)); } $table->print_html(); diff --git a/admin/modules.php b/admin/modules.php index 1364321b639..8eab4bc50a6 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -18,7 +18,7 @@ /// Print headings $stractivities = get_string("activities"); - $strdelete = get_string("delete"); + $struninstall = get_string('uninstallplugin', 'core_admin'); $strversion = get_string("version"); $strhide = get_string("hide"); $strshow = get_string("show"); @@ -44,7 +44,7 @@ WHERE module=?"; $DB->execute($sql, array($module->id)); // clear the course modinfo cache for courses - // where we just deleted something + // where we just uninstalld something $sql = "UPDATE {course} SET modinfo='' WHERE id IN (SELECT DISTINCT course @@ -83,8 +83,8 @@ /// Print the table of all modules // construct the flexible table ready to display $table = new flexible_table(MODULE_TABLE); - $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings')); - $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strdelete, $strsettings)); + $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings')); + $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $struninstall, $strsettings)); $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php'); $table->set_attribute('id', 'modules'); $table->set_attribute('class', 'generaltable'); @@ -102,9 +102,9 @@ $missing = false; } - $delete = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) { - $delete = html_writer::link($deleteurl, $strdelete); + $uninstall = ''; + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") || @@ -141,7 +141,7 @@ $class = ' class="dimmed_text"'; } if ($module->name == "forum") { - $delete = ""; + $uninstall = ""; $visible = ""; $class = ""; } @@ -152,7 +152,7 @@ $countlink, ''.$module->version.'', $visible, - $delete, + $uninstall, $settings )); } diff --git a/admin/plagiarism.php b/admin/plagiarism.php index ba21e3e5175..db2cd2f1bf6 100644 --- a/admin/plagiarism.php +++ b/admin/plagiarism.php @@ -18,7 +18,7 @@ * Provides an overview of installed plagiarism plugins * * Displays the list of found plagiarism plugins, their version (if found) and - * a link to delete the plagiarism plugin. + * a link to uninstall the plagiarism plugin. * * @see http://docs.moodle.org/dev/Plagiarism_API * @package admin @@ -36,7 +36,8 @@ echo $OUTPUT->header(); // Print the table of all installed plagiarism plugins. -$txt = get_strings(array('settings', 'name', 'version', 'delete')); +$txt = get_strings(array('settings', 'name', 'version')); +$txt->uninstall = get_string('uninstallplugin', 'core_admin'); $plagiarismplugins = get_plugin_list('plagiarism'); if (empty($plagiarismplugins)) { @@ -49,7 +50,7 @@ echo $OUTPUT->heading(get_string('availableplugins', 'plagiarism'), 3, 'main'); echo $OUTPUT->box_start('generalbox authsui'); $table = new html_table(); -$table->head = array($txt->name, $txt->version, $txt->delete, $txt->settings); +$table->head = array($txt->name, $txt->version, $txt->uninstall, $txt->settings); $table->colclasses = array('mdl-left', 'mdl-align', 'mdl-align', 'mdl-align'); $table->data = array(); $table->attributes['class'] = 'manageplagiarismtable generaltable'; @@ -69,12 +70,12 @@ foreach ($plagiarismplugins as $plugin => $dir) { } else { $version = '?'; } - // Delete link. - $delete = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin)) { - $delete = html_writer::link($deleteurl, get_string('delete')); + // uninstall link. + $uninstall = ''; + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin)) { + $uninstall = html_writer::link($uninstallurl, $txt->uninstall); } - $table->data[] = array($displayname, $version, $delete, $settings); + $table->data[] = array($displayname, $version, $uninstall, $settings); } } echo html_writer::table($table); diff --git a/admin/reports.php b/admin/reports.php index 00e9a69b1e3..19fafdb1bf3 100644 --- a/admin/reports.php +++ b/admin/reports.php @@ -18,7 +18,7 @@ * Provides an overview of installed reports * * Displays the list of found reports, their version (if found) and - * a link to delete the report. + * a link to uninstall the report. * * The code is based on admin/localplugins.php by David Mudrak. * @@ -38,9 +38,11 @@ echo $OUTPUT->heading(get_string('reports')); /// Print the table of all installed report plugins +$struninstall = get_string('uninstallplugin', 'core_admin'); + $table = new flexible_table('reportplugins_administration_table'); -$table->define_columns(array('name', 'version', 'delete')); -$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete'))); +$table->define_columns(array('name', 'version', 'uninstall')); +$table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall)); $table->define_baseurl($PAGE->url); $table->set_attribute('id', 'reportplugins'); $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide'); @@ -70,9 +72,9 @@ foreach ($installed as $config) { } foreach ($plugins as $plugin => $name) { - $delete = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('report_'.$plugin)) { - $delete = html_writer::link($deleteurl, get_string('delete')); + $uninstall = ''; + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('report_'.$plugin)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } if (!isset($versions[$plugin])) { @@ -94,7 +96,7 @@ foreach ($plugins as $plugin => $name) { } } - $table->add_data(array($name, $version, $delete)); + $table->add_data(array($name, $version, $uninstall)); } $table->print_html(); diff --git a/admin/tools.php b/admin/tools.php index 5c7eb38a5c7..51976bd2b3c 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -18,7 +18,7 @@ * Provides an overview of installed admin tools * * Displays the list of found admin tools, their version (if found) and - * a link to delete the admin tool. + * a link to uninstall the admin tool. * * The code is based on admin/localplugins.php by David Mudrak. * @@ -38,9 +38,11 @@ echo $OUTPUT->heading(get_string('tools', 'admin')); /// Print the table of all installed tool plugins +$struninstall = get_string('uninstallplugin', 'core_admin'); + $table = new flexible_table('toolplugins_administration_table'); -$table->define_columns(array('name', 'version', 'delete')); -$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete'))); +$table->define_columns(array('name', 'version', 'uninstall')); +$table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall)); $table->define_baseurl($PAGE->url); $table->set_attribute('id', 'toolplugins'); $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide'); @@ -70,9 +72,9 @@ foreach ($installed as $config) { } foreach ($plugins as $plugin => $name) { - $delete = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) { - $delete = html_writer::link($deleteurl, get_string('delete')); + $uninstall = ''; + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } if (!isset($versions[$plugin])) { @@ -94,7 +96,7 @@ foreach ($plugins as $plugin => $name) { } } - $table->add_data(array($name, $version, $delete)); + $table->add_data(array($name, $version, $uninstall)); } $table->print_html(); diff --git a/lib/adminlib.php b/lib/adminlib.php index 2c930eef028..79d06a8d719 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5129,7 +5129,7 @@ class admin_setting_manageenrols extends admin_setting { $strsettings = get_string('settings'); $strenable = get_string('enable'); $strdisable = get_string('disable'); - $struninstall = get_string('uninstallplugin', 'admin'); + $struninstall = get_string('uninstallplugin', 'core_admin'); $strusage = get_string('enrolusage', 'enrol'); $strversion = get_string('version'); @@ -5240,8 +5240,8 @@ class admin_setting_manageenrols extends admin_setting { // Add uninstall info. $uninstall = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) { - $uninstall = html_writer::link($deleteurl, $struninstall); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } // Add a row to the table. @@ -5861,7 +5861,7 @@ class admin_setting_manageeditors extends admin_setting { // display strings $txt = get_strings(array('administration', 'settings', 'edit', 'name', 'enable', 'disable', 'up', 'down', 'none')); - $struninstall = get_string('uninstallplugin', 'admin'); + $struninstall = get_string('uninstallplugin', 'core_admin'); $txt->updown = "$txt->up/$txt->down"; @@ -5942,8 +5942,8 @@ class admin_setting_manageeditors extends admin_setting { } $uninstall = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('editor_'.$editor)) { - $uninstall = html_writer::link($deleteurl, $struninstall); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('editor_'.$editor)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } // add a row to the table @@ -6130,11 +6130,12 @@ class admin_setting_manageformats extends admin_setting { $formats = plugin_manager::instance()->get_plugins_of_type('format'); // display strings - $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default', 'delete')); + $txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default')); + $txt->uninstall = get_string('uninstallplugin', 'core_admin'); $txt->updown = "$txt->up/$txt->down"; $table = new html_table(); - $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->delete, $txt->settings); + $table->head = array($txt->name, $txt->enable, $txt->updown, $txt->uninstall, $txt->settings); $table->align = array('left', 'center', 'center', 'center', 'center'); $table->width = '90%'; $table->attributes['class'] = 'manageformattable generaltable'; @@ -6179,8 +6180,8 @@ class admin_setting_manageformats extends admin_setting { $settings = html_writer::link($format->get_settings_url(), $txt->settings); } $uninstall = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('format_'.$format->name)) { - $uninstall = html_writer::link($deleteurl, $txt->delete); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('format_'.$format->name)) { + $uninstall = html_writer::link($uninstallurl, $txt->uninstall); } $table->data[] =array($strformatname, $hideshow, $updown, $uninstall, $settings); } diff --git a/lib/editor/tinymce/adminlib.php b/lib/editor/tinymce/adminlib.php index 982579cd787..8e57b69ab5d 100644 --- a/lib/editor/tinymce/adminlib.php +++ b/lib/editor/tinymce/adminlib.php @@ -170,7 +170,7 @@ class tiynce_subplugins_settings extends admin_setting { $strenable = get_string('enable'); $strname = get_string('name'); $strsettings = get_string('settings'); - $struninstall = get_string('uninstallplugin', 'admin'); + $struninstall = get_string('uninstallplugin', 'core_admin'); $strversion = get_string('version'); $subplugins = get_plugin_list('tinymce'); @@ -232,8 +232,8 @@ class tiynce_subplugins_settings extends admin_setting { // Add uninstall info. $uninstall = ''; - if ($deleteurl = plugin_manager::instance()->get_uninstall_url('tinymce_' . $name)) { - $uninstall = html_writer::link($deleteurl, $struninstall); + if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('tinymce_' . $name)) { + $uninstall = html_writer::link($uninstallurl, $struninstall); } // Add a row to the table. From 6a407a7c0ecc85d89d5b0efad019a5c8791625b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 15:23:30 +0200 Subject: [PATCH 13/13] MDL-39088 fix enrol migration redirect url Thanks David for spotting it! --- admin/enrol.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/enrol.php b/admin/enrol.php index 3c037129fd4..59f77c53aee 100644 --- a/admin/enrol.php +++ b/admin/enrol.php @@ -119,7 +119,9 @@ switch ($action) { echo $OUTPUT->notification(get_string('success'), 'notifysuccess'); - $return = new moodle_url('/admin/plugins.php', array('uninstall'=>'enrol_'.$enrol, 'sesskey'=>sesskey())); + if (!$return = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) { + $return = new moodle_url('/admin/plugins.php'); + } echo $OUTPUT->continue_button($return); echo $OUTPUT->footer(); exit;