]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: get_my_courses() fix when called when empty sort
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:51:19 +0000 (07:51 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:51:19 +0000 (07:51 +0000)
get_my_courses() was failing if called with an empty sortorder on a
cached courselist. Fix.

lib/datalib.php

index 19e92c2e664941e87f629b6083350603a9a50b6a..a1707863a3feb032f1d5419086f801968c2ad78f 100644 (file)
@@ -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