Merge branch 'w04_MDL-31081_m23_forumindex' of git://github.com/skodak/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 23 Jan 2012 20:17:54 +0000 (21:17 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 23 Jan 2012 20:17:54 +0000 (21:17 +0100)
1  2 
mod/forum/lib.php

diff --combined mod/forum/lib.php
@@@ -4543,9 -4543,10 +4543,10 @@@ function forum_get_subscribed_forums($c
      $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;
          }
@@@ -7897,7 -7898,7 +7898,7 @@@ function forum_get_forums_user_posted_i
   *               ->posts: An array containing the posts to show for this request.
   */
  function forum_get_posts_by_user($user, array $courses, $musthaveaccess = false, $discussionsonly = false, $limitfrom = 0, $limitnum = 50) {
 -    global $DB, $USER;
 +    global $DB, $USER, $CFG;
  
      $return = new stdClass;
      $return->totalcount = 0;    // The total number of posts that the current user is able to view