Moodle

issue with forums subscriptions and moodle/course:view

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7, 1.8, 1.9
  • Fix Version/s: None
  • Component/s: Forum, Roles / Access
  • Labels:
    None
  • Affected Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

Description

When a Role is given the "moodle/course:view" permission, they also receive all forum posts from forced subscription forums. (except for administrators role)

We have a role that is like the "inspector" role mentioned in MoodleDocs - we have a range of staff that require full "browse" access to all the courses - but they don't want to get all the e-mails from all the courses where the forums are set to forced subscribe!

Issue Links

Activity

Hide
Dan Marsden added a comment -

problem is with the call to depreclib get_course_users($course->id) in mod\forum\lib.php in forum_subscribed_users()
here:

if (forum_is_forcesubscribed($forum->id)) {
$results = get_course_users($course->id); // Otherwise get everyone in the course

my "guess" is that something like this should be called instead:
if (forum_is_forcesubscribed($forum->id)) {
$context = get_context_instance(CONTEXT_MODULE, $forum->coursemodule);
$results = get_users_by_capability($context, 'mod/forum:viewdiscussion','u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop,
u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums', 'u.firstname ASC', '','',$groupid, '', false);

Although - It does seem weird that a call to Get_users_by_capability doesn't return all users that have that capability! - it doesn't come back with any admins or other hidden assignments to the course.

Show
Dan Marsden added a comment - problem is with the call to depreclib get_course_users($course->id) in mod\forum\lib.php in forum_subscribed_users() here: if (forum_is_forcesubscribed($forum->id)) { $results = get_course_users($course->id); // Otherwise get everyone in the course my "guess" is that something like this should be called instead: if (forum_is_forcesubscribed($forum->id)) { $context = get_context_instance(CONTEXT_MODULE, $forum->coursemodule); $results = get_users_by_capability($context, 'mod/forum:viewdiscussion','u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums', 'u.firstname ASC', '','',$groupid, '', false); Although - It does seem weird that a call to Get_users_by_capability doesn't return all users that have that capability! - it doesn't come back with any admins or other hidden assignments to the course.
Hide
Petr Škoda (skodak) added a comment -

Solution could be IMHO a new capability that is given to real course users only - course/forum:reciveforcedsubscription ..

Show
Petr Škoda (skodak) added a comment - Solution could be IMHO a new capability that is given to real course users only - course/forum:reciveforcedsubscription ..
Hide
Dan Marsden added a comment -

sounds good to me! - besides, the above code doesn't really fix the "problem" it just stops using a deprec lib function......

Show
Dan Marsden added a comment - sounds good to me! - besides, the above code doesn't really fix the "problem" it just stops using a deprec lib function......
Hide
Dan Marsden added a comment -

attached diff with suggested changes.

seems to work fine on my install

Dan

Show
Dan Marsden added a comment - attached diff with suggested changes. seems to work fine on my install Dan
Hide
Dan Marsden added a comment - - edited

This can be acheived using the mod/forum:initialsubscriptions capability - this code now causes a "bug" in 1.9 - see MDL-12979

Show
Dan Marsden added a comment - - edited This can be acheived using the mod/forum:initialsubscriptions capability - this code now causes a "bug" in 1.9 - see MDL-12979
Hide
Dan Marsden added a comment -

fixed by MDL-12979

Show
Dan Marsden added a comment - fixed by MDL-12979

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: