From: martinlanghoff Date: Wed, 19 Sep 2007 07:51:19 +0000 (+0000) Subject: accesslib: get_my_courses() fix when called when empty sort X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b9e9491a89610d7308ee227a0e9ebab56311a1b3;p=moodle.git 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. --- 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