From 026579bbc3adc0f9abc066e2327468704fc62561 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:08:50 +0000 Subject: [PATCH] course/search.php: smarter about contexts, bugfix in pagination Save a ton of queries about contexts, and a bugfix in how we are calling the pagination for get_courses_search(). --- course/search.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/course/search.php b/course/search.php index 6a75f70397..7b27391cd3 100644 --- a/course/search.php +++ b/course/search.php @@ -163,8 +163,8 @@ $totalcount = count($courses); } else { - $courses = get_courses_search($searchterms, "fullname ASC", - $page*$perpage, $perpage, $totalcount); + $courses = get_courses_search($searchterms, "fullname ASC", + $page, $perpage, $totalcount); } $searchform = print_course_search($search, true, "navbar"); @@ -219,9 +219,14 @@ echo "$strcategory\n"; echo "$strselect\n"; echo "$stredit\n"; - foreach ($courses as $course) { - $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + foreach ($courses as $course) { + + if (isset($course->context)) { + $coursecontext = $course->context; + } else { + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + } $course->fullname = highlight("$search", $course->fullname); $linkcss = $course->visible ? "" : " class=\"dimmed\" "; -- 2.39.5