MDL-35826 - Calendar - Creating a caption containing the month name for mini-calendars
[moodle.git] / blocks / calendar_month / block_calendar_month.php
CommitLineData
4ca6cfbf 1<?php
0f3fe4b6 2
e89d741a 3class block_calendar_month extends block_base {
9b4b78fd 4 function init() {
58aac666 5 $this->title = get_string('pluginname', 'block_calendar_month');
89adb174 6 }
7
3c134875 8 function preferred_width() {
e331bccf 9 return 210;
3c134875 10 }
11
0f3fe4b6 12 function get_content() {
cb640229 13 global $USER, $CFG, $SESSION;
e0de1be5 14 $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
15 $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
0f3fe4b6 16
17 require_once($CFG->dirroot.'/calendar/lib.php');
4ca6cfbf 18
3cb9ee39 19 if ($this->content !== NULL) {
0f3fe4b6 20 return $this->content;
21 }
4ca6cfbf 22
9b4b78fd 23 $this->content = new stdClass;
0f3fe4b6 24 $this->content->text = '';
25 $this->content->footer = '';
26
4ca6cfbf 27 // [pj] To me it looks like this if would never be needed, but Penny added it
13f64465 28 // when committing the /my/ stuff. Reminder to discuss and learn what it's about.
29 // It definitely needs SOME comment here!
797cedc7
SH
30 $courseid = $this->page->course->id;
31 $issite = ($courseid == SITEID);
13f64465 32
797cedc7 33 if ($issite) {
13f64465 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.
797cedc7 36 $filtercourse = calendar_get_default_courses();
dd97c328 37 } else {
13f64465 38 // Forcibly filter events to include only those from the particular course we are in.
797cedc7 39 $filtercourse = array($courseid => $this->page->course);
02d5eba3 40 }
458eb0d1 41
797cedc7
SH
42 list($courses, $group, $user) = calendar_set_filters($filtercourse);
43 if ($issite) {
0f3fe4b6 44 // For the front page
512edd65 45 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'frontpage', $courseid);
0f3fe4b6 46 // No filters for now
1a2ea6f4 47 } else {
0f3fe4b6 48 // For any other course
512edd65 49 $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'course', $courseid);
6284362d 50 $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
e57948f5 51 $this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
02d5eba3 52 }
0f3fe4b6 53
54 return $this->content;
55 }
56}
57
4ca6cfbf 58