making get_my_courses() respect $limit

This commit is contained in:
toyomoyo 2007-07-23 08:38:07 +00:00
parent 4e67c97b7d
commit 182c21f139

View file

@ -703,9 +703,13 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
// If using default params, we may have it cached...
if (!empty($USER->id) && ($USER->id == $userid) && $usingdefaults) {
if (!empty($USER->mycourses[$doanything])) {
if ($limit && $limit < count($USER->mycourses[$doanything])) {
return array_slice($USER->mycourses[$doanything], 0, $limit, true);
} else {
return $USER->mycourses[$doanything];
}
}
}
$mycourses = array();
@ -816,7 +820,7 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
}
// Cache if using default params...
if (!empty($USER->id) && ($USER->id == $userid) && $usingdefaults) {
if (!empty($USER->id) && ($USER->id == $userid) && $usingdefaults && $limit == 0) {
$USER->mycourses[$doanything] = $mycourses;
}
return $mycourses;