Merge branch 'w04_MDL-31081_m23_forumindex' of git://github.com/skodak/moodle
[moodle.git] / mod / forum / lib.php
index 2df0ad2..f36d56e 100644 (file)
@@ -4543,9 +4543,10 @@ function forum_get_subscribed_forums($course) {
     $sql = "SELECT f.id
               FROM {forum} f
                    LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = ?)
-             WHERE f.forcesubscribe <> ".FORUM_DISALLOWSUBSCRIBE."
+             WHERE f.course = ?
+                   AND f.forcesubscribe <> ".FORUM_DISALLOWSUBSCRIBE."
                    AND (f.forcesubscribe = ".FORUM_FORCESUBSCRIBE." OR fs.id IS NOT NULL)";
-    if ($subscribed = $DB->get_records_sql($sql, array($USER->id))) {
+    if ($subscribed = $DB->get_records_sql($sql, array($USER->id, $course->id))) {
         foreach ($subscribed as $s) {
             $subscribed[$s->id] = $s->id;
         }