mirror of
https://github.com/moodle/moodle.git
synced 2025-05-13 11:51:22 +02:00
Merge branch 'int_uninstall' of https://github.com/skodak/moodle
This commit is contained in:
commit
c72cad1f85
admin
lang/en
lib
mod
@ -95,38 +95,6 @@
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$filtername = filter_get_name($filterpath);
|
||||
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
$linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1));
|
||||
$formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filterpath);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
// Delete all data for this plugin.
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filterpath;
|
||||
$a->directory = "$CFG->dirroot/filter/$filterpath";
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Add any missing filters to the DB table.
|
||||
@ -211,6 +179,9 @@
|
||||
/// Display helper functions ===================================================
|
||||
|
||||
function filters_action_url($filterpath, $action) {
|
||||
if ($action === 'delete') {
|
||||
return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
|
||||
}
|
||||
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,6 @@ require_capability('moodle/site:config', context_system::instance());
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
$uninstall = optional_param('uninstall', 0, PARAM_INT);
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
@ -56,31 +54,7 @@ if (!empty($enable) && confirm_sesskey()) {
|
||||
plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if (!empty($uninstall) && confirm_sesskey()) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$uninstall))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
|
||||
if (!$confirm) {
|
||||
echo $OUTPUT->confirm(get_string('processordeleteconfirm', 'message', $processorname), 'message.php?uninstall='.$processor->id.'&confirm=1', 'message.php');
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
message_processor_uninstall($processor->name);
|
||||
$a = new stdClass();
|
||||
$a->processor = $processorname;
|
||||
$a->directory = $CFG->dirroot.'/message/output/'.$processor->name;
|
||||
notice(get_string('processordeletefiles', 'message', $a), 'message.php');
|
||||
}
|
||||
}
|
||||
|
||||
if ($disable || $enable || $uninstall) {
|
||||
if ($disable || $enable) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
@ -98,4 +72,4 @@ $messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -424,13 +424,9 @@ $string['defaulthomepage'] = 'Default home page for users';
|
||||
$string['defaultrequestcategory'] = 'Default category for course requests';
|
||||
$string['defaultsettinginfo'] = 'Default: {$a}';
|
||||
$string['defaultuserroleid'] = 'Default role for all users';
|
||||
$string['deletefilterareyousure'] = 'Are you sure you want to delete the filter \'{$a}\'';
|
||||
$string['deletefilterareyousuremessage'] = 'You are about to completely delete the filter \'{$a}\'. Are you sure you want to uninstall it?';
|
||||
$string['deletefilterfiles'] = 'All data associated with the filter \'{$a->filter}\' has been deleted from the database. To complete the deletion (and to prevent the filter from re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
$string['deleteincompleteusers'] = 'Delete incomplete users after';
|
||||
$string['deleteunconfirmed'] = 'Delete not fully setup users after';
|
||||
$string['deleteuser'] = 'Delete user';
|
||||
$string['deletingfilter'] = 'Deleting filter \'{$a}\'';
|
||||
$string['density'] = 'Density';
|
||||
$string['denyemailaddresses'] = 'Denied email domains';
|
||||
$string['development'] = 'Development';
|
||||
|
@ -107,8 +107,6 @@ $string['permitted'] = 'Permitted';
|
||||
$string['page-message-x'] = 'Any message pages';
|
||||
$string['private_config'] = 'Popup message window';
|
||||
$string['processortag'] = 'Destination';
|
||||
$string['processordeleteconfirm'] = 'You are about to completely delete message output \'{$a}\'. This will completely delete everything in the database associated with this output. Are you SURE you want to continue?';
|
||||
$string['processordeletefiles'] = 'All data associated with the output \'{$a->processor}\' has been deleted from the database. To complete the deletion (and prevent the output re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
$string['providers_config'] = 'Configure notification methods for incoming messages';
|
||||
$string['providerstag'] = 'Source';
|
||||
$string['recent'] = 'Recent';
|
||||
|
127
lib/adminlib.php
127
lib/adminlib.php
@ -124,6 +124,7 @@ define('INSECURE_DATAROOT_ERROR', 2);
|
||||
*/
|
||||
function uninstall_plugin($type, $name) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
|
||||
// This may take a long time.
|
||||
@set_time_limit(0);
|
||||
@ -166,121 +167,25 @@ function uninstall_plugin($type, $name) {
|
||||
|
||||
echo $OUTPUT->heading($pluginname);
|
||||
|
||||
// Custom plugin uninstall.
|
||||
$plugindirectory = core_component::get_plugin_directory($type, $name);
|
||||
$uninstalllib = $plugindirectory . '/db/uninstall.php';
|
||||
if (file_exists($uninstalllib)) {
|
||||
require_once($uninstalllib);
|
||||
$uninstallfunction = 'xmldb_' . $pluginname . '_uninstall'; // eg. 'xmldb_workshop_uninstall()'
|
||||
if (function_exists($uninstallfunction)) {
|
||||
if (!$uninstallfunction()) {
|
||||
echo $OUTPUT->notification('Encountered a problem running uninstall function for '. $pluginname);
|
||||
}
|
||||
// Do not verify result, let plugin complain if necessary.
|
||||
$uninstallfunction();
|
||||
}
|
||||
}
|
||||
|
||||
if ($type === 'mod') {
|
||||
// perform cleanup tasks specific for activity modules
|
||||
|
||||
if (!$module = $DB->get_record('modules', array('name' => $name))) {
|
||||
print_error('moduledoesnotexist', 'error');
|
||||
}
|
||||
|
||||
// delete all the relevant instances from all course sections
|
||||
if ($coursemods = $DB->get_records('course_modules', array('module' => $module->id))) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
if (!delete_mod_from_section($coursemod->id, $coursemod->section)) {
|
||||
echo $OUTPUT->notification("Could not delete the $strpluginname with id = $coursemod->id from section $coursemod->section");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Increment course.cacherev for courses that used this module.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE module=?)",
|
||||
array($module->id));
|
||||
|
||||
// delete all the course module records
|
||||
$DB->delete_records('course_modules', array('module' => $module->id));
|
||||
|
||||
// delete module contexts
|
||||
if ($coursemods) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
context_helper::delete_instance(CONTEXT_MODULE, $coursemod->id);
|
||||
}
|
||||
}
|
||||
|
||||
// delete the module entry itself
|
||||
$DB->delete_records('modules', array('name' => $module->name));
|
||||
|
||||
// cleanup the gradebook
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Perform any custom uninstall tasks
|
||||
if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
|
||||
require_once($CFG->dirroot . '/mod/' . $module->name . '/lib.php');
|
||||
$uninstallfunction = $module->name . '_uninstall';
|
||||
if (function_exists($uninstallfunction)) {
|
||||
debugging("{$uninstallfunction}() has been deprecated. Use the plugin's db/uninstall.php instead", DEBUG_DEVELOPER);
|
||||
if (!$uninstallfunction()) {
|
||||
echo $OUTPUT->notification('Encountered a problem running uninstall function for '. $module->name.'!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($type === 'enrol') {
|
||||
// NOTE: this is a bit brute force way - it will not trigger events and hooks properly
|
||||
// nuke all role assignments
|
||||
role_unassign_all(array('component'=>$component));
|
||||
// purge participants
|
||||
$DB->delete_records_select('user_enrolments', "enrolid IN (SELECT id FROM {enrol} WHERE enrol = ?)", array($name));
|
||||
// purge enrol instances
|
||||
$DB->delete_records('enrol', array('enrol'=>$name));
|
||||
// tweak enrol settings
|
||||
if (!empty($CFG->enrol_plugins_enabled)) {
|
||||
$enabledenrols = explode(',', $CFG->enrol_plugins_enabled);
|
||||
$enabledenrols = array_unique($enabledenrols);
|
||||
$enabledenrols = array_flip($enabledenrols);
|
||||
unset($enabledenrols[$name]);
|
||||
$enabledenrols = array_flip($enabledenrols);
|
||||
if (is_array($enabledenrols)) {
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($type === 'block') {
|
||||
if ($block = $DB->get_record('block', array('name'=>$name))) {
|
||||
// Inform block it's about to be deleted
|
||||
if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
}
|
||||
|
||||
// First delete instances and related contexts
|
||||
$instances = $DB->get_records('block_instances', array('blockname' => $block->name));
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
|
||||
// Delete block
|
||||
$DB->delete_records('block', array('id'=>$block->id));
|
||||
}
|
||||
} else if ($type === 'format') {
|
||||
if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $name) {
|
||||
$courses = $DB->get_records('course', array('format' => $name), 'id');
|
||||
$data = (object)array('id' => null, 'format' => $defaultformat);
|
||||
foreach ($courses as $record) {
|
||||
$data->id = $record->id;
|
||||
update_course($data);
|
||||
}
|
||||
}
|
||||
$DB->delete_records('course_format_options', array('format' => $name));
|
||||
// Specific plugin type cleanup.
|
||||
$plugininfo = plugin_manager::instance()->get_plugin_info($component);
|
||||
if ($plugininfo) {
|
||||
$plugininfo->uninstall_cleanup();
|
||||
plugin_manager::reset_caches();
|
||||
}
|
||||
$plugininfo = null;
|
||||
|
||||
// perform clean-up task common for all the plugin/subplugin types
|
||||
|
||||
@ -306,11 +211,6 @@ function uninstall_plugin($type, $name) {
|
||||
// delete message provider
|
||||
message_provider_uninstall($component);
|
||||
|
||||
// delete message processor
|
||||
if ($type === 'message') {
|
||||
message_processor_uninstall($name);
|
||||
}
|
||||
|
||||
// delete the plugin tables
|
||||
$xmldbfilepath = $plugindirectory . '/db/install.xml';
|
||||
drop_plugin_tables($component, $xmldbfilepath, false);
|
||||
@ -372,7 +272,12 @@ function get_component_version($component, $source='installed') {
|
||||
// activity module
|
||||
if ($type === 'mod') {
|
||||
if ($source === 'installed') {
|
||||
return $DB->get_field('modules', 'version', array('name'=>$name));
|
||||
if ($CFG->version < 2013092001.02) {
|
||||
return $DB->get_field('modules', 'version', array('name'=>$name));
|
||||
} else {
|
||||
return get_config('mod_'.$name, 'version');
|
||||
}
|
||||
|
||||
} else {
|
||||
$mods = core_component::get_plugin_list('mod');
|
||||
if (empty($mods[$name]) or !is_readable($mods[$name].'/version.php')) {
|
||||
|
@ -3100,6 +3100,19 @@ abstract class plugininfo_base {
|
||||
return $this->get_default_uninstall_url();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
// Override when extending class,
|
||||
// do not forget to call parent::pre_uninstall_cleanup() at the end.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relative directory of the plugin with heading '/'
|
||||
*
|
||||
@ -3254,6 +3267,39 @@ class plugininfo_block extends plugininfo_base {
|
||||
|
||||
return '<p>'.get_string('uninstallextraconfirmblock', 'core_plugin', array('instances'=>$count)).'</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB, $CFG;
|
||||
|
||||
if ($block = $DB->get_record('block', array('name'=>$this->name))) {
|
||||
// Inform block it's about to be deleted
|
||||
if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
|
||||
$blockobject = block_instance($block->name);
|
||||
if ($blockobject) {
|
||||
$blockobject->before_delete(); //only if we can create instance, block might have been already removed
|
||||
}
|
||||
}
|
||||
|
||||
// First delete instances and related contexts
|
||||
$instances = $DB->get_records('block_instances', array('blockname' => $block->name));
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
|
||||
// Delete block
|
||||
$DB->delete_records('block', array('id'=>$block->id));
|
||||
}
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3317,8 +3363,21 @@ class plugininfo_filter extends plugininfo_base {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/filters.php', array('sesskey' => sesskey(), 'filterpath' => $this->name, 'action' => 'delete'));
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('filter_active', array('filter' => $this->name));
|
||||
$DB->delete_records('filter_config', array('filter' => $this->name));
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3429,6 +3488,61 @@ class plugininfo_mod extends plugininfo_base {
|
||||
|
||||
return '<p>'.get_string('uninstallextraconfirmmod', 'core_plugin', array('instances'=>$count, 'courses'=>$courses)).'</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB, $CFG;
|
||||
|
||||
if (!$module = $DB->get_record('modules', array('name' => $this->name))) {
|
||||
parent::uninstall_cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete all the relevant instances from all course sections.
|
||||
if ($coursemods = $DB->get_records('course_modules', array('module' => $module->id))) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
// Do not verify results, there is not much we can do anyway.
|
||||
delete_mod_from_section($coursemod->id, $coursemod->section);
|
||||
}
|
||||
}
|
||||
|
||||
// Increment course.cacherev for courses that used this module.
|
||||
// This will force cache rebuilding on the next request.
|
||||
increment_revision_number('course', 'cacherev',
|
||||
"id IN (SELECT DISTINCT course
|
||||
FROM {course_modules}
|
||||
WHERE module=?)",
|
||||
array($module->id));
|
||||
|
||||
// Delete all the course module records.
|
||||
$DB->delete_records('course_modules', array('module' => $module->id));
|
||||
|
||||
// Delete module contexts.
|
||||
if ($coursemods) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
context_helper::delete_instance(CONTEXT_MODULE, $coursemod->id);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the module entry itself.
|
||||
$DB->delete_records('modules', array('name' => $module->name));
|
||||
|
||||
// Cleanup the gradebook.
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_uninstalled_module($module->name);
|
||||
|
||||
// Do not look for legacy $module->name . '_uninstall any more,
|
||||
// they should have migrated to db/uninstall.php by now.
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3634,6 +3748,43 @@ class plugininfo_enrol extends plugininfo_base {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB, $CFG;
|
||||
|
||||
// NOTE: this is a bit brute force way - it will not trigger events and hooks properly.
|
||||
|
||||
// Nuke all role assignments.
|
||||
role_unassign_all(array('component'=>'enrol_'.$this->name));
|
||||
|
||||
// Purge participants.
|
||||
$DB->delete_records_select('user_enrolments', "enrolid IN (SELECT id FROM {enrol} WHERE enrol = ?)", array($this->name));
|
||||
|
||||
// Purge enrol instances.
|
||||
$DB->delete_records('enrol', array('enrol'=>$this->name));
|
||||
|
||||
// Tweak enrol settings.
|
||||
if (!empty($CFG->enrol_plugins_enabled)) {
|
||||
$enabledenrols = explode(',', $CFG->enrol_plugins_enabled);
|
||||
$enabledenrols = array_unique($enabledenrols);
|
||||
$enabledenrols = array_flip($enabledenrols);
|
||||
unset($enabledenrols[$this->name]);
|
||||
$enabledenrols = array_flip($enabledenrols);
|
||||
if (is_array($enabledenrols)) {
|
||||
set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
|
||||
}
|
||||
}
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3684,20 +3835,24 @@ class plugininfo_message extends plugininfo_base {
|
||||
}
|
||||
|
||||
public function is_uninstall_allowed() {
|
||||
$processors = get_message_processors();
|
||||
if (isset($processors[$this->name])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see plugintype_interface::get_uninstall_url()
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function get_uninstall_url() {
|
||||
$processors = get_message_processors();
|
||||
return new moodle_url('/admin/message.php', array('uninstall' => $processors[$this->name]->id, 'sesskey' => sesskey()));
|
||||
public function uninstall_cleanup() {
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->libdir.'/messagelib.php');
|
||||
message_processor_uninstall($this->name);
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4000,7 +4155,7 @@ class plugininfo_format extends plugininfo_base {
|
||||
if (empty($conf->value)) {
|
||||
continue;
|
||||
}
|
||||
list($type, $name) = explode('_', $conf->component, 2);
|
||||
list($type, $name) = explode('_', $conf->plugin, 2);
|
||||
unset($plugins[$name]);
|
||||
}
|
||||
|
||||
@ -4083,4 +4238,29 @@ class plugininfo_format extends plugininfo_base {
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB;
|
||||
|
||||
if (($defaultformat = get_config('moodlecourse', 'format')) && $defaultformat !== $this->name) {
|
||||
$courses = $DB->get_records('course', array('format' => $this->name), 'id');
|
||||
$data = (object)array('id' => null, 'format' => $defaultformat);
|
||||
foreach ($courses as $record) {
|
||||
$data->id = $record->id;
|
||||
update_course($data);
|
||||
}
|
||||
}
|
||||
|
||||
$DB->delete_records('course_format_options', array('format' => $this->name));
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ information provided here is intended especially for developers.
|
||||
* Use plugin_manager::reset_caches() when changing visibility of plugins.
|
||||
* Implement new method get_enabled_plugins() method in subplugin info classes.
|
||||
* Each plugin should include version information in version.php.
|
||||
* Module and block tables do not contain version column any more, use get_config('xx_yy', 'version') instead.
|
||||
|
||||
DEPRECATIONS:
|
||||
Various previously deprecated functions have now been altered to throw DEBUG_DEVELOPER debugging notices
|
||||
|
@ -125,7 +125,7 @@ function booktool_exportimscp_prepare_files($book, $context) {
|
||||
// Moodle and Book version
|
||||
$moodle_release = $CFG->release;
|
||||
$moodle_version = $CFG->version;
|
||||
$book_version = $DB->get_field('modules', 'version', array('name'=>'book'));
|
||||
$book_version = get_config('mod_book', 'version');
|
||||
$bookname = format_string($book->name, true, array('context'=>$context));
|
||||
|
||||
// Load manifest header
|
||||
|
57
mod/quiz/adminlib.php
Normal file
57
mod/quiz/adminlib.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Quiz admin stuff.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* Quiz admin stuff.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class plugininfo_quiz extends plugininfo_base {
|
||||
public function is_uninstall_allowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-uninstall hook.
|
||||
*
|
||||
* This is intended for disabling of plugin, some DB table purging, etc.
|
||||
*
|
||||
* NOTE: to be called from uninstall_plugin() only.
|
||||
* @private
|
||||
*/
|
||||
public function uninstall_cleanup() {
|
||||
global $DB;
|
||||
|
||||
// Do the opposite of db/install.php scripts - deregister the report.
|
||||
|
||||
$DB->delete_records('quiz_reports', array('name'=>$this->name));
|
||||
|
||||
parent::uninstall_cleanup();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user