]> git.mjollnir.org Git - moodle.git/commitdiff
Merged MDL-13727 Added a cpability check when showing blog entries
authormoodler <moodler>
Fri, 29 Feb 2008 06:52:26 +0000 (06:52 +0000)
committermoodler <moodler>
Fri, 29 Feb 2008 06:52:26 +0000 (06:52 +0000)
tag/index.php

index 7cd4f81ca6776d9bcccd9a811696eb88b257d449..dfdeb6022f26c60431d69237db884de0fa9dca3d 100644 (file)
@@ -99,35 +99,38 @@ if ($usercount > 0) {
 // I was not able to use get_items_tagged_with() because it automatically 
 // tries to join on 'blog' table, since the itemtype is 'blog'. However blogs
 // uses the post table so this would not really work.    - Yu 29/8/07
-if ($blogs = blog_fetch_entries('', 10, 0, 'site', '', $tag->id)) {
-
-    print_box_start('generalbox', 'tag-blogs');
-
-    print_heading(get_string('relatedblogs', 'tag'), '', 3);
-
-    echo '<ul id="tagblogentries">';
-    foreach ($blogs as $blog) {
-        if ($blog->publishstate == 'draft') {
-            $class = 'class="dimmed"';
-        } else {
-            $class = '';
+if (has_capability('moodle/blog:view', $systemcontext)) {  // You have to see blogs obviously
+
+    if ($blogs = blog_fetch_entries('', 10, 0, 'site', '', $tag->id)) {
+
+        print_box_start('generalbox', 'tag-blogs');
+
+        print_heading(get_string('relatedblogs', 'tag'), '', 3);
+
+        echo '<ul id="tagblogentries">';
+        foreach ($blogs as $blog) {
+            if ($blog->publishstate == 'draft') {
+                $class = 'class="dimmed"';
+            } else {
+                $class = '';
+            }
+            echo '<li '.$class.'>';
+            echo '<a '.$class.' href="'.$CFG->wwwroot.'/blog/index.php?postid='.$blog->id.'">';
+            echo format_string($blog->subject);
+            echo '</a>';
+            echo ' - '; 
+            echo '<a '.$class.' href="'.$CFG->wwwroot.'/user/view.php?id='.$blog->userid.'">';
+            echo fullname($blog);
+            echo '</a>';
+            echo ', '. userdate($blog->lastmodified);
+            echo '</li>';
         }
-        echo '<li '.$class.'>';
-        echo '<a '.$class.' href="'.$CFG->wwwroot.'/blog/index.php?postid='.$blog->id.'">';
-        echo format_string($blog->subject);
-        echo '</a>';
-        echo ' - '; 
-        echo '<a '.$class.' href="'.$CFG->wwwroot.'/user/view.php?id='.$blog->userid.'">';
-        echo fullname($blog);
-        echo '</a>';
-        echo ', '. userdate($blog->lastmodified);
-        echo '</li>';
-    }
-    echo '</ul>';
+        echo '</ul>';
 
-    echo '<p class="moreblogs"><a href="'.$CFG->wwwroot.'/blog/index.php?filtertype=site&filterselect=0&tagid='.$tag->id.'">'.get_string('seeallblogs', 'tag').'</a>...</p>';
+        echo '<p class="moreblogs"><a href="'.$CFG->wwwroot.'/blog/index.php?filtertype=site&filterselect=0&tagid='.$tag->id.'">'.get_string('seeallblogs', 'tag').'</a>...</p>';
 
-    print_box_end();
+        print_box_end();
+    }
 }