diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 57c5d66b0f4..8c3c0454371 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -104,8 +104,8 @@ } //check if user can view this post - if (!forum_user_can_view_post($parent)){ - error ('you can not view this post'); + if (!forum_user_can_view_post($parent,$course)){ + error('You do not have permissions to view this post'); } if (! $post = forum_get_post_full($parent)) { diff --git a/mod/forum/lib.php b/mod/forum/lib.php index c2326ab3e24..be776cc0029 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2658,7 +2658,7 @@ function forum_user_can_post($forum, $user=NULL) { } //checks to see if a user can view a particular post -function forum_user_can_view_post($post, $user=NULL){ +function forum_user_can_view_post($post, $course, $user=NULL){ global $CFG, $USER; @@ -2684,7 +2684,9 @@ function forum_user_can_view_post($post, $user=NULL){ } //first of all, the user must be in this course - if (!(isstudent($forumcourse->course) or isteacher($forumcourse->course))){ + if (!(isstudent($forumcourse->course) or + isteacher($forumcourse->course) or + (isguest() && $course->guest) )){ return false; }