MDL-49329 admin: Add ability to cancel installation of a new plugin
The plugins check screen now provides buttons to cancel installation of a plugin. Available only for new installations (not upgrades) and for additional plugins (not standard), given that the web server process has write access to the plugin folder. This has also been reported as MDL-48535. As a part of the patch, there is improved processing of page URLs during the upgrade. All this dancing around $reload URL is not needed once the $PAGE->url is properly set to guide the admin on the correct page during the upgrade process.
This commit is contained in:
@@ -1531,6 +1531,43 @@ class core_plugin_manager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the plugin code directory if it is not installed yet.
|
||||
*
|
||||
* This is intended for the plugins check screen to give the admin a chance
|
||||
* to cancel the installation of just unzipped plugin before the database
|
||||
* upgrade happens.
|
||||
*
|
||||
* @param string $component
|
||||
* @return bool
|
||||
*/
|
||||
public function cancel_plugin_installation($component) {
|
||||
|
||||
$plugin = $this->get_plugin_info($component);
|
||||
|
||||
if (empty($plugin) or $plugin->is_standard() or $plugin->get_status() !== self::PLUGIN_STATUS_NEW
|
||||
or !$this->is_plugin_folder_removable($plugin->component)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return remove_dir($plugin->rootdir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels installation of all new additional plugins.
|
||||
*/
|
||||
public function cancel_all_plugin_installations() {
|
||||
|
||||
foreach ($this->get_plugins() as $type => $plugins) {
|
||||
foreach ($plugins as $plugin) {
|
||||
if (!$plugin->is_standard() and $plugin->get_status() === self::PLUGIN_STATUS_NEW
|
||||
and $this->is_plugin_folder_removable($plugin->component)) {
|
||||
$this->cancel_plugin_installation($plugin->component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorders plugin types into a sequence to be displayed
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user