MDL-50576 mod_forum: prevent posting to a non-member group
Thanks Fred for the help on the issue.
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
45f3b5302d
commit
7824b2f6d9
@@ -171,15 +171,20 @@ class mod_forum_post_form extends moodleform {
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user