]> git.mjollnir.org Git - moodle.git/commitdiff
merged, fixed an infinite loop
authortoyomoyo <toyomoyo>
Fri, 20 Oct 2006 05:09:37 +0000 (05:09 +0000)
committertoyomoyo <toyomoyo>
Fri, 20 Oct 2006 05:09:37 +0000 (05:09 +0000)
mod/forum/lib.php

index 1eb4979e902b1620635c631b612f16ae7b9e9d9e..d73c72f6bbf2a529f0f9e37ba4e84592e1ebbc97 100644 (file)
@@ -3766,13 +3766,23 @@ function forum_remove_user_subscriptions($userid, $context) {
     switch ($context->contextlevel) {
 
         case CONTEXT_SYSTEM:   // For the whole site
-             if ($courses = get_records('course')) {
-                 foreach ($courses as $course) {
-                     $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
-                     forum_remove_user_subscriptions($userid, $subcontext);
-                 }
-             }
-             break;
+            if ($courses = get_records('course')) {
+                foreach ($courses as $course) {
+                    if ($course->id == SITEID) {
+                        if ($course = get_records('course', 'id', $context->instanceid)) {
+                            if ($forums = get_all_instances_in_course('forum', $course)) {
+                                foreach ($forums as $forum) {
+                                    forum_unsubscribe($userid, $forum->id);
+                                }  
+                            }
+                        }
+                        continue;  
+                    }
+                    $subcontext = get_context_instance(CONTEXT_COURSE, $course->id);
+                    forum_remove_user_subscriptions($userid, $subcontext);
+                }
+            }
+            break;
 
         case CONTEXT_COURSECAT:   // For a whole category
              if ($courses = get_records('course', 'category', $context->instanceid)) {