From 298c9da5f1c808811ab1e49abf117aaa57e64ce3 Mon Sep 17 00:00:00 2001 From: Dave Cooper Date: Wed, 22 Apr 2015 14:05:06 +0800 Subject: [PATCH 1/5] MDL-49845 navigation: Fix breadcrumbs for links in my profile. --- lib/navigationlib.php | 6 +++--- notes/lib.php | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 7e56c18cb88..e5f3897c0f4 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -4226,7 +4226,7 @@ class settings_navigation extends navigation_node { // Add nodes for forum posts and discussions if the user can view either or both // There are no capability checks here as the content of the page is based // purely on the forums the current user has access too. - $forumtab = $dashboard->add(get_string('forumposts', 'forum')); + $forumtab = $profilenode->add(get_string('forumposts', 'forum')); $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs), null, 'myposts'); $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode' => 'discussions'))), null, 'mydiscussions'); @@ -4244,7 +4244,7 @@ class settings_navigation extends navigation_node { } if (count($options) > 0) { - $blogs = $dashboard->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER); + $blogs = $profilenode->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER); foreach ($options as $type => $option) { if ($type == "rss") { $blogs->add($option['string'], $option['link'], self::TYPE_SETTING, null, null, @@ -4284,7 +4284,7 @@ class settings_navigation extends navigation_node { if ($coursecontext->instanceid != SITEID) { $url->param('course', $coursecontext->instanceid); } - $dashboard->add(get_string('notes', 'notes'), $url); + $profilenode->add(get_string('notes', 'notes'), $url); } // Show the grades node. diff --git a/notes/lib.php b/notes/lib.php index 3c455513ca4..ef83ceefdd7 100644 --- a/notes/lib.php +++ b/notes/lib.php @@ -379,6 +379,8 @@ function note_view($context, $userid) { * @return bool */ function core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { + global $USER; + $url = new moodle_url("/notes/index.php", array('user' => $user->id)); $title = get_string('notes', 'core_notes'); if (empty($course)) { @@ -387,7 +389,9 @@ function core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, // No cap, nothing to do. return false; } - $url->param('course', 0); + if ($user->id != $USER->id) { + $url->param('course', 0); + } } else { if (!has_capability('moodle/notes:view', context_course::instance($course->id))) { // No cap, nothing to do. From c1f97c777f19c31c5879dde646c64dcdae1cb263 Mon Sep 17 00:00:00 2001 From: Dave Cooper Date: Thu, 23 Apr 2015 18:39:41 +0800 Subject: [PATCH 2/5] MDL-49845 blog: Fixed navigation logic for blog --- blog/index.php | 28 ++++++++++++++++++++++++++-- blog/lib.php | 4 +--- lib/navigationlib.php | 12 +++++------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/blog/index.php b/blog/index.php index 35bab0c9897..d17abfa5236 100644 --- a/blog/index.php +++ b/blog/index.php @@ -63,8 +63,10 @@ if ($entryid and !isset($userid)) { $userid = $entry->userid; } -if (isset($userid)) { +if (isset($userid) && !isset($courseid)) { $context = context_user::instance($userid); +} else if (isset($courseid) && $courseid != SITEID) { + $context = context_course::instance($courseid); } else { $context = context_system::instance(); } @@ -241,8 +243,30 @@ if ($CFG->enablerssfeeds) { blog_rss_add_http_header($rsscontext, $rsstitle, $filtertype, $thingid, $tagid); } } -if (isset($userid)) { + +$usernode = $PAGE->navigation->find('user'.$userid, null); +if ($usernode && $courseid != SITEID) { + $courseblogsnode = $PAGE->navigation->find('courseblogs', null); + if ($courseblogsnode) { + $courseblogsnode->remove(); + } + $blogurl = new moodle_url($PAGE->url); + $blognode = $usernode->add(get_string('blogscourse', 'blog'), $blogurl); + $blognode->make_active(); +} + +if ($courseid != SITEID) { + $PAGE->set_heading($course->fullname); + echo $OUTPUT->header(); + if (!empty($user)) { + $headerinfo = array('heading' => fullname($user), 'user' => $user); + echo $OUTPUT->context_header($headerinfo, 2); + } +} else if (isset($userid)) { $PAGE->set_heading(fullname($user)); + echo $OUTPUT->header(); +} else if ($courseid == SITEID) { + echo $OUTPUT->header(); } echo $OUTPUT->header(); diff --git a/blog/lib.php b/blog/lib.php index db2d3d3b76f..50eaa357bf5 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -770,8 +770,6 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu $blogurl->param('userid', $userid); $blogurl->param('courseid', $courseid); - $PAGE->navbar->add($strblogentries, $blogurl); - $PAGE->set_title($course->fullname); $PAGE->set_heading($course->fullname); @@ -1043,4 +1041,4 @@ function core_blog_myprofile_navigation(core_user\output\myprofile\tree $tree, $ $blognode = new core_user\output\myprofile\node('miscellaneous', 'blogs', $title, null, $url); $tree->add_node($blognode); return true; -} \ No newline at end of file +} diff --git a/lib/navigationlib.php b/lib/navigationlib.php index e5f3897c0f4..96e6eab4b44 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2553,14 +2553,12 @@ class global_navigation extends navigation_node { if (($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser()))) and has_capability('moodle/blog:view', context_system::instance())) { $blogsurls = new moodle_url('/blog/index.php'); - if ($course->id == $SITE->id) { - $blogsurls->param('courseid', 0); - } else if ($currentgroup = groups_get_course_group($course, true)) { + if ($currentgroup = groups_get_course_group($course, true)) { $blogsurls->param('groupid', $currentgroup); } else { $blogsurls->param('courseid', $course->id); } - $participants->add(get_string('blogscourse','blog'), $blogsurls->out()); + $participants->add(get_string('blogscourse', 'blog'), $blogsurls->out(), self::TYPE_SETTING, null, 'courseblogs'); } } if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) { @@ -2611,16 +2609,16 @@ class global_navigation extends navigation_node { $coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants'); } - $filterselect = 0; - // Blogs if (!empty($CFG->enableblogs) and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser()))) and has_capability('moodle/blog:view', context_system::instance())) { - $blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect)); + $blogsurls = new moodle_url('/blog/index.php'); $coursenode->add(get_string('blogssite', 'blog'), $blogsurls->out(), self::TYPE_SYSTEM, null, 'siteblog'); } + $filterselect = 0; + //Badges if (!empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $this->page->context)) { $url = new moodle_url($CFG->wwwroot . '/badges/view.php', array('type' => 1)); From 7193ea2cd2ccdacaf2110ce821e37831fa43ea4d Mon Sep 17 00:00:00 2001 From: Dave Cooper Date: Tue, 28 Apr 2015 14:02:49 +0800 Subject: [PATCH 3/5] MDL-49845 profile: changed 'My preferences' display logic --- lang/en/deprecated.txt | 1 + lang/en/moodle.php | 3 ++- lib/myprofilelib.php | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 558e5b736df..c0c321783fb 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -23,3 +23,4 @@ mypreferences,core_grades myprofile,core myprofilemyblogs,core_blog viewallmyentries,core_blog +userspreferences,core_moodle diff --git a/lang/en/moodle.php b/lang/en/moodle.php index ddca3401072..3344306a540 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1934,7 +1934,6 @@ $string['usernameoremail'] = 'Enter either username or email address'; $string['usernotconfirmed'] = 'Could not confirm {$a}'; $string['userpic'] = 'User picture'; $string['users'] = 'Users'; -$string['userspreferences'] = 'User {$a}\'s preferences'; $string['userselectorautoselectunique'] = 'If only one user matches the search, select them automatically'; $string['userselectorpreserveselected'] = 'Keep selected users, even if they no longer match the search'; $string['userselectorsearchanywhere'] = 'Match the search text anywhere in the displayed fields'; @@ -2042,3 +2041,5 @@ $string['yourself'] = 'yourself'; $string['yourteacher'] = 'your {$a}'; $string['yourwordforx'] = 'Your word for \'{$a}\''; $string['zippingbackup'] = 'Zipping backup'; +// Deprecated since Moodle 2.9 +$string['userspreferences'] = 'User {$a}\'s preferences'; diff --git a/lib/myprofilelib.php b/lib/myprofilelib.php index bc80dc159ac..5f4a39594fd 100644 --- a/lib/myprofilelib.php +++ b/lib/myprofilelib.php @@ -100,9 +100,9 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, } // Preference page. Only visible by administrators. - if (is_siteadmin()) { + if (!$iscurrentuser && is_siteadmin()) { $url = new moodle_url('/user/preferences.php', array('userid' => $user->id)); - $title = $iscurrentuser ? get_string('preferences') : get_string('userspreferences', 'moodle', fullname($user)); + $title = get_string('preferences', 'moodle'); $node = new core_user\output\myprofile\node('administration', 'preferences', $title, null, $url); $tree->add_node($node); } From a7e98a6900b07425db6ec7ef30bab19f1bb0019b Mon Sep 17 00:00:00 2001 From: Dave Cooper Date: Wed, 29 Apr 2015 10:05:56 +0800 Subject: [PATCH 4/5] MDL-49845 blog: Changed headers for blog index --- blog/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/blog/index.php b/blog/index.php index d17abfa5236..1f5217a37b5 100644 --- a/blog/index.php +++ b/blog/index.php @@ -269,7 +269,6 @@ if ($courseid != SITEID) { echo $OUTPUT->header(); } -echo $OUTPUT->header(); echo $OUTPUT->heading($blogheaders['heading'], 2); $bloglisting = new blog_listing($blogheaders['filters']); From 327e68e69db6713be85faec8cb8b71e43ec5a77b Mon Sep 17 00:00:00 2001 From: Dave Cooper Date: Wed, 29 Apr 2015 12:11:56 +0800 Subject: [PATCH 5/5] MDL-49845 notes: Changed headers for notes index --- lib/navigationlib.php | 2 +- notes/index.php | 29 +++++++++++++++++++++++++++-- notes/lib.php | 5 ----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 96e6eab4b44..564418674a6 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2562,7 +2562,7 @@ class global_navigation extends navigation_node { } } if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) { - $participants->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$course->id))); + $participants->add(get_string('notes', 'notes'), new moodle_url('/notes/index.php', array('filtertype' => 'course', 'filterselect' => $course->id)), self::TYPE_SETTING, null, 'currentcoursenotes'); } } else if (count($this->extendforuser) > 0 || $this->page->course->id == $course->id) { $participants = $coursenode->add(get_string('participants'), null, self::TYPE_CONTAINER, get_string('participants'), 'participants'); diff --git a/notes/index.php b/notes/index.php index 0542c972d7d..6ba0099c6ef 100644 --- a/notes/index.php +++ b/notes/index.php @@ -91,13 +91,28 @@ $systemcontext = context_system::instance(); note_view($coursecontext, $userid); $strnotes = get_string('notes', 'notes'); -if ($userid) { +if ($userid && $course->id == SITEID) { $PAGE->set_context(context_user::instance($user->id)); $PAGE->navigation->extend_for_user($user); // If we are looking at our own notes, then change focus to 'my notes'. if ($userid == $USER->id) { $notenode = $PAGE->navigation->find('notes', null)->make_inactive(); } + + $notesurl = new moodle_url('/notes/index.php', array('user' => $userid)); + $PAGE->navbar->add(get_string('notes', 'notes'), $notesurl); +} else if ($course->id != SITEID) { + $notenode = $PAGE->navigation->find('currentcoursenotes', null)->make_inactive(); + $participantsurl = new moodle_url('/user/view.php', array('id' => $userid, 'course' => $course->id)); + $currentcoursenode = $PAGE->navigation->find('currentcourse', null); + $participantsnode = $currentcoursenode->find('participants', null); + $usernode = $participantsnode->add(fullname($user), $participantsurl); + $usernode->make_active(); + + $notesurl = new moodle_url('/notes/index.php', array('user' => $userid, 'course' => $courseid)); + $PAGE->navbar->add(get_string('notes', 'notes'), $notesurl); + + $PAGE->set_context(context_course::instance($courseid)); } else { $link = null; if (has_capability('moodle/course:viewparticipants', $coursecontext) @@ -109,9 +124,19 @@ if ($userid) { $PAGE->set_pagelayout('incourse'); $PAGE->set_title($course->fullname); -$PAGE->set_heading($course->fullname); +if ($course->id == SITEID) { + $PAGE->set_heading(fullname($user)); +} else { + $PAGE->set_heading($course->fullname); +} echo $OUTPUT->header(); + +if ($course->id != SITEID) { + $headerinfo = array('heading' => fullname($user), 'user' => $user); + echo $OUTPUT->context_header($headerinfo, 2); +} + echo $OUTPUT->heading($strnotes); $strsitenotes = get_string('sitenotes', 'notes'); diff --git a/notes/lib.php b/notes/lib.php index ef83ceefdd7..7b86046f436 100644 --- a/notes/lib.php +++ b/notes/lib.php @@ -379,8 +379,6 @@ function note_view($context, $userid) { * @return bool */ function core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { - global $USER; - $url = new moodle_url("/notes/index.php", array('user' => $user->id)); $title = get_string('notes', 'core_notes'); if (empty($course)) { @@ -389,9 +387,6 @@ function core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, // No cap, nothing to do. return false; } - if ($user->id != $USER->id) { - $url->param('course', 0); - } } else { if (!has_capability('moodle/notes:view', context_course::instance($course->id))) { // No cap, nothing to do.