From 02ce38480883016667eb1a69f28dff931c6ef0ab Mon Sep 17 00:00:00 2001 From: defacer Date: Sun, 19 Sep 2004 22:25:21 +0000 Subject: [PATCH] Merging fix for bug 1957 from MOODLE_14_STABLE. --- .../calendar_month/block_calendar_month.php | 22 +++++-------------- .../block_calendar_upcoming.php | 20 ++++------------- calendar/lib.php | 13 +++++++++++ 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/blocks/calendar_month/block_calendar_month.php b/blocks/calendar_month/block_calendar_month.php index be288cd213..130409f209 100644 --- a/blocks/calendar_month/block_calendar_month.php +++ b/blocks/calendar_month/block_calendar_month.php @@ -32,22 +32,12 @@ class CourseBlock_calendar_month extends MoodleBlock { $courseshown = $this->course->id; - 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 { + 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 { // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => 1); } diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php index 2d7f9fbc46..752888762f 100644 --- a/blocks/calendar_upcoming/block_calendar_upcoming.php +++ b/blocks/calendar_upcoming/block_calendar_upcoming.php @@ -38,22 +38,10 @@ class CourseBlock_calendar_upcoming extends MoodleBlock { '/calendar/event.php?action=new&course='.$this->course->id.'">'. get_string('newevent', 'calendar').'...'; - 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; - } + 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 { // Forcibly filter events to include only those from the particular course we are in. diff --git a/calendar/lib.php b/calendar/lib.php index 2be1eaf986..e4588dc1cb 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -864,6 +864,19 @@ function calendar_get_course_cached(&$coursecache, $courseid) { function calendar_session_vars() { global $SESSION, $USER; + if(isset($USER) && isset($USER->realuser) && !isset($SESSION->cal_loggedinas)) { + // We just logged in as someone else, update the filtering + unset($SESSION->cal_users_shown); + unset($SESSION->cal_courses_shown); + $SESSION->cal_loggedinas = true; + } + else if(isset($USER) && !isset($USER->realuser) && isset($SESSION->cal_loggedinas)) { + // We just logged back to our real self, update again + unset($SESSION->cal_users_shown); + unset($SESSION->cal_courses_shown); + unset($SESSION->cal_loggedinas); + } + if(!isset($SESSION->cal_course_referer)) { $SESSION->cal_course_referer = 0; } -- 2.39.5