From 958b0af64f95b2096ae9ae99b35ce990b8ba385e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Wed, 26 Jun 2013 13:39:26 +0200 Subject: [PATCH] MDL-39088 migrate admin tool uninstallation to plugin_manager --- admin/tools.php | 40 ++++------------------------------------ lang/en/admin.php | 1 - lib/pluginlib.php | 4 ---- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/admin/tools.php b/admin/tools.php index 1c4d9158e70..5c7eb38a5c7 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -33,40 +33,6 @@ require_once($CFG->libdir.'/tablelib.php'); admin_externalpage_setup('managetools'); -$delete = optional_param('delete', '', PARAM_PLUGIN); -$confirm = optional_param('confirm', '', PARAM_BOOL); - -/// If data submitted, then process and store. - -if (!empty($delete) and confirm_sesskey()) { - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('tools', 'admin')); - - if (!$confirm) { - if (get_string_manager()->string_exists('pluginname', 'tool_' . $delete)) { - $strpluginname = get_string('pluginname', 'tool_' . $delete); - } else { - $strpluginname = $delete; - } - echo $OUTPUT->confirm(get_string('toolsdeleteconfirm', 'admin', $strpluginname), - new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)), - $PAGE->url); - echo $OUTPUT->footer(); - die(); - - } else { - uninstall_plugin('tool', $delete); - $a = new stdclass(); - $a->name = $delete; - $pluginlocation = get_plugin_types(); - $a->directory = $pluginlocation['tool'] . '/' . $delete; - echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess'); - echo $OUTPUT->continue_button($PAGE->url); - echo $OUTPUT->footer(); - die(); - } -} - echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('tools', 'admin')); @@ -104,8 +70,10 @@ foreach ($installed as $config) { } foreach ($plugins as $plugin => $name) { - $delete = new moodle_url($PAGE->url, array('delete' => $plugin, 'sesskey' => sesskey())); - $delete = html_writer::link($delete, get_string('delete')); + $delete = ''; + if ($deleteurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) { + $delete = html_writer::link($deleteurl, get_string('delete')); + } if (!isset($versions[$plugin])) { if (file_exists("$CFG->dirroot/$CFG->admin/tool/$plugin/version.php")) { diff --git a/lang/en/admin.php b/lang/en/admin.php index 40c6eceec89..6473715c1a3 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1022,7 +1022,6 @@ $string['timezoneisforcedto'] = 'Force all users to use'; $string['timezonenotforced'] = 'Users can choose their own timezone'; $string['tokenizerrecommended'] = 'Installing the optional PHP Tokenizer extension is recommended -- it improves Moodle Networking functionality.'; $string['tools'] = 'Admin tools'; -$string['toolsdeleteconfirm'] = 'You are about to completely delete the admin tool \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?'; $string['toolsmanage'] = 'Manage admin tools'; $string['unattendedoperation'] = 'Unattended operation'; $string['unbookmarkthispage'] = 'Unbookmark this page'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index e0f421702ae..8b0b32506c8 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -3868,10 +3868,6 @@ class plugininfo_tool extends plugininfo_base { public function is_uninstall_allowed() { return true; } - - public function get_uninstall_url() { - return new moodle_url('/admin/tools.php', array('delete' => $this->name, 'sesskey' => sesskey())); - } }