diff --git a/calendar/export.php b/calendar/export.php index de7e46d8b3909..8275e1e501cc3 100644 --- a/calendar/export.php +++ b/calendar/export.php @@ -106,7 +106,7 @@ new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid]) ); } else { - navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month'])); + $PAGE->navbar->add(get_string('calendar', 'calendar'), new moodle_url('/calendar/view.php', ['view' => 'month'])); } } require_login($course, false); diff --git a/calendar/import.php b/calendar/import.php index 7943529401c23..e4186405eeda2 100644 --- a/calendar/import.php +++ b/calendar/import.php @@ -33,15 +33,18 @@ $pageurl = new moodle_url('/calendar/import.php'); $managesubscriptionsurl = new moodle_url('/calendar/managesubscriptions.php'); -if ($courseid != SITEID && !empty($courseid)) { +$headingstr = $calendarstr = get_string('calendar', 'calendar'); + +if (!empty($courseid) && $courseid != SITEID) { $course = get_course($courseid); $data['eventtype'] = 'course'; $data['courseid'] = $course->id; $pageurl->param('course', $course->id); $managesubscriptionsurl->param('course', $course->id); + $headingstr .= ": {$course->shortname}"; navigation_node::override_active_url(new moodle_url('/course/view.php', ['id' => $course->id])); $PAGE->navbar->add( - get_string('calendar', 'calendar'), + $calendarstr, new moodle_url('/calendar/view.php', ['view' => 'month', 'course' => $course->id]) ); } else if (!empty($category)) { @@ -53,12 +56,16 @@ 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'), + $calendarstr, new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $category]) ); } else { $course = get_site(); - navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month'])); + $PAGE->navbar->add($calendarstr, new moodle_url('/calendar/view.php', ['view' => 'month'])); +} + +if (!empty($groupcourseid)) { + $pageurl->param('groupcourseid', $groupcourseid); } require_login($course, false); @@ -67,15 +74,15 @@ } $heading = get_string('importcalendar', 'calendar'); -$pagetitle = $course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $heading; +$pagetitle = $course->shortname . ': ' . $calendarstr . ': ' . $heading; $PAGE->set_secondary_navigation(false); $PAGE->set_title($pagetitle); -$PAGE->set_heading($heading); +$PAGE->set_heading($headingstr); $PAGE->set_url($pageurl); $PAGE->set_pagelayout('admin'); $PAGE->navbar->add(get_string('managesubscriptions', 'calendar'), $managesubscriptionsurl); -$PAGE->navbar->add($heading); +$PAGE->navbar->add($heading, $pageurl); // Populate the 'group' select box based on the given 'groupcourseid', if necessary. $groups = []; @@ -89,25 +96,13 @@ } $data['groupcourseid'] = $groupcourseid; $data['eventtype'] = 'group'; - $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'); -$headingstr = get_string('calendar', 'core_calendar'); -$headingstr = ($courseid != SITEID && !empty($courseid)) ? "{$headingstr}: {$COURSE->shortname}" : $headingstr; -$pagetitle = $course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $heading; - -$PAGE->set_title($pagetitle); -$PAGE->set_heading($headingstr); -$PAGE->set_url($pageurl); -$PAGE->set_pagelayout('admin'); -$PAGE->navbar->add($heading, $pageurl); $renderer = $PAGE->get_renderer('core_calendar'); $customdata = [ diff --git a/calendar/managesubscriptions.php b/calendar/managesubscriptions.php index 4cf8854fa97f4..2564916ac1b45 100644 --- a/calendar/managesubscriptions.php +++ b/calendar/managesubscriptions.php @@ -48,7 +48,7 @@ new moodle_url('/calendar/view.php', ['view' => 'month', 'category' => $categoryid]) ); } else { - navigation_node::override_active_url(new moodle_url('/calendar/view.php', ['view' => 'month'])); + $PAGE->navbar->add(get_string('calendar', 'calendar'), new moodle_url('/calendar/view.php', ['view' => 'month'])); } $PAGE->set_url($url); diff --git a/calendar/tests/behat/calendar_import.feature b/calendar/tests/behat/calendar_import.feature index a9279eb54f2a4..47f0b1e767630 100644 --- a/calendar/tests/behat/calendar_import.feature +++ b/calendar/tests/behat/calendar_import.feature @@ -19,7 +19,12 @@ Feature: Import and edit calendar events Given I log in as "teacher1" And I view the calendar for "1" "2016" And I click on "Import or export calendars" "link" + And "Calendar" "link" should exist in the ".breadcrumb" "css_element" + And "Import or export calendars" "text" should exist in the ".breadcrumb" "css_element" And I press "Import calendar" + And "Calendar" "link" should exist in the ".breadcrumb" "css_element" + And "Import or export calendars" "link" should exist in the ".breadcrumb" "css_element" + And "Import calendar" "text" should exist in the ".breadcrumb" "css_element" And I set the following fields to these values: | Calendar name | Test Import | | Import from | Calendar file (.ics) | diff --git a/calendar/tests/behat/export.feature b/calendar/tests/behat/export.feature index 2e738a06b03b6..87e7ab81ce7e8 100644 --- a/calendar/tests/behat/export.feature +++ b/calendar/tests/behat/export.feature @@ -19,7 +19,12 @@ Feature: Export calendar events Scenario: Viewing calendar export options Given I follow "Full calendar" When I click on "Import or export calendars" "link" + And "Calendar" "link" should exist in the ".breadcrumb" "css_element" + And "Import or export calendars" "text" should exist in the ".breadcrumb" "css_element" And I click on "Export calendar" "button" + And "Calendar" "link" should exist in the ".breadcrumb" "css_element" + And "Import or export calendars" "link" should exist in the ".breadcrumb" "css_element" + And "Export calendar" "text" should exist in the ".breadcrumb" "css_element" Then I should see "All events" And I should see "Events related to courses" And I should see "Events related to groups"