]> git.mjollnir.org Git - moodle.git/commitdiff
Merged changes from stable to fix bug 1957
authormoodler <moodler>
Sat, 18 Sep 2004 13:17:23 +0000 (13:17 +0000)
committermoodler <moodler>
Sat, 18 Sep 2004 13:17:23 +0000 (13:17 +0000)
blocks/calendar_month/block_calendar_month.php
blocks/calendar_upcoming/block_calendar_upcoming.php

index 130409f20987332d57740da508a6420f8b8245a4..be288cd2136b508d4ba2f9ea5c38ab222d1b7a8b 100644 (file)
@@ -32,12 +32,22 @@ class CourseBlock_calendar_month extends MoodleBlock {
 
             $courseshown = $this->course->id;
 
-            if($this->course->id == SITEID) {
-                // Being displayed at site level. This will cause the filter to fall back to auto-detecting
-                // the list of courses it will be grabbing events from.
-                $filtercourse = NULL;
-            }
-            else {
+            if ($this->course->id == SITEID) {         // Site-level calendar
+                if (!empty($USER) and !isadmin()) {   /// Normal users just see their own courses
+                    if (!empty($USER->student)) {
+                        foreach ($USER->student as $courseid => $info) {
+                            $filtercourse[$courseid] = 1;
+                        }
+                    }
+                    if (!empty($USER->teacher)) {
+                        foreach ($USER->teacher as $courseid => $info) {
+                            $filtercourse[$courseid] = 1;
+                        }
+                    }
+                } else {                              /// Let the filter sort it out for admins and guests
+                    $filtercourse = NULL;            
+                }
+            } else {
                 // Forcibly filter events to include only those from the particular course we are in.
                 $filtercourse = array($courseshown => 1);
             }
index 752888762fd1c7c4ed4057ef722584f75183e354..2d7f9fbc46e71143cdeda2acbe2000e224345574 100644 (file)
@@ -38,10 +38,22 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
                                       '/calendar/event.php?action=new&amp;course='.$this->course->id.'">'.
                                        get_string('newevent', 'calendar').'</a>...';
             
-            if($this->course->id == SITEID) {
-                // Being displayed at site level. This will cause the filter to fall back to auto-detecting
-                // the list of courses it will be grabbing events from.
-                $filtercourse = NULL;
+            if($this->course->id == SITEID) {         // Being displayed at site level. 
+
+                if (!empty($USER) and !isadmin()) {   /// Normal users just see their own courses
+                    if (!empty($USER->student)) {
+                        foreach ($USER->student as $courseid => $info) {
+                            $filtercourse[$courseid] = 1;
+                        }
+                    }
+                    if (!empty($USER->teacher)) {
+                        foreach ($USER->teacher as $courseid => $info) {
+                            $filtercourse[$courseid] = 1;
+                        }
+                    }
+                } else {                              /// Let the filter sort it out for admins and guests
+                    $filtercourse = NULL;            
+                }
             }
             else {
                 // Forcibly filter events to include only those from the particular course we are in.