Fix for bug 1442

- notices
   - course is now properly passed to calendar_filter_controls from block
This commit is contained in:
moodler 2004-05-24 01:28:28 +00:00
parent d980b5da22
commit 3cb9ee3949
2 changed files with 12 additions and 11 deletions

View file

@ -15,7 +15,7 @@ class CourseBlock_calendar_month extends MoodleBlock {
require_once($CFG->dirroot.'/calendar/lib.php'); require_once($CFG->dirroot.'/calendar/lib.php');
if($this->content !== NULL) { if ($this->content !== NULL) {
return $this->content; return $this->content;
} }
@ -23,12 +23,12 @@ class CourseBlock_calendar_month extends MoodleBlock {
$this->content->text = ''; $this->content->text = '';
$this->content->footer = ''; $this->content->footer = '';
if($this->course === NULL) { if ($this->course === NULL) {
// Overrides: use no course at all // Overrides: use no course at all
$courseshown = false; $courseshown = false;
$filtercourse = array(); $filtercourse = array();
}
else { } else {
$courseshown = $this->course->id; $courseshown = $this->course->id;
$filtercourse = array($courseshown => 1); $filtercourse = array($courseshown => 1);
} }
@ -55,19 +55,19 @@ class CourseBlock_calendar_month extends MoodleBlock {
calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse); calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
if($courseshown == 1) { if ($courseshown == 1) {
// 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 {
// For any other course // For any other course
$this->content->text .= calendar_overlib_html(); $this->content->text .= calendar_overlib_html();
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y'])); $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, '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']);
$this->content->text .= calendar_filter_controls('course'); $this->content->text .= calendar_filter_controls('course', '', $this->course);
} }
return $this->content; return $this->content;

View file

@ -559,10 +559,11 @@ function calendar_top_controls($type, $data) {
return $content; return $content;
} }
function calendar_filter_controls($type, $vars = NULL) { function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
global $CFG, $SESSION, $USER; global $CFG, $SESSION, $USER;
$groupevents = true; $groupevents = true;
$getvars = '';
switch($type) { switch($type) {
case 'upcoming': case 'upcoming':
@ -573,13 +574,13 @@ function calendar_filter_controls($type, $vars = NULL) {
break; break;
case 'course': case 'course':
$getvars = '&from=course&id='.$_GET['id']; $getvars = '&from=course&id='.$_GET['id'];
if($course->groupmode == NOGROUPS && $course->groupmodeforce) { if (isset($course->groupmode) and !$course->groupmode and $course->groupmodeforce) {
$groupevents = false; $groupevents = false;
} }
break; break;
} }
if(!empty($vars)) { if (!empty($vars)) {
$getvars .= '&'.$vars; $getvars .= '&'.$vars;
} }