function user_permission_features_rebuild in Features 7.2
Same name and namespace in other branches
- 6 includes/features.user.inc \user_permission_features_rebuild()
- 7 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 139 - Features integration for 'user' module.
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();
$modules = user_permission_get_modules();
$roles = _user_features_get_roles();
$permissions_by_role = _user_features_get_permissions(FALSE);
foreach ($defaults as $permission) {
$perm = $permission['name'];
_user_features_change_term_permission($perm, 'machine_name');
if (empty($modules[$perm])) {
$args = array(
'!name' => $perm,
'!module' => $module,
);
$msg = t('Warning in features rebuild of !module. No module defines permission "!name".', $args);
drupal_set_message($msg, 'warning');
continue;
}
// Export vocabulary permissions using the machine name, instead of
// vocabulary id.
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]);
}
}
}
}