From: martinlanghoff Date: Wed, 19 Sep 2007 07:08:50 +0000 (+0000) Subject: course/search.php: smarter about contexts, bugfix in pagination X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=026579bbc3adc0f9abc066e2327468704fc62561;p=moodle.git 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(). --- 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\" ";