? .backup_check.html.swp
? .backup_execute.html.swp
? .backup_form.html.swp
? .backuplib.php.swp
? .lbi.swp
? .lib.php.swp
? 8189.patchy
Index: backuplib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/backup/backuplib.php,v
retrieving revision 1.187
diff -u -r1.187 backuplib.php
--- backuplib.php	15 Nov 2007 05:00:46 -0000	1.187
+++ backuplib.php	7 Dec 2007 03:59:18 -0000
@@ -2127,17 +2127,14 @@
 
         require_once($CFG->dirroot.'/mod/'.$module.'/backuplib.php');
 
+        $onemodbackup = $module.'_backup_one_mod';
         if (isset($preferences->mods[$module]->instances)
-            && is_array($preferences->mods[$module]->instances)) {
-            $onemodbackup = $module.'_backup_one_mod';
-            if (function_exists($onemodbackup)) {
-                foreach ($preferences->mods[$module]->instances as $instance => $object) {
-                    if (!empty($object->backup)) {
-                        $status = $onemodbackup($bf,$preferences,$instance);
-                    }
+            && is_array($preferences->mods[$module]->instances)
+            && function_exists($onemodbackup)) {
+            foreach ($preferences->mods[$module]->instances as $instance => $object) {
+                if (!empty($object->backup)) {
+                    $status = $onemodbackup($bf,$preferences,$instance);
                 }
-            }  else {
-                $status = false;
             }
         } else { // whole module.
             //First, re-check if necessary functions exists
@@ -2501,26 +2498,32 @@
                 $preferences->$var = true;
                 $count++;
                 // check that there are instances and we can back them up individually
-                if (!count_records('course_modules','course',$course->id,'module',$mod->id) || !function_exists($modbackupone)) {
+                if (!count_records('course_modules','course',$course->id,'module',$mod->id) || (!function_exists($modbackupone) && !function_exists($modbackup))) {
                     continue;
                 }
-                $var = 'exists_one_'.$modname;
-                $preferences->$var = true;
                 $varname = $modname.'_instances';
                 $preferences->$varname = get_all_instances_in_course($modname, $course, NULL, true);
-                foreach ($preferences->$varname as $instance) {
-                    $preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
-                    $var = 'backup_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,0);
-                    $preferences->$var = $$var;
-                    $preferences->mods[$modname]->instances[$instance->id]->backup = $$var;
-                    $var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
-                    $$var = optional_param($var,0);
-                    $preferences->$var = $$var;
-                    $preferences->mods[$modname]->instances[$instance->id]->userinfo = $$var;
-                    $var = 'backup_'.$modname.'_instances';
-                    $preferences->$var = 1; // we need this later to determine what to display in modcheckbackup.
-                }
+                if (function_exists($modbackupone)) {
+                    $var = 'exists_one_'.$modname;
+                    $preferences->$var = true;
+                    foreach ($preferences->$varname as $instance) {
+                        $preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
+                        $var = 'backup_'.$modname.'_instance_'.$instance->id;
+                        $$var = optional_param($var,0);
+                        $preferences->$var = $$var;
+                        $preferences->mods[$modname]->instances[$instance->id]->backup = $$var;
+                        $var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
+                        $$var = optional_param($var,0);
+                        $preferences->$var = $$var;
+                        $preferences->mods[$modname]->instances[$instance->id]->userinfo = $$var;
+                        $var = 'backup_'.$modname.'_instances';
+                        $preferences->$var = 1; // we need this later to determine what to display in modcheckbackup.
+                    }
+                } else {
+                    $var = 'backup_' . $modname . '_instances';
+                    $preferences->$var = 0;
+                    $preferences->mods[$modname]->instances = false;
+                }   
 
                 //Check data
                 //Check module info
