function user_permission_features_rebuild in Features 7
Same name and namespace in other branches
- 6 includes/features.user.inc \user_permission_features_rebuild()
- 7.2 includes/features.user.inc \user_permission_features_rebuild()
Implements hook_features_rebuild(). Iterate through default permissions and update the permissions map.
Parameters
$module: The module whose default user permissions should be rebuilt.
1 call to user_permission_features_rebuild()
- user_permission_features_revert in includes/
features.user.inc - Implements hook_features_revert().
File
- includes/
features.user.inc, line 118
Code
function user_permission_features_rebuild($module) {
if ($defaults = features_get_default('user_permission', $module)) {
// Make sure the list of available node types is up to date, especially when
// installing multiple features at once, for example from an install profile
// or via drush.
node_types_rebuild();
$roles = _user_features_get_roles();
$permissions_by_role = _user_features_get_permissions(FALSE);
foreach ($defaults as $permission) {
$perm = $permission['name'];
foreach ($roles as $role) {
if (in_array($role, $permission['roles'])) {
$permissions_by_role[$role][$perm] = TRUE;
}
else {
$permissions_by_role[$role][$perm] = FALSE;
}
}
}
// Write the updated permissions.
foreach ($roles as $rid => $role) {
if (isset($permissions_by_role[$role])) {
user_role_change_permissions($rid, $permissions_by_role[$role]);
}
}
}
}