Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
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!
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.