MDL-71952 calendar: Make breadcrumb consistent within calendar pages

This commit is contained in:
Shamim Rezaie
2021-07-21 19:50:51 +10:00
parent 1464843a25
commit 7a529cc858
4 changed files with 80 additions and 40 deletions

View File

@@ -55,6 +55,7 @@ if (empty($CFG->enablecalendarexport)) {
} }
$courseid = optional_param('course', SITEID, PARAM_INT); $courseid = optional_param('course', SITEID, PARAM_INT);
$categoryid = optional_param('category', null, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA); $action = optional_param('action', '', PARAM_ALPHA);
$day = optional_param('cal_d', 0, PARAM_INT); $day = optional_param('cal_d', 0, PARAM_INT);
$mon = optional_param('cal_m', 0, PARAM_INT); $mon = optional_param('cal_m', 0, PARAM_INT);
@@ -76,32 +77,44 @@ if (!empty($day) && !empty($mon) && !empty($year)) {
$time = time(); $time = time();
} }
$url = new moodle_url('/calendar/export.php', array('time' => $time));
$managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php');
if ($courseid != SITEID && !empty($courseid)) { if ($courseid != SITEID && !empty($courseid)) {
// Course ID must be valid and existing. // Course ID must be valid and existing.
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$courses = array($course->id => $course); $courses = array($course->id => $course);
$issite = false; $url->param('course', $course->id);
$managesubscriptionsurl->param('course', $course->id);
navigation_node::override_active_url(new moodle_url('/course/view.php', ['id' => $course->id]));
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $course->id])
);
} else { } else {
$course = get_site(); $course = get_site();
$courses = calendar_get_default_courses(); $courses = calendar_get_default_courses();
$issite = true;
if (!empty($categoryid)) {
$managesubscriptionsurl->param('category', $categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid]));
$PAGE->set_category_by_id($categoryid);
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid])
);
} else {
navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month']));
}
} }
require_login($course, false); require_login($course, false);
$url = new moodle_url('/calendar/export.php', array('time' => $time));
$managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php');
if ($action !== '') { if ($action !== '') {
$url->param('action', $action); $url->param('action', $action);
} }
if ($course !== NULL) {
$url->param('course', $course->id);
if ($course->id != SITEID) {
$managesubscriptionsurl->param('course', $course->id);
}
}
$PAGE->set_url($url); $PAGE->set_url($url);
$calendar = new calendar_information(0, 0, 0, $time); $calendar = new calendar_information(0, 0, 0, $time);
@@ -109,15 +122,10 @@ $calendar->set_sources($course, $courses);
$pagetitle = get_string('export', 'calendar'); $pagetitle = get_string('export', 'calendar');
// Print title and header
if ($issite) {
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
}
$link = new moodle_url(CALENDAR_URL.'view.php', array('view'=>'upcoming', 'course'=>$calendar->courseid));
$PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, 0, 0, 0, $time));
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl); $PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl);
$PAGE->navbar->add($pagetitle); $PAGE->navbar->add($pagetitle);
// Print title and header.
$PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle); $PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('standard'); $PAGE->set_pagelayout('standard');

View File

@@ -32,8 +32,6 @@ $category = optional_param('category', 0, PARAM_INT);
$data = []; $data = [];
$pageurl = new moodle_url('/calendar/import.php'); $pageurl = new moodle_url('/calendar/import.php');
$managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php'); $managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php');
$calendarurl = new moodle_url('/calendar/view.php', ['view' => 'month']);
navigation_node::override_active_url($calendarurl);
if ($courseid != SITEID && !empty($courseid)) { if ($courseid != SITEID && !empty($courseid)) {
$course = get_course($courseid); $course = get_course($courseid);
@@ -41,14 +39,43 @@ if ($courseid != SITEID && !empty($courseid)) {
$data['courseid'] = $course->id; $data['courseid'] = $course->id;
$pageurl->param('course', $course->id); $pageurl->param('course', $course->id);
$managesubscriptionsurl->param('course', $course->id); $managesubscriptionsurl->param('course', $course->id);
navigation_node::override_active_url(new moodle_url('/course/view.php', ['id' => $course->id]));
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $course->id])
);
} else if (!empty($category)) {
$course = get_site();
$pageurl->param('category', $category);
$managesubscriptionsurl->param('category', $category);
$data['category'] = $category;
$data['eventtype'] = 'category';
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $category]));
$PAGE->set_category_by_id($category);
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $category])
);
} else { } else {
$course = get_site(); $course = get_site();
navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month']));
} }
require_login($course, false); require_login($course, false);
if (!calendar_user_can_add_event($course)) { if (!calendar_user_can_add_event($course)) {
throw new \moodle_exception('errorcannotimport', 'calendar'); throw new \moodle_exception('errorcannotimport', 'calendar');
} }
$heading = get_string('importcalendar', 'calendar');
$pagetitle = $course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $heading;
$PAGE->set_title($pagetitle);
$PAGE->set_heading($heading);
$PAGE->set_url($pageurl);
$PAGE->set_pagelayout('admin');
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl);
$PAGE->navbar->add($heading);
// Populate the 'group' select box based on the given 'groupcourseid', if necessary. // Populate the 'group' select box based on the given 'groupcourseid', if necessary.
$groups = []; $groups = [];
if (!empty($groupcourseid)) { if (!empty($groupcourseid)) {
@@ -63,22 +90,6 @@ if (!empty($groupcourseid)) {
$data['eventtype'] = 'group'; $data['eventtype'] = 'group';
$pageurl->param('groupcourseid', $groupcourseid); $pageurl->param('groupcourseid', $groupcourseid);
} }
if (!empty($category)) {
$pageurl->param('category', $category);
$managesubscriptionsurl->param('category', $category);
$data['category'] = $category;
$data['eventtype'] = 'category';
}
$heading = get_string('importcalendar', 'calendar');
$pagetitle = $course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $heading;
$PAGE->set_title($pagetitle);
$PAGE->set_heading($heading);
$PAGE->set_url($pageurl);
$PAGE->set_pagelayout('admin');
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl);
$PAGE->navbar->add($heading);
$customdata = [ $customdata = [
'courseid' => $course->id, 'courseid' => $course->id,

View File

@@ -40,14 +40,25 @@ $action = optional_param('action', '', PARAM_INT);
$url = new moodle_url('/calendar/managesubscriptions.php'); $url = new moodle_url('/calendar/managesubscriptions.php');
if ($courseid != SITEID && !empty($courseid)) { if ($courseid != SITEID && !empty($courseid)) {
$url->param('course', $courseid); $url->param('course', $courseid);
} navigation_node::override_active_url(new moodle_url('/course/view.php', ['id' => $courseid]));
if ($categoryid) { $PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $courseid])
);
} else if ($categoryid) {
$url->param('categoryid', $categoryid); $url->param('categoryid', $categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', ['categoryid' => $categoryid]));
$PAGE->set_category_by_id($categoryid);
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid])
);
} else {
navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month']));
} }
navigation_node::override_active_url(new moodle_url('/calendar/view.php', array('view' => 'month')));
$PAGE->set_url($url); $PAGE->set_url($url);
$PAGE->set_pagelayout('admin'); $PAGE->set_pagelayout('admin');
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'));
if ($courseid != SITEID && !empty($courseid)) { if ($courseid != SITEID && !empty($courseid)) {
// Course ID must be valid and existing. // Course ID must be valid and existing.
@@ -63,6 +74,8 @@ if (!calendar_user_can_add_event($course)) {
print_error('errorcannotimport', 'calendar'); print_error('errorcannotimport', 'calendar');
} }
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'));
$importresults = ''; $importresults = '';
if (!empty($subscriptionid)) { if (!empty($subscriptionid)) {

View File

@@ -96,10 +96,18 @@ $course = get_course($courseid);
if ($iscoursecalendar && !empty($courseid)) { if ($iscoursecalendar && !empty($courseid)) {
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id))); navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $course->id])
);
} else if (!empty($categoryid)) { } else if (!empty($categoryid)) {
core_course_category::get($categoryid); // Check that category exists and can be accessed. core_course_category::get($categoryid); // Check that category exists and can be accessed.
$PAGE->set_category_by_id($categoryid); $PAGE->set_category_by_id($categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid))); navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
$PAGE->navbar->add(
get_string('calendar', 'calendar'),
new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid])
);
} else { } else {
$PAGE->set_context(context_system::instance()); $PAGE->set_context(context_system::instance());
} }