3 class block_calendar_upcoming
extends block_base
{
5 $this->title
= get_string('upcomingevents', 'calendar');
6 $this->version
= 2004052600;
9 function get_content() {
10 global $USER, $CFG, $SESSION, $COURSE;
11 $cal_m = optional_param( 'cal_m', 0, PARAM_INT
);
12 $cal_y = optional_param( 'cal_y', 0, PARAM_INT
);
14 require_once($CFG->dirroot
.'/calendar/lib.php');
16 if ($this->content
!== NULL) {
17 return $this->content
;
19 // Initialize the session variables
20 calendar_session_vars();
21 $this->content
= new stdClass
;
22 $this->content
->text
= '';
24 if (empty($this->instance
)) { // Overrides: use no course at all
27 $filtercourse = array();
28 $this->content
->footer
= '';
31 $courseshown = $COURSE->id
;
32 $this->content
->footer
= '<br /><a href="'.$CFG->wwwroot
.
33 '/calendar/view.php?view=upcoming&course='.$courseshown.'">'.
34 get_string('gotocalendar', 'calendar').'</a>...';
35 $context = get_context_instance(CONTEXT_COURSE
, $courseshown);
36 if (has_capability('moodle/calendar:manageentries', $context) ||
37 has_capability('moodle/calendar:manageownentries', $context)) {
38 $this->content
->footer
.= '<br /><a href="'.$CFG->wwwroot
.
39 '/calendar/event.php?action=new&course='.$courseshown.'">'.
40 get_string('newevent', 'calendar').'</a>...';
42 if ($courseshown == SITEID
) {
43 // Being displayed at site level. This will cause the filter to fall back to auto-detecting
44 // the list of courses it will be grabbing events from.
47 // Forcibly filter events to include only those from the particular course we are in.
48 $filtercourse = array($courseshown => 1);
52 // We 'll need this later
53 calendar_set_referring_course($courseshown);
55 // Be VERY careful with the format for default courses arguments!
56 // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
58 calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse, false);
59 $events = calendar_get_upcoming($courses, $group, $user,
60 get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS
),
61 get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS
));
63 if (!empty($this->instance
)) {
64 $this->content
->text
= calendar_get_sideblock_upcoming($events,
65 'view.php?view=day&course='.$courseshown.'&');
68 if (empty($this->content
->text
)) {
69 $this->content
->text
= '<div class="post">'.
70 get_string('noupcomingevents', 'calendar').'</div>';
73 return $this->content
;