From 4e1f60478a377c7767a33108768b58486577f6c7 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 24 Mar 2015 15:10:51 +0800 Subject: [PATCH] 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 --- badges/preferences.php | 2 +- badges/view.php | 8 +++---- blog/lib.php | 44 ++++++++++++++----------------------- blog/preferences.php | 2 +- blog/tests/bloglib_test.php | 2 +- lang/en/badges.php | 1 + lang/en/blog.php | 7 ++++-- lang/en/deprecated.txt | 1 + lib/navigationlib.php | 7 +++--- login/change_password.php | 4 ++-- notes/index.php | 11 ++++------ tag/index.php | 3 ++- tag/search.php | 6 ++--- user/edit.php | 4 ++-- user/editadvanced.php | 2 +- user/index.php | 1 + user/preferences.php | 4 +--- 17 files changed, 49 insertions(+), 60 deletions(-) diff --git a/badges/preferences.php b/badges/preferences.php index a35337d6b96e6..aa650342817d5 100644 --- a/badges/preferences.php +++ b/badges/preferences.php @@ -47,7 +47,7 @@ } if ($mform->is_cancelled()) { - redirect($CFG->wwwroot . '/badges/mybadges.php'); + redirect($CFG->wwwroot . '/user/preferences.php'); } $strpreferences = get_string('preferences'); diff --git a/badges/view.php b/badges/view.php index 80a3e25554a9e..7548faed54836 100644 --- a/badges/view.php +++ b/badges/view.php @@ -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); @@ -103,4 +103,4 @@ echo $output->notification(get_string('nobadges', 'badges')); } -echo $output->footer(); \ No newline at end of file +echo $output->footer(); diff --git a/blog/lib.php b/blog/lib.php index b9cbae57c8dc8..cb2c969364130 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -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', diff --git a/blog/preferences.php b/blog/preferences.php index e0608d01781b1..9c42bec8a1351 100644 --- a/blog/preferences.php +++ b/blog/preferences.php @@ -81,7 +81,7 @@ } if ($mform->is_cancelled()) { - redirect($CFG->wwwroot . '/blog/index.php'); + redirect($CFG->wwwroot . '/user/preferences.php'); } $site = get_site(); diff --git a/blog/tests/bloglib_test.php b/blog/tests/bloglib_test.php index 06b1f07d2f29d..a0589c26194c8 100644 --- a/blog/tests/bloglib_test.php +++ b/blog/tests/bloglib_test.php @@ -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() { diff --git a/lang/en/badges.php b/lang/en/badges.php index 7169f37398ab4..337395ec985b1 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -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.'; diff --git a/lang/en/blog.php b/lang/en/blog.php index 10193b2da6374..5eb6f4e02ee40 100644 --- a/lang/en/blog.php +++ b/lang/en/blog.php @@ -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: @@ -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'; @@ -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}'; diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 96f2c6931c734..6b603f3625499 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -11,3 +11,4 @@ lockingmeans,core_cache lockmethod,core_cache lockmethod_help,core_cache personalrepositories,core_repository +siteblog,core_blog diff --git a/lib/navigationlib.php b/lib/navigationlib.php index e57e7d540aef2..9354ead9afbfa 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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()) { @@ -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'; @@ -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); diff --git a/login/change_password.php b/login/change_password.php index d36475e4c6b70..5efce2c81163e 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -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; } @@ -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)) { diff --git a/notes/index.php b/notes/index.php index 54480c44d8093..0542c972d7db7 100644 --- a/notes/index.php +++ b/notes/index.php @@ -72,6 +72,7 @@ } else { $filtertype = 'course'; $filterselect = $course->id; + $user = $USER; } require_login($course); @@ -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'); diff --git a/tag/index.php b/tag/index.php index da4064d36ebaf..9636e1149fb6e 100644 --- a/tag/index.php +++ b/tag/index.php @@ -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'); @@ -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); diff --git a/tag/search.php b/tag/search.php index b399bac2d1279..20cb75f8d0621 100644 --- a/tag/search.php +++ b/tag/search.php @@ -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 '' ; } -echo $OUTPUT->heading(get_string('searchtags', 'tag'), 2); - tag_print_search_box(); if(!empty($query)) { diff --git a/user/edit.php b/user/edit.php index 3966c1f960fe7..792539d2bb8b7 100644 --- a/user/edit.php +++ b/user/edit.php @@ -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&course=$course->id"); + $emailchangedhtml .= $OUTPUT->continue_button("$CFG->wwwroot/user/preferences.php?userid=$user->id&course=$course->id"); $emailchanged = true; } } @@ -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"); } } diff --git a/user/editadvanced.php b/user/editadvanced.php index e2eeaca9c9458..976ccd5a64b9d 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -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. diff --git a/user/index.php b/user/index.php index fb253ff4453dd..c62f25982c8d6 100644 --- a/user/index.php +++ b/user/index.php @@ -155,6 +155,7 @@ $PAGE->set_other_editing_capability('moodle/course:manageactivities'); echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('participants')); echo '
'; diff --git a/user/preferences.php b/user/preferences.php index 3dc8aa6425cc2..f3f461cfe25e8 100644 --- a/user/preferences.php +++ b/user/preferences.php @@ -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(); } @@ -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();