MDL-39088 add new general uninstall url support to plugin manager
This commit is contained in:
+9
-5
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user