From b9e9491a89610d7308ee227a0e9ebab56311a1b3 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:51:19 +0000 Subject: [PATCH] accesslib: get_my_courses() fix when called when empty sort get_my_courses() was failing if called with an empty sortorder on a cached courselist. Fix. --- lib/datalib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/datalib.php b/lib/datalib.php index 19e92c2e66..a1707863a3 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -855,6 +855,12 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL $fields = $basefields; } + $orderby = ''; + $sort = trim($sort); + if (!empty($sort)) { + $orderby = "ORDER BY $sort"; + } + // // Logged-in user - Check cached courses // @@ -901,7 +907,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL JOIN {$CFG->prefix}context ctx ON (c.id=ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.") WHERE c.id IN ($courseids) - ORDER BY $sort"; + $orderby"; $rs = get_recordset_sql($sql); $courses = array(); $cc = 0; // keep count -- 2.39.5