function get_content() { global $USER, $CFG, $SESSION; $cal_m = optional_param('cal_m', 0, PARAM_INT); $cal_y = optional_param('cal_y', 0, PARAM_INT); require_once $CFG->dirroot . '/calendar/lib.php'; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $filtercourse = array(); if (empty($this->instance)) { // Overrides: use no course at all $courseshown = false; $this->content->footer = ''; } else { $courseshown = $this->page->course->id; $this->content->footer = '<div class="gotocal"><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...</div>'; $context = context_course::instance($courseshown); if (has_any_capability(array('moodle/calendar:manageentries', 'moodle/calendar:manageownentries'), $context)) { $this->content->footer .= '<div class="newevent"><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...</div>'; } if ($courseshown == SITEID) { // 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. $filtercourse = calendar_get_default_courses(); } else { // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $this->page->course); } } list($courses, $group, $user) = calendar_set_filters($filtercourse); $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD; if (isset($CFG->calendar_lookahead)) { $defaultlookahead = intval($CFG->calendar_lookahead); } $lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead); $defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS; if (isset($CFG->calendar_maxevents)) { $defaultmaxevents = intval($CFG->calendar_maxevents); } $maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents); $events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents); if (!empty($this->instance)) { $this->content->text = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&'); } if (empty($this->content->text)) { $this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>'; } return $this->content; }
function get_content() { global $USER, $CFG, $SESSION; $cal_m = optional_param('cal_m', 0, PARAM_INT); $cal_y = optional_param('cal_y', 0, PARAM_INT); require_once $CFG->dirroot . '/calendar/lib.php'; if ($this->content !== NULL) { return $this->content; } // Reset the session variables calendar_session_vars($this->page->course); $this->content = new stdClass(); $this->content->text = ''; if (empty($this->instance)) { // Overrides: use no course at all $courseshown = false; $filtercourse = array(); $this->content->footer = ''; } else { $courseshown = $this->page->course->id; $this->content->footer = '<div class="gotocal"><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...</div>'; $context = get_context_instance(CONTEXT_COURSE, $courseshown); if (has_capability('moodle/calendar:manageentries', $context) || has_capability('moodle/calendar:manageownentries', $context)) { $this->content->footer .= '<div class="newevent"><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...</div>'; } if ($courseshown == SITEID) { // 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. $filtercourse = NULL; $groupeventsfrom = NULL; $SESSION->cal_courses_shown = calendar_get_default_courses(true); calendar_set_referring_course(0); } else { // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $this->page->course); $groupeventsfrom = array($courseshown => 1); } } // We 'll need this later calendar_set_referring_course($courseshown); // Be VERY careful with the format for default courses arguments! // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false); $events = calendar_get_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS)); if (!empty($this->instance)) { $this->content->text = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&'); } if (empty($this->content->text)) { $this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>'; } return $this->content; }
global $USER, $CFG, $SESSION; $cal_m = optional_param('cal_m', 0, PARAM_INT); $cal_y = optional_param('cal_y', 0, PARAM_INT); require_once $CFG->dirroot . '/calendar/lib.php'; $filtercourse = array(); if (empty($this->instance)) { // Overrides: use no course at all $courseshown = false; } else { $courseshown = $this->page->course->id; } // 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. $filtercourse = calendar_get_default_courses(); list($courses, $group, $user) = calendar_set_filters($filtercourse); $defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD; if (isset($CFG->calendar_lookahead)) { $defaultlookahead = intval($CFG->calendar_lookahead); } $lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead); $defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS; if (isset($CFG->calendar_maxevents)) { $defaultmaxevents = intval($CFG->calendar_maxevents); } $maxevents = 3; $events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents); $upcomingoutput = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&'); echo $upcomingoutput; ?>