MDL-9059, admins can't see group events in calendar
authortoyomoyo <toyomoyo>
Tue, 16 Oct 2007 03:47:41 +0000 (03:47 +0000)
committertoyomoyo <toyomoyo>
Tue, 16 Oct 2007 03:47:41 +0000 (03:47 +0000)
blocks/calendar_month/block_calendar_month.php

index c7dae668fa86e6454f4641fb6e678052c91b169b..ebfa4c0df1edaaacb729da3753d3fae3522809aa 100644 (file)
@@ -45,6 +45,12 @@ class block_calendar_month extends block_base {
         // We 'll need this later
         calendar_set_referring_course($courseshown);
 
+        // MDL-9059, set to show this course when admins go into a course, then unset it.
+        if ($COURSE->id != SITEID && !isset($SESSION->cal_courses_shown[$COURSE->id]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
+            $courseset = true;
+            $SESSION->cal_courses_shown[$COURSE->id] = $COURSE;
+        }
+    
         // Be VERY careful with the format for default courses arguments!
         // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
         calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
@@ -64,6 +70,11 @@ class block_calendar_month extends block_base {
             $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
             
         }
+        
+        // MDL-9059, unset this so that it doesn't stay in session
+        if ($courseset) {
+            unset($SESSION->cal_courses_shown[$COURSE->id]);
+        }
 
         return $this->content;
     }