]> git.mjollnir.org Git - moodle.git/commitdiff
Now, after restoring the course, the restore proccess executes
authorstronk7 <stronk7>
Fri, 9 Apr 2004 23:40:37 +0000 (23:40 +0000)
committerstronk7 <stronk7>
Fri, 9 Apr 2004 23:40:37 +0000 (23:40 +0000)
every MODULE_refresh_events() function to recalculate every
activity event automatically.

backup/restore_execute.html
backup/restorelib.php
backup/version.php

index c7887d9409bad476391b51856915f51b402ae410..a0306e79e677e4dd704d883ae444f2df351088bc 100644 (file)
         }
     }
 
+    //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:
     //   - course modinfo field 
     //   - categories table
index 05348033f4327a051abfcdc758bd08bfc2382639..af2f42b22e658a9a757bcf7a1df092039d4a06c8 100644 (file)
         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) {
 
                         $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;
index 8978af3f6dd346d04d812e921accb0d5a2171da7..5de75d2c0c53180036162021ccf597de5c25c5fc 100644 (file)
@@ -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