]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9059, when teacher creates group event on calendar, they can not see it
authortoyomoyo <toyomoyo>
Mon, 12 Nov 2007 06:27:42 +0000 (06:27 +0000)
committertoyomoyo <toyomoyo>
Mon, 12 Nov 2007 06:27:42 +0000 (06:27 +0000)
calendar/lib.php

index 171f4f3f94a1cf3517948109a179d8de4b4b7705..e1f2e40eb65b53a54595d72ecdb84c1ad20277dd 100644 (file)
@@ -1163,10 +1163,25 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
     if(is_string($SESSION->cal_courses_shown)) {
         $SESSION->cal_courses_shown = intval($SESSION->cal_courses_shown);
     }
-
     if($courseeventsfrom === NULL) {
-        $courseeventsfrom = $SESSION->cal_courses_shown;
+        $courseeventsfrom = $SESSION->cal_courses_shown;    
+    }
+    
+    // MDL-9059, $courseeventsfrom can be an int, or an array of ints, or an array of course objects
+    // convert all to array of objects
+    // we probably should do some clean up and make sure that session is set to use the proper form
+    if (is_int($courseeventsfrom)) { // case of an int, e.g. calendar view page
+        $c = array();
+        $c[$courseeventsfrom] = get_record('course', 'id', $courseeventsfrom);
+        $courseeventsfrom = $c;
+    } else if (is_array($courseeventsfrom)) { // case of an array of ints, e.g. course home page
+        foreach ($courseeventsfrom as $i=>$courseid) {
+            if (is_int($courseid)) {
+                $courseeventsfrom[$i] = get_record('course', 'id', $courseid);
+            } 
+        }    
     }
+
     if($groupeventsfrom === NULL) {
         $groupeventsfrom = $SESSION->cal_courses_shown;
     }