1
<?PHP //$Id: block_calendar_month.php,v 1.11.2.3 2004/09/19 22:18:33 defacer Exp $
1
<?PHP //$Id: block_calendar_month.php,v 1.22 2005/03/03 23:11:13 mjollnir_ Exp $
3
class CourseBlock_calendar_month extends MoodleBlock {
4
function CourseBlock_calendar_month($course) {
3
class block_calendar_month extends block_base {
5
5
$this->title = get_string('calendar', 'calendar');
6
$this->content_type = BLOCK_TYPE_TEXT;
7
$this->course = $course;
8
6
$this->version = 2004081200;
9
function preferred_width() {
11
13
function get_content() {
12
14
global $USER, $CFG, $SESSION;
13
15
optional_variable($_GET['cal_m']);
14
16
optional_variable($_GET['cal_y']);
16
18
require_once($CFG->dirroot.'/calendar/lib.php');
18
20
if ($this->content !== NULL) {
19
21
return $this->content;
22
$this->content = New object;
24
$this->content = new stdClass;
23
25
$this->content->text = '';
24
26
$this->content->footer = '';
26
if (empty($this->course)) { // Overrides: use no course at all
28
if (empty($this->instance)) { // Overrides: use no course at all
28
30
$courseshown = false;
29
31
$filtercourse = array();
33
$courseshown = $this->course->id;
35
$courseshown = $this->instance->pageid;
35
if($this->course->id == SITEID) {
37
if($courseshown == SITEID) {
36
38
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
37
39
// the list of courses it will be grabbing events from.
38
40
$filtercourse = NULL;
49
51
// Be VERY careful with the format for default courses arguments!
50
52
// Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
52
53
calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse);
54
if ($courseshown == 1) {
54
if ($courseshown == SITEID) {
55
55
// For the front page
56
56
$this->content->text .= calendar_overlib_html();
57
57
$this->content->text .= calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
58
58
$this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
59
59
// No filters for now
61
} elseif (!empty($courseshown)) {
62
62
// For any other course
63
63
$this->content->text .= calendar_overlib_html();
64
64
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y']));
65
65
$this->content->text .= calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']);
66
$this->content->text .= calendar_filter_controls('course', '', $this->course);
66
$course = get_record('course', 'id', $this->instance->pageid);
67
$this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $course).'</div>';
69
71
return $this->content;