Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.9.2
-
Fix Version/s: None
-
Component/s: Forum
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
Users who have a sitewide role that grants moodle/course:view, but does not grant mod/forum:initialsubscriptions, get automatically subscribed to forums that are created with the option Subscribe Users: Yes, Initially.
As a result, administrative users who have a sitewide role get dozens of bogus emails from courses they are not directly involved with.
This is a very similar bug to MDL-10163, but occurs in a different place in the code. (When forums are created.)
Here is a proposed fix to /mod/forum/lib.php, function forum_add_instance()...
... replace this:
if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
$users = get_course_users($forum->course);
foreach ($users as $user) {
forum_subscribe($user->id, $forum->id);
}
}
.. with this:
if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
$context = get_context_instance(CONTEXT_COURSE, $forum->course);
$users= get_users_by_capability($context, 'mod/forum:initialsubscriptions', 'u.id', '', '','','','', false, true);
foreach ($users as $user) { forum_subscribe($user->id, $forum->id); } }
}
Activity
- All
- Comments
- History
- Activity
- Source
- Test Sessions
I fixed this recently in 1.9.3+. For details, search for the duplicate tracker issue.