Permalink
Browse files

Fix for case calling get_courses("all") when there is no user

  • Loading branch information...
moodler
moodler committed Jan 8, 2004
1 parent 5c27e76 commit 14f3260978c0a95b223ad8e50a2807fa0106add4
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/datalib.php
View
@@ -1527,7 +1527,7 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
$categoryselect = "";
if ($categoryid != "all") {
- $categoryselect = "WHERE c.category = '$categoryid'";
+ $categoryselect = "c.category = '$categoryid'";
}
$teachertable = "";
@@ -1541,7 +1541,12 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
$visiblecourses = "AND c.visible > 0";
}
- $selectsql = "{$CFG->prefix}course c $teachertable $categoryselect $visiblecourses";
+ if ($categoryselect or $visiblecourses) {
+ $selectsql = "{$CFG->prefix}course c $teachertable WHERE $categoryselect $visiblecourses";
+ } else {
+ $selectsql = "{$CFG->prefix}course c $teachertable";
+ }
+
return get_records_sql("SELECT DISTINCT $fields FROM $selectsql ORDER BY $sort");
}

0 comments on commit 14f3260

Please sign in to comment.