diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php
index edc8ba2b2e0..10fe299b1e8 100755
--- a/blocks/blog_menu/block_blog_menu.php
+++ b/blocks/blog_menu/block_blog_menu.php
@@ -54,41 +54,69 @@ class block_blog_menu extends block_base {
//if ( blog_isLoggedIn() && !isguest() ) {
$courseviewlink = '';
$addentrylink = '';
-
$coursearg = '';
- if((isloggedin() && !isguest()) && isset($course) && isset($course->id) && $course->id !=0 && $course->id!=SITEID && $CFG->bloglevel >= BLOG_COURSE_LEVEL) {
- $coursearg = '&courseid='. $course->id;
+
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+
+ if (isset($course) && isset($course->id)
+ && $course->id != 0 && $course->id != SITEID) {
+
+ $incoursecontext = true;
+ $curcontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ } else {
+ $incoursecontext = false;
+ $curcontext = $sitecontext;
+ }
+
+ $canviewblogs = has_capability('moodle/blog:view', $curcontext);
+
+
+ if ( (isloggedin() && !isguest()) && $incoursecontext
+ && $CFG->bloglevel >= BLOG_COURSE_LEVEL && $canviewblogs) {
+
+ $coursearg = '&courseid='.$course->id;
// a course is specified
$courseviewlink = '';
$courseviewlink .= get_string('viewcourseentries', 'blog') .'
';
}
-
+
$blogmodon = false;
- if ((isloggedin() && !isguest()) && (isadmin() || !$blogmodon || ($blogmodon && $coursearg != '')) && $CFG->bloglevel >= BLOG_USER_LEVEL) {
+ if ( (isloggedin() && !isguest())
+ && (!$blogmodon || ($blogmodon && $coursearg != ''))
+ && $CFG->bloglevel >= BLOG_USER_LEVEL ) {
- // show Add entry link - user is not admin, moderation is off, or moderation is on and the user is viewing the block within the context of a course
- $addentrylink = ''. get_string('addnewentry', 'blog') .'
';
-
- // show View my entries link
- $addentrylink .= '';
- $addentrylink .= get_string('viewmyentries', 'blog') .'
';
- // show link to manage blog prefs
- $addentrylink .= ''. get_string('blogpreferences', 'blog') .'
';
-
- $output = $addentrylink;
- $output .= $courseviewlink;
+ // show Add entry link - moderation is off, or moderation is on and the user is viewing the block within the context of a course
+ if (has_capability('moodle/blog:create', $curcontext)) {
+ $addentrylink = ''.
+ get_string('addnewentry', 'blog') .'
';
+ }
+ // show View my entries link
+ $addentrylink .= ''.get_string('viewmyentries', 'blog').
+ '
';
+
+ // show link to manage blog prefs
+ $addentrylink .= ''.
+ get_string('blogpreferences', 'blog').'
';
+ $output = $addentrylink;
+ $output .= $courseviewlink;
}
// show View site entries link
- if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
+ if ($CFG->bloglevel >= BLOG_SITE_LEVEL && $canviewblogs) {
$output .= '';
- $output .= get_string('viewsiteentries', 'blog') .'
';
+ $output .= get_string('viewsiteentries', 'blog').'
';
}
- if (isloggedin() && (!isguest())) {
+ if (isloggedin() && !isguest()
+ && (has_capability('moodle/blog:manageofficialtags', $sitecontext)
+ || has_capability('moodle/blog:managepersonaltags', $curcontext))) {
+
$output .= link_to_popup_window("/blog/tags.php",'popup',get_string('tagmanagement'), 400, 500, 'Popup window', 'none', true);
}
@@ -103,4 +131,5 @@ class block_blog_menu extends block_base {
return $this->content;
}
}
-?>
+
+?>
\ No newline at end of file