Moodle

accessallgroups does not work for reply forum posts in separate groups

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.2
  • Fix Version/s: 1.8.3, 1.9
  • Component/s: Forum, Groups, Roles / Access
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_18_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

An editing trainer in the course with capability "moodle/site:accessallgroups" set to ALLOWED is not able to reply to a forum post when the group mode of the forum is set to separate groups. Error "nopostdiscussion"

Looking at the code in mod/forum/post.php, line 146 (Moodle version 1.8.2):

$modcontext = get_context_instance(CONTEXT_MODULE, $forum->id);

This record is not in the mdl_context table since this table does not contain the forum ID in the instanceid field but the forums course module ID; so the correct call should be:

$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id); - which returns the course module object of the forum
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);

You will find this in post.php of Moodle 1.9, i.e. in Moodle 1.9 the code seems to be correct.

Activity

Hide
Gisela Hillenbrand added a comment -

Gisela Hillenbrand: Code for 1.8.3 is also correct: lines 145ff in post.php:

if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { error("Incorrect cm"); }

$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);

Show
Gisela Hillenbrand added a comment - Gisela Hillenbrand: Code for 1.8.3 is also correct: lines 145ff in post.php: if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { error("Incorrect cm"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
Hide
Helen Foster added a comment -

Hi Gisela,

Thanks for your bug report. It sounds as though the bug can be resolved as fixed for 1.8.3 and 1.9. Is this correct?

Show
Helen Foster added a comment - Hi Gisela, Thanks for your bug report. It sounds as though the bug can be resolved as fixed for 1.8.3 and 1.9. Is this correct?
Hide
Gisela Hillenbrand added a comment -

Hi Helen,

yes the bug can be resolved for 1.8.3 and 1.9.
The fix for 1.8.2 is in the bug description:

mod/forum/post.php, line 146 (Moodle version 1.8.2):

old code (bug): $modcontext = get_context_instance(CONTEXT_MODULE, $forum->id);

new code (bug fix):
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id); - which returns the course module object of the forum
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);

Show
Gisela Hillenbrand added a comment - Hi Helen, yes the bug can be resolved for 1.8.3 and 1.9. The fix for 1.8.2 is in the bug description: mod/forum/post.php, line 146 (Moodle version 1.8.2): old code (bug): $modcontext = get_context_instance(CONTEXT_MODULE, $forum->id); new code (bug fix): $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id); - which returns the course module object of the forum $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
Hide
Helen Foster added a comment -

Thanks Gisela and whoever fixed things in 1.8.3 and 1.9

Show
Helen Foster added a comment - Thanks Gisela and whoever fixed things in 1.8.3 and 1.9

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: