function user_permission_features_export_render in Features 7.2
Same name and namespace in other branches
- 6 includes/features.user.inc \user_permission_features_export_render()
- 7 includes/features.user.inc \user_permission_features_export_render()
Implements hook_features_export_render().
File
- includes/
features.user.inc, line 84 - Features integration for 'user' module.
Code
function user_permission_features_export_render($module, $data) {
$perm_modules =& drupal_static(__FUNCTION__ . '_perm_modules');
if (!isset($perm_modules)) {
$perm_modules = user_permission_get_modules();
}
$code = array();
$code[] = ' $permissions = array();';
$code[] = '';
$permissions = _user_features_get_permissions();
foreach ($data as $perm_name) {
$permission = array();
// Export vocabulary permissions using the machine name, instead of
// vocabulary id.
$perm = $perm_name;
_user_features_change_term_permission($perm_name, 'machine_name');
$permission['name'] = $perm;
if (!empty($permissions[$perm_name])) {
sort($permissions[$perm_name]);
$permission['roles'] = drupal_map_assoc($permissions[$perm_name]);
}
else {
$permission['roles'] = array();
}
if (isset($perm_modules[$perm_name])) {
$permission['module'] = $perm_modules[$perm_name];
}
$perm_identifier = features_var_export($perm);
$perm_export = features_var_export($permission, ' ');
$code[] = " // Exported permission: {$perm_identifier}.";
$code[] = " \$permissions[{$perm_identifier}] = {$perm_export};";
$code[] = "";
}
$code[] = ' return $permissions;';
$code = implode("\n", $code);
return array(
'user_default_permissions' => $code,
);
}