MDL-43619 Roles: reset_role_capabilities unit test, cache fix

This commit is contained in:
sam marshall
2014-01-14 13:47:38 +00:00
parent bf2c42e8ee
commit a6a14f2155
2 changed files with 44 additions and 3 deletions
+9 -3
View File
@@ -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();
}
/**