You are here

function _user_features_get_permissions in Features 7

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

Represent the current state of permissions as a perm to role name array map.

2 calls to _user_features_get_permissions()
user_permission_features_export_render in includes/features.user.inc
Implements hook_features_export_render().
user_permission_features_rebuild in includes/features.user.inc
Implements hook_features_rebuild(). Iterate through default permissions and update the permissions map.

File

includes/features.user.inc, line 247

Code

function _user_features_get_permissions($by_role = TRUE) {
  $map = user_permission_get_modules();
  $roles = _user_features_get_roles();
  $permissions = array();
  foreach (user_role_permissions($roles) as $rid => $role_permissions) {
    if ($by_role) {
      foreach (array_keys(array_filter($role_permissions)) as $permission) {
        if (isset($map[$permission])) {
          $permissions[$permission][] = $roles[$rid];
        }
      }
    }
    else {
      $permissions[$roles[$rid]] = array();
      foreach ($role_permissions as $permission => $status) {
        if (isset($map[$permission])) {
          $permissions[$roles[$rid]][$permission] = $status;
        }
      }
    }
  }
  return $permissions;
}