Fix for bug 1321:

When clicking the month name from the month view block and go to detailed
month view, only events from the course you where in are shown by default.
This commit is contained in:
defacer 2004-05-07 10:39:30 +00:00
parent bd1195678c
commit 51f8a12f28
2 changed files with 21 additions and 5 deletions

View file

@ -36,15 +36,24 @@ class CourseBlock_calendar_month extends MoodleBlock {
// We 'll need this later // We 'll need this later
calendar_set_referring_course($courseshown); calendar_set_referring_course($courseshown);
if($courseshown !== false) {
// By default, the course filter will show this course only
$SESSION->cal_show_course = $courseshown;
}
// [pj] Let's leave this in, the above may not be the final solution
/*
if($courseshown !== false && is_int($SESSION->cal_show_course) && $SESSION->cal_show_course != $courseshown) { if($courseshown !== false && is_int($SESSION->cal_show_course) && $SESSION->cal_show_course != $courseshown) {
// There is a filter in action that shows events from a course other than the current // There is a filter in action that shows events from a course other than the current
// Obviously we have to cut it out // Change it to show only the current course
$SESSION->cal_show_course = true; $SESSION->cal_show_course = $courseshown;
} }
else if($courseshown !== false && is_array($SESSION->cal_show_course) && !in_array($courseshown, $SESSION->cal_show_course)) { else if($courseshown !== false && is_array($SESSION->cal_show_course) && !in_array($courseshown, $SESSION->cal_show_course)) {
// Same as above, only there are many courses being shown. Unfortunately, not this one. // Same as above, only there are many courses being shown. Unfortunately, not this one.
$SESSION->cal_show_course = true; // Change it to show only the current course
$SESSION->cal_show_course = $courseshown;
} }
*/
// Be VERY careful with the format for default courses arguments! // Be VERY careful with the format for default courses arguments!
// Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
@ -55,7 +64,7 @@ class CourseBlock_calendar_month extends MoodleBlock {
// For the front page // For the front page
$this->content->text .= calendar_overlib_html(); $this->content->text .= calendar_overlib_html();
$this->content->text .= calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y'])); $this->content->text .= calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
$this->content->text.= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']); $this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
// No filters for now // No filters for now
} }
else { else {

View file

@ -1007,6 +1007,13 @@ function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL
// WARNING: When calling this function, be VERY careful with the format for default courses arguments! // WARNING: When calling this function, be VERY careful with the format for default courses arguments!
// Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
// Insidious bug-wannabe: setting $SESSION->cal_show_course to $course->id would cause
// the code to function incorrectly UNLESS we convert it to an integer. One case where
// PHP's loose type system works against us.
if(is_string($SESSION->cal_show_course)) {
$SESSION->cal_show_course = intval($SESSION->cal_show_course);
}
$showcourse = ( $showcourse = (
(is_int($SESSION->cal_show_course) && $SESSION->cal_show_course) || (is_int($SESSION->cal_show_course) && $SESSION->cal_show_course) ||
(is_array($SESSION->cal_show_course) && count($SESSION->cal_show_course)) || (is_array($SESSION->cal_show_course) && count($SESSION->cal_show_course)) ||