Commit 39e36451 authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-60587 calendar: Switch to new helper in main view

parent 557d8528
......@@ -77,34 +77,20 @@ $url->param('time', $time);
$PAGE->set_url($url);
$course = get_course($courseid);
if ($courseid != SITEID && !empty($courseid)) {
// Course ID must be valid and existing.
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$courses = array($course->id => $course);
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else if (!empty($categoryid)) {
$PAGE->set_category_by_id($categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
} else {
$course = get_site();
$courses = calendar_get_default_courses();
if ($categoryid) {
$PAGE->set_category_by_id($categoryid);
} else {
$PAGE->set_context(context_system::instance());
}
if ($PAGE->context->contextlevel === CONTEXT_COURSECAT) {
// Restrict to categories, and their parents, and the courses that the user is enrolled in within those
// categories.
$categories = array_keys($PAGE->categories);
$courses = array_filter($courses, function($course) use ($categories) {
return array_search($course->category, $categories) !== false;
});
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
}
$PAGE->set_context(context_system::instance());
}
require_login($course, false);
$calendar = new calendar_information(0, 0, 0, $time);
$calendar->set_sources($course, $courses, $PAGE->category);
$calendar = calendar_information::create($time, $courseid, $categoryid);
$pagetitle = '';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment