3 class block_calendar_month
extends block_base
{
5 $this->title
= get_string('calendar', 'calendar');
6 $this->version
= 2004081200;
9 function preferred_width() {
13 function get_content() {
14 global $USER, $CFG, $SESSION, $COURSE;
15 $cal_m = optional_param( 'cal_m', 0, PARAM_INT
);
16 $cal_y = optional_param( 'cal_y', 0, PARAM_INT
);
18 require_once($CFG->dirroot
.'/calendar/lib.php');
20 if ($this->content
!== NULL) {
21 return $this->content
;
23 // Initialize the session variables
24 calendar_session_vars();
26 $this->content
= new stdClass
;
27 $this->content
->text
= '';
28 $this->content
->footer
= '';
30 // [pj] To me it looks like this if would never be needed, but Penny added it
31 // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
32 // It definitely needs SOME comment here!
33 $courseshown = $COURSE->id
;
35 if($courseshown == SITEID
) {
36 // Being displayed at site level. This will cause the filter to fall back to auto-detecting
37 // the list of courses it will be grabbing events from.
41 // Forcibly filter events to include only those from the particular course we are in.
42 $filtercourse = array($courseshown => 1);
45 // We 'll need this later
46 calendar_set_referring_course($courseshown);
48 // MDL-9059, set to show this course when admins go into a course, then unset it.
49 if ($COURSE->id
!= SITEID
&& !isset($SESSION->cal_courses_shown
[$COURSE->id
]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM
))) {
51 $SESSION->cal_courses_shown
[$COURSE->id
] = $COURSE;
54 // Be VERY careful with the format for default courses arguments!
55 // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
56 calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
57 if ($courseshown == SITEID
) {
59 $this->content
->text
.= calendar_overlib_html();
60 $this->content
->text
.= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
61 $this->content
->text
.= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
65 // For any other course
66 $this->content
->text
.= calendar_overlib_html();
67 $this->content
->text
.= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
68 $this->content
->text
.= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
69 $this->content
->text
.= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
70 $this->content
->text
.= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
74 // MDL-9059, unset this so that it doesn't stay in session
75 if (!empty($courseset)) {
76 unset($SESSION->cal_courses_shown
[$COURSE->id
]);
79 return $this->content
;