function user_permission_features_rebuild in Features 6
Same name and namespace in other branches
- 7.2 includes/features.user.inc \user_permission_features_rebuild()
- 7 includes/features.user.inc \user_permission_features_rebuild()
Implementation of 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 - Implementation of hook_features_revert().
File
- includes/
features.user.inc, line 123
Code
function user_permission_features_rebuild($module) {
if ($defaults = features_get_default('user_permission', $module)) {
$roles = _features_get_roles();
foreach ($defaults as $permission) {
$perm = $permission['name'];
// Add permissions for any roles that should have them.
foreach ($permission['roles'] as $role) {
if (isset($roles[$role]) && !in_array($perm, $roles[$role]['perm'])) {
$roles[$role]['perm'][] = $perm;
}
}
// Remove permissions for any roles that shouldn't have them.
foreach (array_keys($roles) as $role) {
if (in_array($perm, $roles[$role]['perm']) && !in_array($role, $permission['roles'])) {
$position = array_search($perm, $roles[$role]['perm']);
unset($roles[$role]['perm'][$position]);
}
}
}
// Write the updated permissions.
_user_features_save_roles($roles);
}
}