Skip to content

Commit

Permalink
MDL-49635 Navigation: Site pages consistent headers + navigation for …
Browse files Browse the repository at this point in the history
…preferences

Preferences pages cancel and continue buttons should lead back to preferences page.

Site pages should have consistent headers and breadcrumbs.

Hide the "Preferences" node in the navigation.

Part of MDL-45774
  • Loading branch information
Damyon Wiese authored and abgreeve committed Apr 10, 2015
1 parent f495187 commit 4e1f604
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 60 deletions.
2 changes: 1 addition & 1 deletion badges/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}

if ($mform->is_cancelled()) {
redirect($CFG->wwwroot . '/badges/mybadges.php');
redirect($CFG->wwwroot . '/user/preferences.php');
}

$strpreferences = get_string('preferences');
Expand Down
8 changes: 4 additions & 4 deletions badges/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@
}

if ($type == BADGE_TYPE_SITE) {
$title = get_string('sitebadges', 'badges');
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
$PAGE->set_heading($title);
$PAGE->set_heading($SITE->fullname);
$title = get_string('sitebadges', 'badges');
} else {
require_login($course);
$coursename = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
$title = $coursename . ': ' . get_string('coursebadges', 'badges');
$PAGE->set_context(context_course::instance($course->id));
$PAGE->set_pagelayout('incourse');
$PAGE->set_heading($title);
$PAGE->set_heading($coursename);
}

$PAGE->set_title($title);
Expand Down Expand Up @@ -103,4 +103,4 @@
echo $output->notification(get_string('nobadges', 'badges'));
}

echo $output->footer();
echo $output->footer();
44 changes: 16 additions & 28 deletions blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,10 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 1: No entry, mod, course or user params: all site entries to be shown (filtered by search and tag/tagid)
// Note: if action is set to 'add' or 'edit', we do this at the end.
if (empty($entryid) && empty($modid) && empty($courseid) && empty($userid) && !in_array($action, array('edit', 'add'))) {
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
$PAGE->set_title($site->fullname);
$PAGE->set_heading($site->fullname);
$headers['heading'] = get_string('siteblogheading', 'blog');
}

// Case 2: only entryid is requested, ignore all other filters. courseid is used to give more contextual information.
Expand Down Expand Up @@ -740,10 +739,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
// Case 4: No blog associations, no userid.

$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
$PAGE->set_title($site->fullname);
$PAGE->set_heading($site->fullname);
$headers['heading'] = get_string('siteblogheading', 'blog');
} else if (!empty($userid) && !empty($modid) && empty($entryid)) {
// Case 5: Blog entries associated with an activity by a specific user (courseid ignored).

Expand All @@ -769,15 +767,13 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
// Case 6: Blog entries associated with a course by a specific user.

$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('userid', $userid);
$blogurl->param('courseid', $courseid);

$PAGE->navbar->add($strblogentries, $blogurl);

$PAGE->set_title("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);

$a = new stdClass();
$a->user = fullname($user);
Expand All @@ -792,17 +788,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!empty($groupid) && empty($modid) && empty($entryid)) {
// Case 7: Blog entries by members of a group, associated with that group's course.

$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('courseid', $course->id);

$PAGE->navbar->add($strblogentries, $blogurl);
$blogurl->remove_params(array('courseid'));
$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);

$PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);

$a = new stdClass();
$a->group = $group->name;
Expand All @@ -814,17 +808,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!empty($groupid) && !empty($modid) && empty($entryid)) {
// Case 8: Blog entries by members of a group, associated with an activity in that course.

$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$headers['cm'] = $cm;
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);

$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);

$PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);

$a = new stdClass();
$a->group = $group->name;
Expand All @@ -837,13 +829,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
// Case 9: All blog entries associated with an activity.

$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$PAGE->set_cm($cm, $course);
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);
$headers['heading'] = get_string('blogentriesabout', 'blog', $cm->name);
$a = new stdClass();
$a->type = get_string('modulename', $cm->modname);
Expand All @@ -852,12 +842,10 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
// Case 10: All blog entries associated with a course.

$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$blogurl->param('courseid', $courseid);
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);
$a = new stdClass();
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesabout',
Expand Down
2 changes: 1 addition & 1 deletion blog/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

if ($mform->is_cancelled()) {
redirect($CFG->wwwroot . '/blog/index.php');
redirect($CFG->wwwroot . '/user/preferences.php');
}

$site = get_site();
Expand Down
2 changes: 1 addition & 1 deletion blog/tests/bloglib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function test_overrides() {
public function test_blog_get_headers_case_1() {
global $CFG, $PAGE, $OUTPUT;
$blogheaders = blog_get_headers();
$this->assertEquals($blogheaders['heading'], get_string('siteblog', 'blog', 'phpunit'));
$this->assertEquals($blogheaders['heading'], get_string('siteblogheading', 'blog'));
}

public function test_blog_get_headers_case_6() {
Expand Down
1 change: 1 addition & 0 deletions lang/en/badges.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
$string['numawardstat'] = 'This badge has been issued {$a} user(s).';
$string['overallcrit'] = 'of the selected criteria are complete.';
$string['potentialrecipients'] = 'Potential badge recipients';
$string['preferences'] = 'Badge preferences';
$string['recipients'] = 'Badge recipients';
$string['recipientdetails'] = 'Recipient details';
$string['recipientidentificationproblem'] = 'Cannot find a recipient of this badge among the existing users.';
Expand Down
7 changes: 5 additions & 2 deletions lang/en/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
$string['pagesize'] = 'Blog entries per page';
$string['permalink'] = 'Permalink';
$string['personalblogs'] = 'Users can only see their own blog';
$string['preferences'] = 'Preferences';
$string['preferences'] = 'Blog preferences';
$string['publishto'] = 'Publish to';
$string['publishto_help'] = 'There are 3 options:
Expand All @@ -143,7 +143,7 @@
$string['rssfeed'] = 'Blog RSS feed';
$string['searchterm'] = 'Search: {$a}';
$string['settingsupdatederror'] = 'An error has occurred, blog preference setting could not be updated';
$string['siteblog'] = 'Site blog: {$a}';
$string['siteblogheading'] = 'Site blog';
$string['siteblogdisable'] = 'Site blog is not enabled';
$string['siteblogs'] = 'All site users can see all blog entries';
$string['tagdatelastused'] = 'Date tag was last used';
Expand Down Expand Up @@ -182,3 +182,6 @@
$string['page-blog-edit'] = 'Blog editing pages';
$string['page-blog-index'] = 'Blog listing pages';
$string['page-blog-x'] = 'All blog pages';

// Deprecated since Moodle 2.9.
$string['siteblog'] = 'Site blog: {$a}';
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ lockingmeans,core_cache
lockmethod,core_cache
lockmethod_help,core_cache
personalrepositories,core_repository
siteblog,core_blog
7 changes: 3 additions & 4 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,7 @@ public function add_front_page_course_essentials(navigation_node $coursenode, st

// Tags
if (!empty($CFG->usetags) && isloggedin()) {
$coursenode->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
$node = $coursenode->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'), self::TYPE_SETTING, null, 'tags');
}

if (isloggedin()) {
Expand Down Expand Up @@ -4301,8 +4301,7 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr
$dashboard->add_node($usersetting);
} else {
$usersetting = $this->add(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
// Set to false when a link to preferences has been added to the my profile page. MDL-45900.
$usersetting->display = true;
$usersetting->display = false;
}
$usersetting->id = 'usersettings';

Expand Down Expand Up @@ -4452,7 +4451,7 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr
// Badges.
if ($currentuser && !empty($CFG->enablebadges)) {
$badges = $usersetting->add(get_string('badges'), null, navigation_node::TYPE_CONTAINER, null, 'badges');
$badges->add(get_string('preferences'), new moodle_url('/badges/preferences.php'), navigation_node::TYPE_SETTING);
$badges->add(get_string('preferences', 'badges'), new moodle_url('/badges/preferences.php'), navigation_node::TYPE_SETTING);
if (!empty($CFG->badges_allowexternalbackpack)) {
$badges->add(get_string('backpackdetails', 'badges'), new moodle_url('/badges/mybackpack.php'),
navigation_node::TYPE_SETTING);
Expand Down
4 changes: 2 additions & 2 deletions login/change_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// this redirect prevents security warning because https can not POST to http pages
if (empty($SESSION->wantsurl)
or stripos(str_replace('https://', 'http://', $SESSION->wantsurl), str_replace('https://', 'http://', $CFG->wwwroot.'/login/change_password.php')) === 0) {
$returnto = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id";
$returnto = "$CFG->wwwroot/user/preferences.php?userid=$USER->id&course=$id";
} else {
$returnto = $SESSION->wantsurl;
}
Expand Down Expand Up @@ -109,7 +109,7 @@
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');

if ($mform->is_cancelled()) {
redirect($CFG->wwwroot.'/user/view.php?id='.$USER->id.'&course='.$course->id);
redirect($CFG->wwwroot.'/user/preferences.php?userid='.$USER->id.'&course='.$course->id);
} else if ($data = $mform->get_data()) {

if (!$userauth->user_update_password($USER, $data->newpassword1)) {
Expand Down
11 changes: 4 additions & 7 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
} else {
$filtertype = 'course';
$filterselect = $course->id;
$user = $USER;
}

require_login($course);
Expand Down Expand Up @@ -107,15 +108,11 @@
}

$PAGE->set_pagelayout('incourse');
$PAGE->set_title($course->shortname . ': ' . $strnotes);
$PAGE->set_heading(fullname($USER));
$PAGE->set_title($course->fullname);
$PAGE->set_heading($course->fullname);

echo $OUTPUT->header();
if ($userid) {
echo $OUTPUT->heading(fullname($user).': '.$strnotes);
} else {
echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $coursecontext)).': '.$strnotes);
}
echo $OUTPUT->heading($strnotes);

$strsitenotes = get_string('sitenotes', 'notes');
$strcoursenotes = get_string('coursenotes', 'notes');
Expand Down
3 changes: 2 additions & 1 deletion tag/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
$PAGE->set_url('/tag/index.php', array('id' => $tag->id));
$PAGE->set_subpage($tag->id);
$PAGE->set_context($systemcontext);
$tagnode = $PAGE->navigation->find('tags', null);
$tagnode->make_active();
$PAGE->set_pagelayout('standard');
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');

Expand All @@ -71,7 +73,6 @@
$button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tag->id)));
}

$PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
$PAGE->navbar->add($tagname);
$PAGE->set_title($title);
$PAGE->set_heading($COURSE->fullname);
Expand Down
6 changes: 3 additions & 3 deletions tag/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
$manage_link = ' ';

$PAGE->set_title(get_string('tags', 'tag'));
$PAGE->set_heading($SITE->fullname.': '.$PAGE->title);
$PAGE->set_heading($SITE->fullname);
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('searchtags', 'tag'), 2);

if ( has_capability('moodle/tag:manage',$systemcontext) ) {
echo '<div class="managelink"><a href="'. $CFG->wwwroot .'/tag/manage.php">' . get_string('managetags', 'tag') . '</a></div>' ;
}

echo $OUTPUT->heading(get_string('searchtags', 'tag'), 2);

tag_print_search_box();

if(!empty($query)) {
Expand Down
4 changes: 2 additions & 2 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
$a->oldemail = $usernew->email = $user->email;

$emailchangedhtml = $OUTPUT->box(get_string('auth_changingemailaddress', 'auth', $a), 'generalbox', 'notice');
$emailchangedhtml .= $OUTPUT->continue_button("$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id");
$emailchangedhtml .= $OUTPUT->continue_button("$CFG->wwwroot/user/preferences.php?userid=$user->id&amp;course=$course->id");
$emailchanged = true;
}
}
Expand Down Expand Up @@ -284,7 +284,7 @@
}

if (!$emailchanged || !$CFG->emailchangeconfirmation) {
redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id");
redirect("$CFG->wwwroot/user/preferences.php?id=$user->id&course=$course->id");
}
}

Expand Down
2 changes: 1 addition & 1 deletion user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
// Somebody double clicked when editing admin user during install.
redirect("$CFG->wwwroot/$CFG->admin/");
} else {
redirect("$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id");
redirect("$CFG->wwwroot/user/preferences.php?userid=$USER->id&course=$course->id");
}
} else {
\core\session\manager::gc(); // Remove stale sessions.
Expand Down
1 change: 1 addition & 0 deletions user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
$PAGE->set_other_editing_capability('moodle/course:manageactivities');

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('participants'));

echo '<div class="userlist">';

Expand Down
4 changes: 1 addition & 3 deletions user/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
$usernode = $PAGE->navigation->find('users', null);
$usernode->make_inactive();

$PAGE->set_title(get_string('preferences'));
$PAGE->set_heading(get_string('preferences'));

$settings = $PAGE->settingsnav->find('usercurrentsettings', null);
$settings->make_active();
}
Expand All @@ -85,5 +82,6 @@
$preferences = new preferences_groups($groups);

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('preferences'));
echo $OUTPUT->render($preferences);
echo $OUTPUT->footer();

0 comments on commit 4e1f604

Please sign in to comment.