dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/calendar/lib.php'); $categoryid = optional_param('category', null, PARAM_INT); $courseid = optional_param('course', SITEID, PARAM_INT); $view = optional_param('view', 'upcoming', PARAM_ALPHA); $time = optional_param('time', 0, PARAM_INT); $lookahead = optional_param('lookahead', null, PARAM_INT); $url = new moodle_url('/calendar/view.php'); if (empty($time)) { $time = time(); } if ($courseid != SITEID) { $url->param('course', $courseid); } if ($categoryid) { $url->param('categoryid', $categoryid); } if ($view !== 'upcoming') { $time = usergetmidnight($time); $url->param('view', $view); } $url->param('time', $time); $PAGE->set_url($url); $course = get_course($courseid); if ($courseid != SITEID && !empty($courseid)) { navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id))); } else if (!empty($categoryid)) { core_course_category::get($categoryid); // Check that category exists and can be accessed. $PAGE->set_category_by_id($categoryid); navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid))); } else { $PAGE->set_context(context_system::instance()); } require_login($course, false); $calendar = calendar_information::create($time, $courseid, $categoryid); $pagetitle = ''; $strcalendar = get_string('calendar', 'calendar'); switch($view) { case 'day': $PAGE->navbar->add(userdate($time, get_string('strftimedate'))); $pagetitle = get_string('dayviewtitle', 'calendar', userdate($time, get_string('strftimedaydate'))); break; case 'month': $PAGE->navbar->add(userdate($time, get_string('strftimemonthyear'))); $pagetitle = get_string('detailedmonthviewtitle', 'calendar', userdate($time, get_string('strftimemonthyear'))); break; case 'upcoming': $pagetitle = get_string('upcomingevents', 'calendar'); break; } // Print title and header $PAGE->set_pagelayout('standard'); $PAGE->set_title("$course->shortname: $strcalendar: $pagetitle"); $PAGE->set_heading($COURSE->fullname); $renderer = $PAGE->get_renderer('core_calendar'); $calendar->add_sidecalendar_blocks($renderer, true, $view); echo $OUTPUT->header(); echo $renderer->start_layout(); echo html_writer::start_tag('div', array('class'=>'heightcontainer')); echo $OUTPUT->heading(get_string('calendar', 'calendar')); list($data, $template) = calendar_get_view($calendar, $view, true, false, $lookahead); echo $renderer->render_from_template($template, $data); echo html_writer::end_tag('div'); list($data, $template) = calendar_get_footer_options($calendar); echo $renderer->render_from_template($template, $data); echo $renderer->complete_layout(); echo $OUTPUT->footer();