]> git.mjollnir.org Git - moodle.git/commitdiff
We need the newly created course_module id to be passed to the restore
authorvyshane <vyshane>
Fri, 25 Aug 2006 02:37:54 +0000 (02:37 +0000)
committervyshane <vyshane>
Fri, 25 Aug 2006 02:37:54 +0000 (02:37 +0000)
functions of the modules. We need this now for the forum module to convert
forums backed up in 1.6 to use roles upon restore in 1.7. However, this might
be needed for other modules as well if they need conversion to the roles
system.

backup/restorelib.php

index d62a0003c06cadfb427fa0e72160d7d2c509b6c8..71fb59a71833d7fe7fee52926ff165644833d204 100644 (file)
     //This function creates all the course_sections and course_modules from xml
     //when restoring in a new course or simply checks sections and create records
     //in backup_ids when restoring in a existing course
-    function restore_create_sections($restore,$xml_file) {
+    function restore_create_sections(&$restore, $xml_file) {
 
         global $CFG,$db;
 
                 //Now calculate the section's newid
                 $newid = 0;
                 if ($restore->restoreto == 2) {
-                //Save it to db (only if restoring to new course)
+                    //Save it to db (only if restoring to new course)
                     $newid = insert_record("course_sections",$section);
                 } else {
                     //Get section id when restoring in existing course
                     }
                     //New check. If section 0 doesn't exist, insert it here !!
                     //Teorically this never should happen but, in practice, some users
-                    //have reported this issue. 
+                    //have reported this issue.
                     if(!$rec) {
                         $zero_sec->course = $restore->course_id;
                         $zero_sec->section = 0;
                                 if (!is_array($restore->mods[$mod->type]->instances)  // we don't care about per instance
                                     || (array_key_exists($mod->instance,$restore->mods[$mod->type]->instances) 
                                         && !empty($restore->mods[$mod->type]->instances[$mod->instance]->restore))) {
+                                    
                                     //Get the module id from modules
                                     $module = get_record("modules","name",$mod->type);
                                     if ($module) {
                                             //to use it later
                                             backup_putid ($restore->backup_unique_code,"course_modules",
                                                           $keym,$newidmod,$mod->instance);
+                                            
+                                            $restore->mods[$mod->type]->instances[$mod->instance]->restored_as_course_module = $newidmod;
                                         } else {
                                             $status = false;
                                         }
     function restore_create_modules($restore,$xml_file) {
 
         global $CFG;
-
         $status = true;
         //Check it exists
         if (!file_exists($xml_file)) {