From 667e06ed113786430c5d7de6c3d7e32abc52623a Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 4 Jun 2007 21:46:12 +0000 Subject: [PATCH] MDL-10018 Discussion for all groups not sent when groups used to users without access to all groups; backported from HEAD --- mod/forum/lib.php | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 909856a6a6a..f7c31be4160 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -378,26 +378,17 @@ function forum_cron() { course_setup($course); // More environment // Make sure groups allow this user to see this email - $groupmode = false; - if (!empty($cm->id)) { - if ($groupmode = groupmode($course, $cm) and $discussion->groupid > 0) { // Groups are being used - if (! groups_group_exists($discussion->groupid)) { // Can't find group //TODO: - continue; // Be safe and don't send it to anyone - } + if ($discussion->groupid > 0 and $groupmode = groupmode($course, $cm)) { // Groups are being used + if (! groups_group_exists($discussion->groupid)) { // Can't find group + continue; // Be safe and don't send it to anyone + } + + if (!ismember($discussion->groupid) and !has_capability('moodle/site:accessallgroups', $modcontext)) { + // do not send posts from other groups when in SEPARATEGROUPS or VISIBLEGROUPS + continue; } } - if ($groupmode) { // Look for a reason not to send this email - if (!empty($discussion->groupid)) { - if (!ismember($discussion->groupid, $userto->id)) { - if (!has_capability('moodle/site:accessallgroups', $modcontext)) { - continue; - } - } - } - } - - // Make sure we're allowed to see it... if (!forum_user_can_see_post($forum, $discussion, $post)) { mtrace('user '.$userto->id. ' can not see '.$post->id);