Merge branch 'MDL-24951-master' of git://github.com/Chocolate-lightning/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 8 Jan 2019 05:46:11 +0000 (13:46 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 8 Jan 2019 05:46:11 +0000 (13:46 +0800)
1  2 
mod/forum/lib.php

diff --combined mod/forum/lib.php
@@@ -657,12 -657,6 +657,12 @@@ function forum_cron() 
                      }
                  }
  
 +                $coursecontext = context_course::instance($course->id);
 +                if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext, $userto->id)) {
 +                    // The course is hidden and the user does not have access to it.
 +                    continue;
 +                }
 +
                  // Don't send email if the forum is Q&A and the user has not posted.
                  // Initial topics are still mailed.
                  if ($forum->type == 'qanda' && !forum_get_user_posted_time($discussion->id, $userto->id) && $pid != $discussion->firstpost) {
@@@ -5626,7 -5620,11 +5626,11 @@@ function forum_print_latest_discussions
      } else if ($groupmode and !has_capability('moodle/site:accessallgroups', $context)) {
          // inform users why they can not post new discussion
          if (!$currentgroup) {
-             echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
+             if (!has_capability('mod/forum:canposttomygroups', $context)) {
+                 echo $OUTPUT->notification(get_string('cannotadddiscussiongroup', 'forum'));
+             } else {
+                 echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
+             }
          } else if (!groups_is_member($currentgroup)) {
              echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum'));
          }