Commit a7bb9b8f authored by toyomoyo's avatar toyomoyo
Browse files

merged fix for MDL-8981, roles assigned at site level may result in a lot of default subscriptions

parent 0fd22238
......@@ -2166,7 +2166,7 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time
include_once($CFG->dirroot.'/mod/'.$mod.'/lib.php');
$functionname = $mod.'_role_assign';
if (function_exists($functionname)) {
$functionname($userid, $context);
$functionname($userid, $context, $roleid);
}
}
}
......
......@@ -250,6 +250,17 @@ $mod_forum_capabilities = array(
)
),
'mod/forum:initialsubscriptions' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'student' => CAP_ALLOW
)
),
'mod/forum:throttlingapplies' => array(
'riskbitmask' => RISK_SPAM,
......
......@@ -3829,8 +3829,18 @@ function forum_update_subscriptions_button($courseid, $forumid) {
* @param object $context
* @return bool
*/
function forum_role_assign($userid, $context) {
return forum_add_user_default_subscriptions($userid, $context);
function forum_role_assign($userid, $context, $roleid) {
// check to see if this role comes with mod/forum:initialsubscriptions
$cap = role_context_capabilities($roleid, $context, 'mod/forum:initialsubscriptions');
// we are checking the role because has_capability() will pull this capability out
// from other roles this user might have and resolve them, which is no good
if ($cap['mod/forum:initialsubscriptions'] == CAP_ALLOW) {
return forum_add_user_default_subscriptions($userid, $context);
} else {
// MDL-8981, do not subscribe to forum
return true;
}
}
......
......@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2007020201;
$module->version = 2007020202;
$module->requires = 2007020201; // Requires this Moodle version
$module->cron = 60;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment