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.
This commit is contained in:
Mathew
2018-12-24 09:13:36 +08:00
parent 79d87ad683
commit 2f56e8a287
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -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';
+5 -1
View File
@@ -5528,7 +5528,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'));
}