From: stronk7 Date: Fri, 9 Apr 2004 23:40:37 +0000 (+0000) Subject: Now, after restoring the course, the restore proccess executes X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=df9a165ecc2f153314f9ab87f0f8d5178167884b;p=moodle.git Now, after restoring the course, the restore proccess executes every MODULE_refresh_events() function to recalculate every activity event automatically. --- diff --git a/backup/restore_execute.html b/backup/restore_execute.html index c7887d9409..a0306e79e6 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -267,6 +267,14 @@ } } + //Now, if all is OK, adjust activity events + if ($status) { + echo "
  • ".get_string("refreshingevents"); + if (!$status = restore_refresh_events($restore)) { + notify("Could not refresh events for activities!"); + } + } + //Now if all is OK, update: // - course modinfo field // - categories table diff --git a/backup/restorelib.php b/backup/restorelib.php index 05348033f4..af2f42b22e 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -52,6 +52,31 @@ 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 function restore_read_xml_info ($xml_file) { @@ -989,10 +1014,9 @@ $eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']); $eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']); - //Now search if that event exists (by description and timestart field) in //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 (!$eve_db) { $create_event = true; diff --git a/backup/version.php b/backup/version.php index 8978af3f6d..5de75d2c0c 100644 --- a/backup/version.php +++ b/backup/version.php @@ -5,6 +5,6 @@ // database (backup_version) to determine whether upgrades should // 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