2009-11-01 12:00:47 +00:00
|
|
|
<?php
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-11-23 18:53:34 +00:00
|
|
|
class block_calendar_month extends block_base {
|
2004-10-19 21:04:28 +00:00
|
|
|
function init() {
|
2010-04-11 11:07:47 +00:00
|
|
|
$this->title = get_string('pluginname', 'block_calendar_month');
|
2004-05-28 10:53:54 +00:00
|
|
|
}
|
|
|
|
|
2005-02-11 15:52:59 +00:00
|
|
|
function preferred_width() {
|
2007-01-27 20:56:55 +00:00
|
|
|
return 210;
|
2005-02-11 15:52:59 +00:00
|
|
|
}
|
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
function get_content() {
|
2009-05-06 09:28:26 +00:00
|
|
|
global $USER, $CFG, $SESSION;
|
2005-06-10 10:05:30 +00:00
|
|
|
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
|
|
|
|
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
require_once($CFG->dirroot.'/calendar/lib.php');
|
2009-11-01 12:00:47 +00:00
|
|
|
|
2004-05-24 01:28:28 +00:00
|
|
|
if ($this->content !== NULL) {
|
2004-04-18 23:20:53 +00:00
|
|
|
return $this->content;
|
|
|
|
}
|
2009-11-01 12:00:47 +00:00
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content = new stdClass;
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->text = '';
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
2009-11-01 12:00:47 +00:00
|
|
|
// [pj] To me it looks like this if would never be needed, but Penny added it
|
2005-11-23 23:40:26 +00:00
|
|
|
// when committing the /my/ stuff. Reminder to discuss and learn what it's about.
|
|
|
|
// It definitely needs SOME comment here!
|
2011-06-29 14:50:38 +08:00
|
|
|
$courseid = $this->page->course->id;
|
|
|
|
$issite = ($courseid == SITEID);
|
2005-11-23 23:40:26 +00:00
|
|
|
|
2011-06-29 14:50:38 +08:00
|
|
|
if ($issite) {
|
2005-11-23 23:40:26 +00:00
|
|
|
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
|
|
|
// the list of courses it will be grabbing events from.
|
2011-06-29 14:50:38 +08:00
|
|
|
$filtercourse = calendar_get_default_courses();
|
2008-01-24 20:33:50 +00:00
|
|
|
} else {
|
2005-11-23 23:40:26 +00:00
|
|
|
// Forcibly filter events to include only those from the particular course we are in.
|
2011-06-29 14:50:38 +08:00
|
|
|
$filtercourse = array($courseid => $this->page->course);
|
2007-10-16 03:47:41 +00:00
|
|
|
}
|
2009-09-17 07:46:20 +00:00
|
|
|
|
2011-06-29 14:50:38 +08:00
|
|
|
list($courses, $group, $user) = calendar_set_filters($filtercourse);
|
|
|
|
if ($issite) {
|
2004-04-18 23:20:53 +00:00
|
|
|
// For the front page
|
2011-06-29 14:50:38 +08:00
|
|
|
$this->content->text .= calendar_top_controls('frontpage', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
|
2005-06-10 10:05:30 +00:00
|
|
|
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
2004-04-18 23:20:53 +00:00
|
|
|
// No filters for now
|
2006-05-29 08:17:57 +00:00
|
|
|
} else {
|
2004-04-18 23:20:53 +00:00
|
|
|
// For any other course
|
2011-06-29 14:50:38 +08:00
|
|
|
$this->content->text .= calendar_top_controls('course', array('id' => $courseid, 'm' => $cal_m, 'y' => $cal_y));
|
2005-06-10 10:05:30 +00:00
|
|
|
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
2007-06-12 09:48:56 +00:00
|
|
|
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
|
2011-06-29 14:50:38 +08:00
|
|
|
$this->content->text .= '<div class="filters">'.calendar_filter_controls($this->page->url).'</div>';
|
2007-10-16 03:47:41 +00:00
|
|
|
}
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-01 12:00:47 +00:00
|
|
|
|