mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
making get_my_courses() respect $limit
This commit is contained in:
parent
4e67c97b7d
commit
182c21f139
1 changed files with 9 additions and 5 deletions
|
@ -703,7 +703,11 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
|
||||||
// If using default params, we may have it cached...
|
// If using default params, we may have it cached...
|
||||||
if (!empty($USER->id) && ($USER->id == $userid) && $usingdefaults) {
|
if (!empty($USER->id) && ($USER->id == $userid) && $usingdefaults) {
|
||||||
if (!empty($USER->mycourses[$doanything])) {
|
if (!empty($USER->mycourses[$doanything])) {
|
||||||
return $USER->mycourses[$doanything];
|
if ($limit && $limit < count($USER->mycourses[$doanything])) {
|
||||||
|
return array_slice($USER->mycourses[$doanything], 0, $limit, true);
|
||||||
|
} else {
|
||||||
|
return $USER->mycourses[$doanything];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,11 +765,11 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
|
||||||
c.id
|
c.id
|
||||||
FROM
|
FROM
|
||||||
{$CFG->prefix}role_assignments ra
|
{$CFG->prefix}role_assignments ra
|
||||||
INNER JOIN {$CFG->prefix}context x ON x.id = ra.contextid
|
INNER JOIN {$CFG->prefix}context x ON x.id = ra.contextid
|
||||||
INNER JOIN {$CFG->prefix}course_categories a ON a.path LIKE ".sql_concat("'%/'", 'x.instanceid', "'/%'")." OR x.instanceid = a.id
|
INNER JOIN {$CFG->prefix}course_categories a ON a.path LIKE ".sql_concat("'%/'", 'x.instanceid', "'/%'")." OR x.instanceid = a.id
|
||||||
INNER JOIN {$CFG->prefix}course c ON c.category = a.id
|
INNER JOIN {$CFG->prefix}course c ON c.category = a.id
|
||||||
WHERE
|
WHERE
|
||||||
ra.userid = $userid AND
|
ra.userid = $userid AND
|
||||||
x.contextlevel = 40
|
x.contextlevel = 40
|
||||||
UNION
|
UNION
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -816,7 +820,7 @@ function get_my_courses($userid, $sort=NULL, $fields=NULL, $doanything=false,$li
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache if using default params...
|
// 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;
|
$USER->mycourses[$doanything] = $mycourses;
|
||||||
}
|
}
|
||||||
return $mycourses;
|
return $mycourses;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue