Navigation - Blog and Tags links are now shown/hidden correctly according to settings

This commit is contained in:
Martin Dougiamas 2010-05-01 14:33:07 +00:00
parent 610b5fde69
commit 593270c629
2 changed files with 17 additions and 9 deletions

View File

@ -269,13 +269,13 @@ function blog_get_context_url($context=null) {
}
/**
* This function checks that blogs are enabled, and that the user is logged in an
* is not the guest user.
* This function checks that blogs are enabled, and that the user can see blogs at all
* @return bool
*/
function blog_is_enabled_for_user() {
global $CFG;
return (!empty($CFG->bloglevel) && $CFG->bloglevel <= BLOG_GLOBAL_LEVEL && isloggedin() && !isguestuser());
//return (!empty($CFG->bloglevel) && $CFG->bloglevel <= BLOG_GLOBAL_LEVEL && isloggedin() && !isguestuser());
return (!empty($CFG->bloglevel) && (isloggedin() || ($CFG->bloglevel == BLOG_GLOBAL_LEVEL)));
}
/**
@ -914,4 +914,4 @@ function blog_get_associated_count($courseid, $cmid=null) {
$context = get_context_instance(CONTEXT_MODULE, $cmid);
}
return $DB->count_records('blog_association', array('contextid' => $context->id));
}
}

View File

@ -1492,7 +1492,6 @@ class global_navigation extends navigation_node {
//Participants
if (has_capability('moodle/course:viewparticipants', $this->page->context)) {
require_once($CFG->dirroot.'/blog/lib.php');
$coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants');
}
@ -1505,14 +1504,23 @@ class global_navigation extends navigation_node {
$filterselect = $currentgroup;
}
$filterselect = clean_param($filterselect, PARAM_INT);
if ($CFG->bloglevel >= 3) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
$coursenode->add(get_string('blogs','blog'), $blogsurls->out());
// Blogs
if (has_capability('moodle/blog:view', $this->page->context)) {
require_once($CFG->dirroot.'/blog/lib.php');
if (blog_is_enabled_for_user()) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
$coursenode->add(get_string('blogs','blog'), $blogsurls->out());
}
}
// Notes
if (!empty($CFG->enablenotes) && (has_capability('moodle/notes:manage', $this->page->context) || has_capability('moodle/notes:view', $this->page->context))) {
$coursenode->add(get_string('notes','notes'), new moodle_url('/notes/index.php', array('filtertype'=>'course', 'filterselect'=>$filterselect)));
}
if (!empty($CFG->usetags)) {
// Tags
if (!empty($CFG->usetags) && isloggedin()) {
$coursenode->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
}