MDL-43619 Roles: reset_role_capabilities unit test, cache fix
This commit is contained in:
+9
-3
@@ -2615,8 +2615,11 @@ function get_default_role_archetype_allows($type, $archetype) {
|
||||
* Reset role capabilities to default according to selected role archetype.
|
||||
* If no archetype selected, removes all capabilities.
|
||||
*
|
||||
* @param int $roleid
|
||||
* @return void
|
||||
* This applies to capabilities that are assigned to the role (that you could
|
||||
* edit in the 'define roles' interface), and not to any capability overrides
|
||||
* in different locations.
|
||||
*
|
||||
* @param int $roleid ID of role to reset capabilities for
|
||||
*/
|
||||
function reset_role_capabilities($roleid) {
|
||||
global $DB;
|
||||
@@ -2627,11 +2630,14 @@ function reset_role_capabilities($roleid) {
|
||||
$systemcontext = context_system::instance();
|
||||
|
||||
$DB->delete_records('role_capabilities',
|
||||
array('roleid'=>$roleid, 'contextid' => $systemcontext->id));
|
||||
array('roleid' => $roleid, 'contextid' => $systemcontext->id));
|
||||
|
||||
foreach($defaultcaps as $cap=>$permission) {
|
||||
assign_capability($cap, $permission, $roleid, $systemcontext->id);
|
||||
}
|
||||
|
||||
// Mark the system context dirty.
|
||||
context_system::instance()->mark_dirty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user