You are here

function user_permission_features_export_render in Features 7

Same name and namespace in other branches
  1. 6 includes/features.user.inc \user_permission_features_export_render()
  2. 7.2 includes/features.user.inc \user_permission_features_export_render()

Implements hook_features_export_render().

File

includes/features.user.inc, line 67

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();
    $permission['name'] = $perm_name;
    if (isset($permissions[$perm_name])) {
      sort($permissions[$perm_name]);
      $permission['roles'] = $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_name);
    $perm_export = features_var_export($permission, '  ');
    $code[] = "  // Exported permission: {$perm_name}.";
    $code[] = "  \$permissions[{$perm_identifier}] = {$perm_export};";
    $code[] = "";
  }
  $code[] = '  return $permissions;';
  $code = implode("\n", $code);
  return array(
    'user_default_permissions' => $code,
  );
}