Skip to content

Commit

Permalink
MDL-74595 calendar: consistent breadcrumbs navigating site calendar.
Browse files Browse the repository at this point in the history
Take #3, see also 7a529cc and 81b0d05.
  • Loading branch information
paulholden committed Jun 24, 2022
1 parent ceb4158 commit 1dba715
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion calendar/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 14 additions & 19 deletions calendar/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand All @@ -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 = [];
Expand All @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion calendar/managesubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions calendar/tests/behat/calendar_import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
5 changes: 5 additions & 0 deletions calendar/tests/behat/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1dba715

Please sign in to comment.