From 0dbe9025b580309f83128ed350f9b34e106d23ee Mon Sep 17 00:00:00 2001 From: Mathew Date: Mon, 10 Dec 2018 16:03:37 +0800 Subject: [PATCH] MDL-24951 mod_forum: Check user capability to know what message to show. If the user has the following capabilty: mod/forum:canposttomygroups then show them the more technical of the strings. Otherwise we use something a bit easier for them to ask their tutor or teacher about. --- mod/forum/lang/en/forum.php | 1 + mod/forum/lib.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index 825cf8b963f..0df3632670f 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -53,6 +53,7 @@ $string['bynameondate'] = 'by {$a->name} - {$a->date}'; $string['cannotadd'] = 'Could not add the discussion for this forum'; $string['cannotadddiscussion'] = 'Adding discussions to this forum requires group membership.'; $string['cannotadddiscussionall'] = 'You do not have permission to add a new discussion topic for all participants.'; +$string['cannotadddiscussiongroup'] = 'You are not able to create a discussion because you are not a member of any group.'; $string['cannotaddsubscriber'] = 'Could not add subscriber with id {$a} to this forum!'; $string['cannotaddteacherforumto'] = 'Could not add converted teacher forum instance to section 0 in the course'; $string['cannotcreatediscussion'] = 'Could not create new discussion'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index aaf91fb06d5..c198dd947d7 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -5620,7 +5620,11 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions = -1, $ } 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')); } -- 2.43.0