MDL-49635 Navigation: Site pages consistent headers + navigation for 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
This commit is contained in:
Damyon Wiese 2015-03-24 15:10:51 +08:00 committed by Adrian Greeve
parent f495187da7
commit 4e1f60478a
17 changed files with 49 additions and 60 deletions

View File

@ -47,7 +47,7 @@ if (!$mform->is_cancelled() && $data = $mform->get_data()) {
}
if ($mform->is_cancelled()) {
redirect($CFG->wwwroot . '/badges/mybadges.php');
redirect($CFG->wwwroot . '/user/preferences.php');
}
$strpreferences = get_string('preferences');

View File

@ -62,17 +62,17 @@ if ($course = $DB->get_record('course', array('id' => $courseid))) {
}
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);
@ -103,4 +103,4 @@ if ($totalcount) {
echo $output->notification(get_string('nobadges', 'badges'));
}
echo $output->footer();
echo $output->footer();

View File

@ -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.
@ -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).
@ -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);
@ -792,8 +788,6 @@ 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);
@ -801,8 +795,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$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;
@ -814,8 +808,6 @@ 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);
@ -823,8 +815,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$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;
@ -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);
@ -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',

View File

@ -81,7 +81,7 @@ if (!$mform->is_cancelled() && $data = $mform->get_data()) {
}
if ($mform->is_cancelled()) {
redirect($CFG->wwwroot . '/blog/index.php');
redirect($CFG->wwwroot . '/user/preferences.php');
}
$site = get_site();

View File

@ -129,7 +129,7 @@ class core_bloglib_testcase extends advanced_testcase {
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() {

View File

@ -330,6 +330,7 @@ $string['numawards'] = 'This badge has been issued to <a href="{$a->link}">{$a->
$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.';

View File

@ -121,7 +121,7 @@ $string['numberoftags'] = 'Number of tags to display';
$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:
@ -143,7 +143,7 @@ $string['retrievedfrom'] = 'Retrieved from';
$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';
@ -182,3 +182,6 @@ $string['wrongpostid'] = 'Wrong blog post id';
$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}';

View File

@ -11,3 +11,4 @@ lockingmeans,core_cache
lockmethod,core_cache
lockmethod_help,core_cache
personalrepositories,core_repository
siteblog,core_blog

View File

@ -2640,7 +2640,7 @@ class global_navigation extends navigation_node {
// 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()) {
@ -4301,8 +4301,7 @@ class settings_navigation extends navigation_node {
$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';
@ -4452,7 +4451,7 @@ class settings_navigation extends navigation_node {
// 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);

View File

@ -45,7 +45,7 @@ if ($return) {
// 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;
}
@ -109,7 +109,7 @@ $navlinks = array();
$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.'&amp;course='.$course->id);
redirect($CFG->wwwroot.'/user/preferences.php?userid='.$USER->id.'&amp;course='.$course->id);
} else if ($data = $mform->get_data()) {
if (!$userauth->user_update_password($USER, $data->newpassword1)) {

View File

@ -72,6 +72,7 @@ if ($userid) {
} else {
$filtertype = 'course';
$filterselect = $course->id;
$user = $USER;
}
require_login($course);
@ -107,15 +108,11 @@ if ($userid) {
}
$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');

View File

@ -56,6 +56,8 @@ if (empty($tag)) {
$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');
@ -71,7 +73,6 @@ if ($PAGE->user_allowed_editing() ) {
$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);

View File

@ -54,15 +54,15 @@ $systemcontext = context_system::instance();
$manage_link = '&nbsp;';
$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)) {

View File

@ -194,7 +194,7 @@ if ($usernew = $userform->get_data()) {
$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;
}
}
@ -284,7 +284,7 @@ if ($usernew = $userform->get_data()) {
}
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");
}
}

View File

@ -293,7 +293,7 @@ if ($usernew = $userform->get_data()) {
// 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.

View File

@ -155,6 +155,7 @@ $PAGE->add_body_class('path-user'); // So we can style it in
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('participants'));
echo '<div class="userlist">';

View File

@ -62,9 +62,6 @@ if (!$currentuser) {
$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();
}
@ -85,5 +82,6 @@ if (!empty($orphans)) {
$preferences = new preferences_groups($groups);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('preferences'));
echo $OUTPUT->render($preferences);
echo $OUTPUT->footer();