]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_14_STABLE moodle--eduforge--1.3.3--patch-305 - Postgres SQL bugfix...
authormartinlanghoff <martinlanghoff>
Thu, 18 Nov 2004 02:37:52 +0000 (02:37 +0000)
committermartinlanghoff <martinlanghoff>
Thu, 18 Nov 2004 02:37:52 +0000 (02:37 +0000)
lib/datalib.php

index 6e2ef1e9d5b9337c03f923c597578991139ff5a3..5d1cf8c8619491c3617e2abfc6dec3017bf2f635 100644 (file)
@@ -2494,19 +2494,20 @@ function instance_is_visible($moduletype, $module) {
 
     global $CFG;
 
-    if ($records = get_records_sql("SELECT cm.instance, cm.visible
-                                    FROM {$CFG->prefix}course_modules cm,
-                                         {$CFG->prefix}modules m
-                                   WHERE cm.course = '$module->course' AND
-                                         cm.module = m.id AND
-                                         m.name = '$moduletype' AND
-                                         cm.instance = '$module->id'")) {
-
-        foreach ($records as $record) { // there should only be one - use the first one
-            return $record->visible;
+    if (!empty($module->id)) {
+        if ($records = get_records_sql("SELECT cm.instance, cm.visible
+                                        FROM {$CFG->prefix}course_modules cm,
+                                             {$CFG->prefix}modules m
+                                       WHERE cm.course = '$module->course' AND
+                                             cm.module = m.id AND
+                                             m.name = '$moduletype' AND
+                                             cm.instance = '$module->id'")) {
+    
+            foreach ($records as $record) { // there should only be one - use the first one
+                return $record->visible;
+            }
         }
     }
-
     return true;  // visible by default!
 }