MDL-41792 core_calendar: refactored the calendar to allow the use of multiple calendar types

This commit is contained in:
Mark Nelson 2013-09-16 17:30:59 +08:00
parent bb74cdfef3
commit da3041379a
14 changed files with 759 additions and 475 deletions

View file

@ -49,6 +49,7 @@ class block_calendar_month extends block_base {
$calm = optional_param('cal_m', 0, PARAM_INT);
$caly = optional_param('cal_y', 0, PARAM_INT);
$time = optional_param('time', 0, PARAM_INT);
require_once($CFG->dirroot.'/calendar/lib.php');
@ -56,6 +57,15 @@ class block_calendar_month extends block_base {
return $this->content;
}
// If a day, month and year were passed then convert it to a timestamp. If these were passed then we can assume
// the day, month and year are passed as Gregorian, as no where in core should we be passing these values rather
// than the time. This is done for BC.
if (!empty($calm) && (!empty($caly))) {
$time = make_timestamp($caly, $calm, 1);
} else if (empty($time)) {
$time = time();
}
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
@ -78,11 +88,11 @@ class block_calendar_month extends block_base {
list($courses, $group, $user) = calendar_set_filters($filtercourse);
if ($issite) {
// For the front page.
$this->content->text .= calendar_get_mini($courses, $group, $user, $calm, $caly, 'frontpage', $courseid);
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
// No filters for now.
} else {
// For any other course.
$this->content->text .= calendar_get_mini($courses, $group, $user, $calm, $caly, 'course', $courseid);
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
$this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
}