]> git.mjollnir.org Git - moodle.git/commitdiff
Patched file. Bug 1425 closed.
authorstronk7 <stronk7>
Wed, 19 May 2004 07:12:40 +0000 (07:12 +0000)
committerstronk7 <stronk7>
Wed, 19 May 2004 07:12:40 +0000 (07:12 +0000)
(http://moodle.org/bugs/bug.php?op=show&bugid=1425)

lib/datalib.php

index 22887a61637531bd61d8c41074fd9c5e5247e337..4039b870012d67117704b085e8ff184723ca508b 100644 (file)
@@ -1628,13 +1628,17 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
 
     $teachertable = "";
     $visiblecourses = "";
+    $sqland = "";
+    if (!empty($categoryselect)) {
+        $sqland = "AND ";
+    }
     if (!empty($USER)) {  // May need to check they are a teacher
         if (!iscreator()) {
-            $visiblecourses = "AND ((c.visible > 0) OR (t.userid = '$USER->id' AND t.course = c.id))";
+            $visiblecourses = "$sqland ((c.visible > 0) OR (t.userid = '$USER->id' AND t.course = c.id))";
             $teachertable = ", {$CFG->prefix}user_teachers t";
         }
     } else {
-        $visiblecourses = "AND c.visible > 0";
+        $visiblecourses = "$sqland c.visible > 0";
     }
 
     if ($categoryselect or $visiblecourses) {
@@ -1667,13 +1671,17 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
 
     $teachertable = "";
     $visiblecourses = "";
+    $sqland = "";
+    if (!empty($categoryselect)) {
+        $sqland = "AND ";
+    }
     if (!empty($USER)) {  // May need to check they are a teacher
         if (!iscreator()) {
-            $visiblecourses = "AND ((c.visible > 0) OR (t.userid = '$USER->id' AND t.course = c.id))";
+            $visiblecourses = "$sqland ((c.visible > 0) OR (t.userid = '$USER->id' AND t.course = c.id))";
             $teachertable = ", {$CFG->prefix}user_teachers t";
         }
     } else {
-        $visiblecourses = "AND c.visible > 0";
+        $visiblecourses = "$sqland c.visible > 0";
     }
 
     if ($limitfrom !== "") {