From c66e8ae2fdab0176f987d0057204b58fc926f488 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Thu, 29 Sep 2011 12:22:05 -0400 Subject: [PATCH] converted CVS patch from http://tracker.moodle.org/browse/MDL-21427 --- course/lib.php | 46 ++++++++++++++- lib/datalib.php | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 206 insertions(+), 8 deletions(-) diff --git a/course/lib.php b/course/lib.php index 80494ee..cd4139f 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2144,16 +2144,46 @@ function print_my_moodle() { error("It shouldn't be possible to see My Moodle without being logged in."); } - $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary')); + $coursepage = optional_param('coursepage', 0, PARAM_INT); + $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary'), false, 0, $coursepage); $rhosts = array(); $rcourses = array(); + + // calculate the pagination variables without remote courses + $totalcourses = count_my_courses(); + $totalpages = (int) ceil($totalcourses / $CFG->coursesperpage); if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode==='strict') { - $rcourses = get_my_remotecourses($USER->id); - $rhosts = get_my_remotehosts(); + + // calculate pagination variables with remote courses + $remotecoursepage = ($coursepage - $totalpages) + 1; + $remotepageoffset = $totalcourses % $CFG->coursesperpage; + if ($remotepageoffset == 0) { + $remotepageoffset = $CFG->coursesperpage; + } + $totalcourses = $totalcourses + count_my_remote_courses($USER->id); + $totalpages = ceil($totalcourses / $CFG->coursesperpage); + + // only ask for the remote host course if this is a page that contains them + if ($remotecoursepage >= 0) { + $rcourses = get_my_remotecourses($USER->id, + $remotecoursepage, + $remotepageoffset); + } + $rhosts = get_my_remotehosts(); } if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) { + // build the HTML navigation tool to browse between the pages + $paginationhtml = print_paging_bar($totalcourses, $coursepage, + $CFG->coursesperpage, $CFG->wwwroot.'/index.php?', + 'coursepage', false, true); + + if ($totalpages > 1) { + // put the page navigation above the list of courses + echo $paginationhtml; + } + if (!empty($courses)) { echo '