]> git.mjollnir.org Git - moodle.git/commitdiff
a few fixes, for MDL-6836, MDL-6835, and MDL-6765
authortoyomoyo <toyomoyo>
Thu, 5 Oct 2006 04:05:07 +0000 (04:05 +0000)
committertoyomoyo <toyomoyo>
Thu, 5 Oct 2006 04:05:07 +0000 (04:05 +0000)
backup/backuplib.php
backup/restore_form.html
backup/restorelib.php

index 2ad2d577cb80a742aff880f0554ef8b06315caef..5633189b24a777eb6072fbea7b4be7b1fccda76d 100644 (file)
                     //Is needed user (exists in needed_users) 
                     if (isset($needed_users[$backupable_user->id])) {
                         $backupable_user->info .= "needed";
-                    }
-                    
+                    } else if (isset($course_users[$backupable_user->id])) {
+                        $backupable_user->info .= "needed"; 
+                    }   // Yu: also needed because they can view course
+                        // might need another variable
+                                        
                     //Now create the backup_id record
                     $backupids_rec->backup_code = $backup_unique_code;
                     $backupids_rec->table_name = "user";
index 20393f0b0d5ee5e8902353d4c537c00d0b02db88..cc5830658172935a11d1553b312438d4bbf02569 100644 (file)
@@ -470,7 +470,8 @@ if ($info->backup_moodle_version < 2006092801) {
 } else {
     // 1.7 and above backup
     $roles = restore_read_xml_roles($xml_file);
-    if (is_array($roles)) { // possible to have course with no roles
+    
+    if (!empty($roles->roles)) { // possible to have course with no roles
 
         foreach ($roles->roles as $roleid=>$role) {
             echo ('<tr><td align="right">');
index 32e7f7b5a03168a100ceea8cf48baaa2076ccd82..988e40ed1e13d3d0e35cf425b78b2260785ca55e 100644 (file)
                     if (!empty($sect->mods)) {
                         //For each mod inside section
                         foreach ($sect->mods as $keym => $mod) {
+                            // Yu: This part is called repeatedly for every instance, 
+                            // so it is necessary to set the granular flag and check isset() 
+                            // when the first instance of this type of mod is processed.
+                            if (!isset($restore->mods[$mod->type]->granular) && is_array($restore->mods[$mod->type]->instances)) {
+                                // This defines whether we want to restore specific
+                                // instances of the modules (granular restore), or
+                                // whether we don't care and just want to restore
+                                // all module instances (non-granular).
+                                $restore->mods[$mod->type]->granular = true;
+                            } else {
+                                $restore->mods[$mod->type]->granular = false;
+                            }
+                          
                             //Check if we've to restore this module (and instance) 
-                            if ($restore->mods[$mod->type]->restore) {
-                                
-                                if (is_array($restore->mods[$mod->type]->instances)) {
-                                    // This defines whether we want to restore specific
-                                    // instances of the modules (granular restore), or
-                                    // whether we don't care and just want to restore
-                                    // all module instances (non-granular).
-                                    $restore->mods[$mod->type]->granular = true;
-                                }
-                                
+                            if ($restore->mods[$mod->type]->restore) {                      
                                 if (empty($restore->mods[$mod->type]->granular)  // 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))) {
             $this->level--;
             $this->content = "";
 
-        }      
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
+        }
 
         //This is the endTag handler we use where we are reading the course_header zone (todo="COURSE_HEADER")
         function endElementCourseHeader($parser, $tagName) {
         if (!empty($course->roleassignments)) {
             $courseassignments = $course->roleassignments;
 
-            foreach ($courseassignments as $oldroleid => $courseassignment) {          
+            foreach ($courseassignments as $oldroleid => $courseassignment) {    
                 restore_write_roleassignments($restore, $courseassignment->assignments, "course", CONTEXT_COURSE, $course->course_id, $oldroleid);
             }
         }
             $newcontext = get_context_instance($contextlevel, $oldinstance->new_id);
             $assignment->contextid = $newcontext->id; // new context id
             // might already have same assignment           
-            
             role_assign($assignment->roleid, $assignment->userid, 0, $assignment->contextid, $assignment->timestart, $assignment->timeend, $assignment->hidden, $assignment->enrol);
             
         }