Merging fix for bug 1957 from MOODLE_14_STABLE.

This commit is contained in:
defacer 2004-09-19 22:25:21 +00:00
parent 9ef95d14bb
commit 02ce384808
3 changed files with 23 additions and 32 deletions

View file

@ -32,22 +32,12 @@ class CourseBlock_calendar_month extends MoodleBlock {
$courseshown = $this->course->id; $courseshown = $this->course->id;
if ($this->course->id == SITEID) { // Site-level calendar if($this->course->id == SITEID) {
if (!empty($USER) and !isadmin()) { /// Normal users just see their own courses // Being displayed at site level. This will cause the filter to fall back to auto-detecting
if (!empty($USER->student)) { // the list of courses it will be grabbing events from.
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; $filtercourse = NULL;
} }
} else { else {
// Forcibly filter events to include only those from the particular course we are in. // Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => 1); $filtercourse = array($courseshown => 1);
} }

View file

@ -38,23 +38,11 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
'/calendar/event.php?action=new&course='.$this->course->id.'">'. '/calendar/event.php?action=new&course='.$this->course->id.'">'.
get_string('newevent', 'calendar').'</a>...'; get_string('newevent', 'calendar').'</a>...';
if($this->course->id == SITEID) { // Being displayed at site level. if($this->course->id == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
if (!empty($USER) and !isadmin()) { /// Normal users just see their own courses // the list of courses it will be grabbing events from.
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; $filtercourse = NULL;
} }
}
else { else {
// Forcibly filter events to include only those from the particular course we are in. // Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => 1); $filtercourse = array($courseshown => 1);

View file

@ -864,6 +864,19 @@ function calendar_get_course_cached(&$coursecache, $courseid) {
function calendar_session_vars() { function calendar_session_vars() {
global $SESSION, $USER; 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)) { if(!isset($SESSION->cal_course_referer)) {
$SESSION->cal_course_referer = 0; $SESSION->cal_course_referer = 0;
} }