]> git.mjollnir.org Git - moodle.git/commitdiff
course/search.php: smarter about contexts, bugfix in pagination
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:08:50 +0000 (07:08 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:08:50 +0000 (07:08 +0000)
Save a ton of queries about contexts, and a bugfix in how we are
calling the pagination for get_courses_search().

course/search.php

index 6a75f70397df50156cdac99341487b636527e014..7b27391cd30a4ccbc5c7e3640994a3275f50179a 100644 (file)
         $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");
             echo "<th scope=\"col\">$strcategory</th>\n";
             echo "<th scope=\"col\">$strselect</th>\n";
             echo "<th scope=\"col\">$stredit</th></tr>\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\" ";