MDL-39088 add new general uninstall url support to plugin manager

This commit is contained in:
Petr Škoda
2013-06-27 22:20:34 +02:00
parent f0d37f4ac5
commit 2f87bb0315
3 changed files with 40 additions and 5 deletions
+9 -5
View File
@@ -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 = '<p>' . get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)) . '</p>';
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
*/
+2
View File
@@ -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
+29
View File
@@ -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
*