MDL-46499 navigation: better enrolled course limit

We now user $CFG->navcourselimit to limit the number of
courses shown in the navigation when browsing another users
full profile. Previously it showed all courses which caused
some slowdown.
This commit is contained in:
Sam Hemelryk
2014-10-20 10:58:34 +13:00
parent e4fe4fdabe
commit 3fa8adb3a6
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -2277,7 +2277,14 @@ class global_navigation extends navigation_node {
$userscourses = enrol_get_users_courses($user->id);
$userscoursesnode = $usernode->add(get_string('courses'));
$count = 0;
foreach ($userscourses as $usercourse) {
if ($count === (int)$CFG->navcourselimit) {
$url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
$userscoursesnode->add(get_string('showallcourses'), $url);
break;
}
$count++;
$usercoursecontext = context_course::instance($usercourse->id);
$usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
$usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER);
+1 -1
View File
@@ -386,7 +386,7 @@ if (!isset($hiddenfields['mycourses'])) {
$courselisting .= ', ';
}
$shown++;
if(!$showallcourses && $shown==20) {
if (!$showallcourses && $shown == $CFG->navcourselimit) {
$url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
$courselisting .= html_writer::link($url, '...', array('title' => get_string('viewmore')));
break;