mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-49845 blog: Fixed navigation logic for blog
This commit is contained in:
parent
298c9da5f1
commit
c1f97c777f
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user