]> git.mjollnir.org Git - moodle.git/commitdiff
This is a ridiculously complicated solution to showing only
authormoodler <moodler>
Mon, 12 Jan 2004 17:20:10 +0000 (17:20 +0000)
committermoodler <moodler>
Mon, 12 Jan 2004 17:20:10 +0000 (17:20 +0000)
those posts in recent activity that one should see.

It's temporary.

I have a more efficient solution in mind but it will take
at least one new database field - I'll tackle it later.

mod/forum/lib.php

index ffbce94b207282c0e486f28dcd73a614cc0b7409..5ca2238e953ddf1f774abb3fd3e58bfcc8ce5427 100644 (file)
@@ -394,13 +394,14 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
         $tempmod->course = $log->course;
         $tempmod->id = $post->forum;
         //Obtain the visible property from the instance
-        $modvisible = instance_is_visible($log->module,$tempmod);
+        $modvisible = instance_is_visible($log->module, $tempmod);
   
         //Only if the mod is visible
         if ($modvisible) {
             if ($post) {
+                /// Check whether this is for teachers only
                 $teacheronly = "";
-                if ($forum = get_record("forum", "id", $post->forum) ) {
+                if ($forum = get_record("forum", "id", $post->forum)) {
                     if ($forum->type == "teacher") {
                         if ($isteacher) {
                             $teacheronly = "class=\"teacheronly\"";
@@ -409,6 +410,26 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
                         }
                     }
                 }
+                /// Check whether this is belongs to a discussion in a group that 
+                /// should not be accessible to the current user
+                /// TEMPORARY:  This algorithm is ridiculously cumbersome ... 
+                ///             There MUST be a better way of doing this...
+                if ($cm = get_coursemodule_from_instance("forum", $post->forum, $course->id)) {
+                    if (groupmode($course, $cm) == SEPARATEGROUPS) {
+                        if (!isteacheredit($course->id)) {
+                            if ($discussion = get_record("forum_discussions", "id", $post->discussion)) {
+                                if ($firstpost = get_record("forum_posts", "id", $discussion->firstpost)) {
+                                    if ($group = user_group($course->id, $firstpost->userid)) {
+                                        if (mygroupid($course->id) != $group->id) {
+                                            continue;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
                 if (! $heading) {
                     print_headline(get_string("newforumposts", "forum").":");
                     $heading = true;