Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

FIxes for showing user discussions from groups

  • Loading branch information...
commit 64784287842b6632f43ac75db16c063f598827d7 1 parent 660381d
moodler authored

Showing 1 changed file with 30 additions and 4 deletions. Show diff stats Hide diff stats

  1. +30 4 mod/forum/lib.php
34 mod/forum/lib.php
@@ -919,7 +919,7 @@ function forum_get_user_discussions($courseid, $userid, $groupid=0) {
919 919 $groupselect = "";
920 920 }
921 921
922   - return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture,
  922 + return get_records_sql("SELECT p.*, d.groupid, u.firstname, u.lastname, u.email, u.picture,
923 923 f.type as forumtype, f.name as forumname, f.id as forumid
924 924 FROM {$CFG->prefix}forum_discussions d,
925 925 {$CFG->prefix}forum_posts p,
@@ -1903,12 +1903,22 @@ function forum_print_user_discussions($courseid, $userid, $groupid=0) {
1903 1903
1904 1904 $visible = array();
1905 1905
  1906 + $course = get_record("course", "id", $courseid);
  1907 +
  1908 + $currentgroup = get_current_group($courseid);
  1909 + $isteacheredit = isteacheredit($courseid);
  1910 +
1906 1911 if ($discussions = forum_get_user_discussions($courseid, $userid, $groupid=0)) {
1907   - $user = get_record("user", "id", $userid);
1908   - echo "<hr />";
  1912 +
  1913 + $user = get_record("user", "id", $userid);
1909 1914 $fullname = fullname($user, isteacher($courseid));
1910   - print_heading( get_string("discussionsstartedbyrecent", "forum", $fullname) );
  1915 +
1911 1916 $replies = forum_count_discussion_replies();
  1917 +
  1918 + echo "<hr />";
  1919 +
  1920 + print_heading( get_string("discussionsstartedbyrecent", "forum", $fullname) );
  1921 +
1912 1922 foreach ($discussions as $discussion) {
1913 1923 $countdiscussions++;
1914 1924 if ($countdiscussions > $maxdiscussions) {
@@ -1926,6 +1936,22 @@ function forum_print_user_discussions($courseid, $userid, $groupid=0) {
1926 1936 if(!$visible[$discussion->forumid] && !isteacheredit($courseid, $USER->id)) {
1927 1937 continue;
1928 1938 }
  1939 +
  1940 + /// Check whether this is belongs to a discussion in a group that
  1941 + /// should NOT be accessible to the current user
  1942 +
  1943 + if (!$isteacheredit and $discussion->groupid != -1) { /// Editing teachers or open discussions
  1944 + if (!isset($cm[$discussion->forum])) {
  1945 + $cm[$discussion->forum] = get_coursemodule_from_instance("forum", $discussion->forum, $courseid);
  1946 + $groupmode[$discussion->forum] = groupmode($course, $cm[$discussion->forum]);
  1947 + }
  1948 + if ($groupmode[$discussion->forum] == SEPARATEGROUPS) {
  1949 + if ($currentgroup != $discussion->groupid) {
  1950 + continue;
  1951 + }
  1952 + }
  1953 + }
  1954 +
1929 1955 if (!empty($replies[$discussion->discussion])) {
1930 1956 $discussion->replies = $replies[$discussion->discussion]->replies;
1931 1957 } else {

0 comments on commit 6478428

Please sign in to comment.
Something went wrong with that request. Please try again.