mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 21:45:37 +02:00
MDL-39088 migrate module uninstallation to plugin_manager
This commit is contained in:
parent
ba7ce5e150
commit
cd79930e4d
@ -13,8 +13,6 @@
|
||||
|
||||
$show = optional_param('show', '', PARAM_PLUGIN);
|
||||
$hide = optional_param('hide', '', PARAM_PLUGIN);
|
||||
$delete = optional_param('delete', '', PARAM_PLUGIN);
|
||||
$confirm = optional_param('confirm', '', PARAM_BOOL);
|
||||
|
||||
|
||||
/// Print headings
|
||||
@ -73,38 +71,6 @@
|
||||
admin_get_root(true, false); // settings not required - only pages
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
if (get_string_manager()->string_exists('modulename', $delete)) {
|
||||
$strmodulename = get_string('modulename', $delete);
|
||||
} else {
|
||||
$strmodulename = $delete;
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else { // Delete everything!!
|
||||
|
||||
if ($delete == "forum") {
|
||||
print_error("cannotdeleteforummodule", 'forum');
|
||||
}
|
||||
|
||||
uninstall_plugin('mod', $delete);
|
||||
$a = new stdClass();
|
||||
$a->module = $strmodulename;
|
||||
$a->directory = "$CFG->dirroot/mod/$delete";
|
||||
echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button("modules.php");
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($stractivities);
|
||||
|
||||
@ -136,7 +102,10 @@
|
||||
$missing = false;
|
||||
}
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=".sesskey()."\">$strdelete</a>";
|
||||
$delete = '';
|
||||
if ($deleteurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) {
|
||||
$delete = html_writer::link($deleteurl, $strdelete);
|
||||
}
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/settings.php") ||
|
||||
file_exists("$CFG->dirroot/mod/$module->name/settingstree.php")) {
|
||||
|
@ -1056,8 +1056,6 @@ $string['months'] = 'Months';
|
||||
$string['modified'] = 'Modified';
|
||||
$string['modchooserenable'] = 'Activity chooser on';
|
||||
$string['modchooserdisable'] = 'Activity chooser off';
|
||||
$string['moduledeleteconfirm'] = 'You are about to completely delete the module \'{$a}\'. This will completely delete everything in the database associated with this activity module. Are you SURE you want to continue?';
|
||||
$string['moduledeletefiles'] = 'All data associated with the module \'{$a->module}\' has been deleted from the database. To complete the deletion (and prevent the module re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
$string['moduleintro'] = 'Description';
|
||||
$string['modulesetup'] = 'Setting up module tables';
|
||||
$string['modulesuccess'] = '{$a} tables have been set up correctly';
|
||||
|
@ -153,6 +153,7 @@ $string['uninstalldeleteconfirm'] = 'All data associated with the plugin <em>{$a
|
||||
$string['uninstalldeleteconfirmexternal'] = 'It appears that the current version of the plugin has been obtained via source code management system ({$a}) checkout. If you remove the plugin folder, you may loose important local modifications of the code. Please ensure that you definitely want to remove the plugin folder before continuing.';
|
||||
$string['uninstallextraconfirmblock'] = 'There are {$a->instances} instances of this block.';
|
||||
$string['uninstallextraconfirmenrol'] = 'There are {$a->enrolments} user enrolments.';
|
||||
$string['uninstallextraconfirmmod'] = 'There are {$a->instances} instances of this module in {$a->courses} courses.';
|
||||
$string['uninstalling'] = 'Uninstalling {$a->name}';
|
||||
$string['version'] = 'Version';
|
||||
$string['versiondb'] = 'Current version';
|
||||
|
@ -3423,8 +3423,29 @@ class plugininfo_mod extends plugininfo_base {
|
||||
}
|
||||
}
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/modules.php', array('delete' => $this->name, 'sesskey' => sesskey()));
|
||||
/**
|
||||
* Return warning with number of activities and number of affected courses.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_uninstall_extra_warning() {
|
||||
global $DB;
|
||||
|
||||
if (!$module = $DB->get_record('modules', array('name'=>$this->name))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$count = $DB->count_records('course_modules', array('module'=>$module->id))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(course)
|
||||
FROM {course_modules}
|
||||
WHERE module = :mid
|
||||
GROUP BY course";
|
||||
$courses = $DB->count_records_sql($sql, array('mid'=>$module->id));
|
||||
|
||||
return '<p>'.get_string('uninstallextraconfirmmod', 'core_plugin', array('instances'=>$count, 'courses'=>$courses)).'</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,6 @@ $string['cannotaddsubscriber'] = 'Could not add subscriber with id {$a} to this
|
||||
$string['cannotaddteacherforumto'] = 'Could not add converted teacher forum instance to section 0 in the course';
|
||||
$string['cannotcreatediscussion'] = 'Could not create new discussion';
|
||||
$string['cannotcreateinstanceforteacher'] = 'Could not create new course module instance for the teacher forum';
|
||||
$string['cannotdeleteforummodule'] = 'You can not delete the forum module.';
|
||||
$string['cannotdeletepost'] = 'You can\'t delete this post!';
|
||||
$string['cannoteditposts'] = 'You can\'t edit other people\'s posts!';
|
||||
$string['cannotfinddiscussion'] = 'Could not find the discussion in this forum';
|
||||
|
Loading…
x
Reference in New Issue
Block a user