Moodle release 2.5.4
[moodle.git] / blocks / calendar_month / block_calendar_month.php
blobabe28089e9e470d8b6a86b5f8511d0a0ff787151
1 <?php
3 class block_calendar_month extends block_base {
4 function init() {
5 $this->title = get_string('pluginname', 'block_calendar_month');
8 function preferred_width() {
9 return 210;
12 function get_content() {
13 global $USER, $CFG, $SESSION;
14 $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
15 $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
17 require_once($CFG->dirroot.'/calendar/lib.php');
19 if ($this->content !== NULL) {
20 return $this->content;
23 $this->content = new stdClass;
24 $this->content->text = '';
25 $this->content->footer = '';
27 // [pj] To me it looks like this if would never be needed, but Penny added it
28 // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
29 // It definitely needs SOME comment here!
30 $courseid = $this->page->course->id;
31 $issite = ($courseid == SITEID);
33 if ($issite) {
34 // Being displayed at site level. This will cause the filter to fall back to auto-detecting
35 // the list of courses it will be grabbing events from.
36 $filtercourse = calendar_get_default_courses();
37 } else {
38 // Forcibly filter events to include only those from the particular course we are in.
39 $filtercourse = array($courseid => $this->page->course);
42 list($courses, $group, $user) = calendar_set_filters($filtercourse);
43 if ($issite) {
44 // For the front page
45 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'frontpage', $courseid);
46 // No filters for now
47 } else {
48 // For any other course
49 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'course', $courseid);
50 $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
51 $this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
54 return $this->content;