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 *