# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/mod/forum/lib.php
--- moodle/mod/forum/lib.php Base (1.904)
+++ moodle/mod/forum/lib.php Locally Modified (Based On 1.904)
@@ -1793,9 +1793,7 @@
 /**
  * An array of forum objects that the user is allowed to read/search through.
  *
- * @global object
- * @global object
- * @global object
+ * @global moodle_database $DB
  * @param int $userid
  * @param int $courseid if 0, we look for forums throughout the whole site.
  * @return array of forum objects, or false if no matches
@@ -1815,10 +1813,8 @@
     if ($courseid) {
         $courses = $DB->get_records('course', array('id' => $courseid));
     } else {
-        // If no course is specified, then the user can see SITE + his courses.
-        $courses1 = $DB->get_records('course', array('id' => SITEID));
-        $courses2 = enrol_get_users_courses($userid, true);
-        $courses = array_merge($courses1, $courses2);
+        // If no course is specified then all courses the user can view
+        $courses = get_user_capability_course('moodle/course:view', $userid);
     }
     if (!$courses) {
         return array();
