Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-39087 Improve the Plugins overview renderer

As suggested by Tim Hunt during the peer-review, rendering methods
should not set properties of the page they are producing HTML code for.
Additionally, the page now uses correct check that the uninstalling can
happen.
  • Loading branch information...
commit c2d2001a145995f437daa52fabea1ab863211341 1 parent ccc6c15
@mudrd8mz mudrd8mz authored
Showing with 22 additions and 14 deletions.
  1. +22 −5 admin/plugins.php
  2. +0 −9 admin/renderer.php
View
27 admin/plugins.php
@@ -18,6 +18,15 @@
/**
* UI for general plugins management
*
+ * Supported HTTP parameters:
+ *
+ * ?fetchremote=1 - check for available updates
+ * ?updatesonly=1 - display plugins with available update only
+ * ?contribonly=1 - display non-standard add-ons only
+ * ?uninstall=foo_bar - uninstall the given plugin
+ * ?delete=foo_bar - delete the plugin folder (it must not be installed)
+ * &confirm=1 - confirm the uninstall or delete action
+ *
* @package core
* @subpackage admin
* @copyright 2011 David Mudrak <david@moodle.com>
@@ -47,16 +56,20 @@
require_sesskey();
$pluginfo = $pluginman->get_plugin_info($uninstall);
+ // Make sure we know the plugin.
if (is_null($pluginfo)) {
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
'plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
}
- $requiredby = $pluginman->other_plugins_that_require($pluginfo->component);
- if (!empty($requiredby)) {
- throw new moodle_exception('err_uninstalling_required_plugin', 'core_plugin', '',
- array('plugin' => $pluginfo->component, 'requiredby' => implode(', ', $requiredby)),
- 'plugin_manager::other_plugins_that_require() returned non-empty array');
+ $pluginname = $pluginman->plugin_name($pluginfo->component);
+ $PAGE->set_title($pluginname);
+ $PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
+
+ if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
+ throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
+ array('plugin' => $pluginfo->component),
+ 'plugin_manager::can_uninstall_plugin() returned false');
}
if (!$confirmed) {
@@ -90,6 +103,10 @@
'plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
}
+ $pluginname = $pluginman->plugin_name($pluginfo->component);
+ $PAGE->set_title($pluginname);
+ $PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
+
// Make sure it is not installed.
if (!is_null($pluginfo->versiondb)) {
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
View
9 admin/renderer.php
@@ -384,9 +384,6 @@ public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugini
$pluginname = $pluginman->plugin_name($pluginfo->component);
- $this->page->set_title($pluginname);
- $this->page->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
-
$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)),
@@ -411,9 +408,6 @@ public function plugin_uninstall_results_removable_page(plugin_manager $pluginma
$pluginname = $pluginman->plugin_name($pluginfo->component);
- $this->page->set_title($pluginname);
- $this->page->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
-
$output .= $this->output->header();
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
@@ -448,9 +442,6 @@ public function plugin_uninstall_results_page(plugin_manager $pluginman, plugini
$pluginname = $pluginman->plugin_name($pluginfo->component);
- $this->page->set_title($pluginname);
- $this->page->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
-
$output .= $this->output->header();
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
Please sign in to comment.
Something went wrong with that request. Please try again.