From e84a97b83cf75c5b6e0349d87b21346951a05fff Mon Sep 17 00:00:00 2001 From: ericmerrill Date: Wed, 7 Oct 2009 16:30:07 +0000 Subject: [PATCH] My Moodle: MDL-19089 Course limit for My Moodle not propperly obeyed. Fixing so that it obeys mycoursesperpage and propperly displays '...' --- my/index.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/my/index.php b/my/index.php index ebdd718503c86..64bd4ea33d594 100644 --- a/my/index.php +++ b/my/index.php @@ -66,13 +66,26 @@ // limits the number of courses showing up $courses_limit = 21; - if (!empty($CFG->mycoursesperpage)) { + if (isset($CFG->mycoursesperpage)) { $courses_limit = $CFG->mycoursesperpage; } + + $morecourses = false; + if ($courses_limit > 0) { + $courses_limit = $courses_limit + 1; + } + $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, $courses_limit); $site = get_site(); $course = $site; //just in case we need the old global $course hack + if (($courses_limit > 0) && (count($courses) >= $courses_limit)) { + //remove the 'marker' course that we retrieve just to see if we have more than $courses_limit + array_pop($courses); + $morecourses = true; + } + + if (array_key_exists($site->id,$courses)) { unset($courses[$site->id]); } @@ -92,7 +105,7 @@ } // if more than 20 courses - if (count($courses) > 20) { + if ($morecourses) { echo '
...'; }