From f68e5995e54a4e31d8adca0d3579213823dd65a3 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 21 Aug 2003 09:39:07 +0000 Subject: [PATCH] Fix for non-logged-in person --- lib/datalib.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/datalib.php b/lib/datalib.php index 53732ec1f7..e04428e1c1 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1119,13 +1119,15 @@ function get_courses($categoryid="all", $sort="sortorder ASC", $fields="c.*", $categoryselect = "c.category = '$categoryid'"; } - $teachersonly = ""; $teachertable = ""; + $visiblecourses = ""; if (!empty($USER)) { // May need to check they are a teacher if (!isadmin()) { - $teachersonly = "AND ((c.visible = '1') OR (t.userid = '$USER->id' AND t.course = c.id))"; + $visiblecourses = "AND ((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"; } if ($limitfrom !== "") { @@ -1143,7 +1145,7 @@ function get_courses($categoryid="all", $sort="sortorder ASC", $fields="c.*", $limit = ""; } - $selectsql = "{$CFG->prefix}course c $teachertable WHERE $categoryselect $teachersonly "; + $selectsql = "{$CFG->prefix}course c $teachertable WHERE $categoryselect $visiblecourses "; $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql"); -- 2.39.5