*** empty log message ***
[moodle-pu.git] / blocks / calendar_month / block_calendar_month.php
blobdd5debbc8a1e0ff2601fae51c867177728cd9fb1
1 <?PHP //$Id$
3 class block_calendar_month extends block_base {
4 function init() {
5 $this->title = get_string('calendar', 'calendar');
6 $this->version = 2004081200;
9 function preferred_width() {
10 return 210;
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.
38 $filtercourse = NULL;
40 else {
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 // Be VERY careful with the format for default courses arguments!
49 // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
50 calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
51 if ($courseshown == SITEID) {
52 // For the front page
53 $this->content->text .= calendar_overlib_html();
54 $this->content->text .= calendar_top_controls('frontpage', array('m' => $cal_m, 'y' => $cal_y));
55 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
56 // No filters for now
58 } else {
59 // For any other course
60 $this->content->text .= calendar_overlib_html();
61 $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
62 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
63 $this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
67 return $this->content;