Skip to content
Permalink
Browse files

MDL-50576 mod_forum: prevent posting to a non-member group

Thanks Fred for the help on the issue.
  • Loading branch information...
lameze authored and stronk7 committed Jul 28, 2015
1 parent 45f3b53 commit 7824b2f6d91963db676a098bfde460642bbd7a4a
Showing with 6 additions and 1 deletion.
  1. +6 −1 mod/forum/classes/post_form.php
@@ -171,15 +171,20 @@ function definition() {
// Check whether the user has access to all groups in this forum from the accessallgroups cap.
if ($groupmode == VISIBLEGROUPS || has_capability('moodle/site:accessallgroups', $modulecontext)) {
// Only allow posting to all groups if the user has access to all groups.
$groupinfo = array('0' => get_string('allparticipants'));
$groupdata[] = (object) array('id' => 0, 'name' => get_string('allparticipants'));
$groupcount++;
}
$contextcheck = has_capability('mod/forum:movediscussions', $modulecontext) && empty($post->parent) && $groupcount > 1;
if ($contextcheck) {
foreach ($groupdata as $grouptemp) {
if (!forum_user_can_post_discussion($forum, $grouptemp->id, -1, $cm, $modcontext)) {
continue;
}
$groupinfo[$grouptemp->id] = $grouptemp->name;
}
}
if (count($groupinfo) > 1) {
$mform->addElement('select','groupinfo', get_string('group'), $groupinfo);
$mform->setDefault('groupinfo', $post->groupid);
$mform->setType('groupinfo', PARAM_INT);

0 comments on commit 7824b2f

Please sign in to comment.
You can’t perform that action at this time.