MDL-39088 migrate report uninstallation to plugin_manager

This commit is contained in:
Petr Škoda 2013-06-26 13:36:43 +02:00
parent 142f9d5087
commit 0a53e5c5ae
3 changed files with 6 additions and 43 deletions

View File

@ -33,40 +33,6 @@ require_once($CFG->libdir.'/tablelib.php');
admin_externalpage_setup('managereports');
$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('reports'));
if (!$confirm) {
if (get_string_manager()->string_exists('pluginname', 'report_' . $delete)) {
$strpluginname = get_string('pluginname', 'report_' . $delete);
} else {
$strpluginname = $delete;
}
echo $OUTPUT->confirm(get_string('reportsdeleteconfirm', 'admin', $strpluginname),
new moodle_url($PAGE->url, array('delete' => $delete, 'confirm' => 1)),
$PAGE->url);
echo $OUTPUT->footer();
die();
} else {
uninstall_plugin('report', $delete);
$a = new stdclass();
$a->name = $delete;
$pluginlocation = get_plugin_types();
$a->directory = $pluginlocation['report'] . '/' . $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('reports'));
@ -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('report_'.$plugin)) {
$delete = html_writer::link($deleteurl, get_string('delete'));
}
if (!isset($versions[$plugin])) {
if (file_exists("$CFG->dirroot/report/$plugin/version.php")) {

View File

@ -907,7 +907,6 @@ $string['releasenoteslink'] = 'For information about this version of Moodle, ple
$string['rememberusername'] = 'Remember username';
$string['rememberusername_desc'] = 'Enable if you want to store permanent cookies with usernames during user login. Permanent cookies may be considered a privacy issue if used without consent.';
$string['reportsmanage'] = 'Manage reports';
$string['reportsdeleteconfirm'] = 'You are about to completely delete the report \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?';
$string['requiredentrieschanged'] = '<strong>IMPORTANT - PLEASE READ<br/>(This warning message will only be displayed during this upgrade)</strong><br/>Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explanation of the changes can be read on <a href="http://moodle.org/mod/forum/discuss.php?d=110928" target="_blank">the database module forum</a>. The expected behavior of these settings can also be read on <a href="http://docs.moodle.org/en/Adding/editing_a_database#Required_entries" target="_blank">Moodle Docs</a>.
<br/><br/>This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)<br/><strong>{$a->text}</strong><br/>';
$string['requiremodintro'] = 'Require activity description';

View File

@ -3883,10 +3883,6 @@ class plugininfo_report extends plugininfo_base {
public function is_uninstall_allowed() {
return true;
}
public function get_uninstall_url() {
return new moodle_url('/admin/reports.php', array('delete' => $this->name, 'sesskey' => sesskey()));
}
}
@ -3895,8 +3891,8 @@ class plugininfo_report extends plugininfo_base {
*/
class plugininfo_local extends plugininfo_base {
public function get_uninstall_url() {
return new moodle_url('/admin/localplugins.php', array('delete' => $this->name, 'sesskey' => sesskey()));
public function is_uninstall_allowed() {
return true;
}
}