mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Now, after restoring the course, the restore proccess executes
every MODULE_refresh_events() function to recalculate every activity event automatically.
This commit is contained in:
parent
866eb2ffbd
commit
df9a165ecc
3 changed files with 35 additions and 3 deletions
|
@ -267,6 +267,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Now, if all is OK, adjust activity events
|
||||||
|
if ($status) {
|
||||||
|
echo "<li>".get_string("refreshingevents");
|
||||||
|
if (!$status = restore_refresh_events($restore)) {
|
||||||
|
notify("Could not refresh events for activities!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Now if all is OK, update:
|
//Now if all is OK, update:
|
||||||
// - course modinfo field
|
// - course modinfo field
|
||||||
// - categories table
|
// - categories table
|
||||||
|
|
|
@ -52,6 +52,31 @@
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This function iterates over all modules in backup file, searching for a
|
||||||
|
//MODNAME_refresh_events() to execute. Perhaps it should ve moved to central Moodle...
|
||||||
|
function restore_refresh_events($restore) {
|
||||||
|
|
||||||
|
global $CFG;
|
||||||
|
$status = true;
|
||||||
|
|
||||||
|
//Take all modules in backup
|
||||||
|
$modules = $restore->mods;
|
||||||
|
//Iterate
|
||||||
|
foreach($modules as $name => $module) {
|
||||||
|
//Only if the module is being restored
|
||||||
|
if ($module->restore == 1) {
|
||||||
|
//Include module library
|
||||||
|
include_once("$CFG->dirroot/mod/$name/lib.php");
|
||||||
|
//If module_refresh_events exists
|
||||||
|
$function_name = $name."_refresh_events";
|
||||||
|
if (function_exists($function_name)) {
|
||||||
|
$status = $function_name($restore->course_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
//This function read the xml file and store it data from the info zone in an object
|
//This function read the xml file and store it data from the info zone in an object
|
||||||
function restore_read_xml_info ($xml_file) {
|
function restore_read_xml_info ($xml_file) {
|
||||||
|
|
||||||
|
@ -989,10 +1014,9 @@
|
||||||
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
|
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
|
||||||
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
|
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
|
||||||
|
|
||||||
|
|
||||||
//Now search if that event exists (by description and timestart field) in
|
//Now search if that event exists (by description and timestart field) in
|
||||||
//restore->course_id course
|
//restore->course_id course
|
||||||
$eve_db = get_record("event","courseid",$restore->course_id,"description",$eve->description,"timestart",$eve->timestart);
|
$eve_db = get_record("event","courseid",$eve->courseid,"description",$eve->description,"timestart",$eve->timestart);
|
||||||
//If it doesn't exist, create
|
//If it doesn't exist, create
|
||||||
if (!$eve_db) {
|
if (!$eve_db) {
|
||||||
$create_event = true;
|
$create_event = true;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
// database (backup_version) to determine whether upgrades should
|
// database (backup_version) to determine whether upgrades should
|
||||||
// be performed (see db/backup_*.php)
|
// be performed (see db/backup_*.php)
|
||||||
|
|
||||||
$backup_version = 2004040100; // The current version is a date (YYYYMMDDXX)
|
$backup_version = 2004041000; // The current version is a date (YYYYMMDDXX)
|
||||||
|
|
||||||
$backup_release = "1.3 development"; // User-friendly version number
|
$backup_release = "1.3 development"; // User-friendly version number
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue