]> git.mjollnir.org Git - moodle.git/commitdiff
Eloy's finding: If the user is not a teacher or a student anywhere, this
authordefacer <defacer>
Thu, 1 Apr 2004 08:58:29 +0000 (08:58 +0000)
committerdefacer <defacer>
Thu, 1 Apr 2004 08:58:29 +0000 (08:58 +0000)
caused an SQL error. It was handled correctly, but why an SQL query at all
if we can optimize it away?

Thanks Eloy! :)

calendar/view.php

index 786c138faa5d1640039f36c0b53ad680d7e7ccc2..3931f616c9a51dfd38ad3e501863356245302bfb 100644 (file)
@@ -552,9 +552,14 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
     $defaultcourses = array_diff_assoc($defaultcourses, array(1 => 1)); // Filter the site out
     $getcourses = array_keys($defaultcourses);
 
-    $select = 'id IN ('.implode(',', $getcourses).')';
+    if(!empty($getcourses)) {
+        $select = 'id IN ('.implode(',', $getcourses).')';
+        $coursesdata = get_records_select('course', $select, 'fullname');
+    }
+    else {
+        $coursedata = false;
+    }
 
-    $coursesdata = get_records_select('course', $select, 'fullname');
     echo '<select name="course" onchange="document.location.href=\''.CALENDAR_URL.'set.php?var=setcourse&amp;'.$getvars.'&amp;id=\' + this.value;">';
     echo '<option value="0"'.($SESSION->cal_show_course === false?' selected':'').'>'.get_string('hidden', 'calendar')."</option>\n";
     echo '<option value="1"'.($SESSION->cal_show_course === true?' selected':'').'>'.get_string('shown', 'calendar')."</option>\n";