fix for MDL-8908, draft blogs should not be visible

This commit is contained in:
toyomoyo
2007-03-15 06:14:08 +00:00
parent 25a37d70ff
commit e07f4ac436
2 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -75,7 +75,7 @@ switch ($filtertype) {
$courseid = $course->id;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_login($course->id);
if (!has_capability('moodle/blog:view', $sitecontext)) {
if (!has_capability('moodle/blog:view', $coursecontext)) {
error('You do not have the required permissions to view blogs in this course');
}
break;
@@ -115,7 +115,7 @@ switch ($filtertype) {
if ($USER->id == $filterselect) {
if (!has_capability('moodle/blog:create', $sitecontext)
and !has_capability('moodle/blog:view', $sitecontext)) {
error('You do not have your own a blog, sorry.');
error('You do not have your own blog, sorry.');
}
} else {
$personalcontext = get_context_instance(CONTEXT_USER, $filterselect);
+8 -2
View File
@@ -327,10 +327,16 @@
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
return true; // can manage all posts
}
// coming for 1 post, make sure it's not a draft
if ($blogEntry and $blogEntry->publishstate == 'draft') {
return false; // can not view draft of others
}
// coming for 1 post, make sure user is logged in, if not a public blog
if ($blogEntry && $blogEntry->publishstate != 'public' && !isloggedin()) {
return false;
}
switch ($CFG->bloglevel) {
case BLOG_GLOBAL_LEVEL:
@@ -411,7 +417,7 @@
if ($post = get_record('post', 'id', $postid)) {
if (blog_user_can_view_user_post($post->userid)) {
if (blog_user_can_view_user_post($post->userid, $post)) {
if ($user = get_record('user', 'id', $post->userid)) {
$post->email = $user->email;