From 0a66585b3d087beda8bd30ad4106b0699bef6b79 Mon Sep 17 00:00:00 2001
From: martinlanghoff <martinlanghoff>
Date: Sun, 6 May 2007 05:32:40 +0000
Subject: [PATCH] get_my_courses() callers update - check of the $fields param
 - pass null instead

The default way to call get_my_courses() is now to pass null in the $fields
param to get the (cached copy) of the useful fields. Cuts down enormously
on DB traffic, memory footprint, and session size.
---
 calendar/lib.php  | 4 ++--
 mod/forum/lib.php | 2 +-
 my/index.php      | 2 +-
 user/view.php     | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/calendar/lib.php b/calendar/lib.php
index 5c43b3b020..55c39b6ebc 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -1247,10 +1247,10 @@ function calendar_get_default_courses($ignoreref = false) {
     }
     
     if (isset($CFG->adminseesall)) {
-        $courses = get_my_courses($USER->id, 'visible DESC', '*', $CFG->adminseesall);
+        $courses = get_my_courses($USER->id, 'visible DESC', null, $CFG->adminseesall);
     }
     else {
-        $courses = get_my_courses($USER->id, 'visible DESC', '*', false);
+        $courses = get_my_courses($USER->id, 'visible DESC', null, false);
     }
     // Make sure global events are included
     $courses[0] = true;
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 946eefa16e..e609cad0f7 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -1300,7 +1300,7 @@ function forum_get_readable_forums($userid, $courseid=0) {
         // If no course is specified, then the user can see SITE + his courses. 
         // And admins can see all courses, so pass the $doanything flag enabled
         $courses1 = get_records('course', 'id', SITEID);
-        $courses2 = get_my_courses($userid, 'visible DESC,sortorder ASC', '*', true);
+        $courses2 = get_my_courses($userid, 'visible DESC,sortorder ASC', null, true);
         $courses = array_merge($courses1, $courses2);
     }
     if (!$courses) {
diff --git a/my/index.php b/my/index.php
index 20506423e1..9c8b035420 100644
--- a/my/index.php
+++ b/my/index.php
@@ -55,7 +55,7 @@
 /// The main overview in the middle of the page
     
     // limits the number of courses showing up
-    $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, 21);
+    $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', null, false, 21);
     $site = get_site();
     $course = $site; //just in case we need the old global $course hack
 
diff --git a/user/view.php b/user/view.php
index 6f59476217..a6e01d6ddf 100644
--- a/user/view.php
+++ b/user/view.php
@@ -300,7 +300,7 @@
     profile_display_fields($user->id);
 
 
-    if ($mycourses = get_my_courses($user->id,'visible DESC,sortorder ASC', '*', false, 21)) {
+    if ($mycourses = get_my_courses($user->id,'visible DESC,sortorder ASC', null, false, 21)) {
         $shown=0;
         $courselisting = '';
         foreach ($mycourses as $mycourse) {
-- 
2.39.5