From 4b929531505f16b46621c89eaabefa3fbf7291b7 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Wed, 19 May 2004 07:12:40 +0000 Subject: [PATCH] Patched file. Bug 1425 closed. (http://moodle.org/bugs/bug.php?op=show&bugid=1425) --- lib/datalib.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/datalib.php b/lib/datalib.php index 22887a6163..4039b87001 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -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 !== "") { -- 2.39.5