You are here

function _user_features_get_permissions in Features 6

Same name and namespace in other branches
  1. 7.2 includes/features.user.inc \_user_features_get_permissions()
  2. 7 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()
FeaturesUserTestCase::_test_user_permission in tests/features.test
user_permission_features_export_render in includes/features.user.inc
Implementation of hook_features_export_render().

File

includes/features.user.inc, line 244

Code

function _user_features_get_permissions() {
  $result = db_query("SELECT p.perm, r.name FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid ORDER BY r.rid ASC, p.perm ASC");
  $permissions = array();
  while ($row = db_fetch_object($result)) {
    $role = $row->name;
    $role_perms = explode(', ', $row->perm);
    foreach ($role_perms as $perm) {
      if (!isset($permissions[$perm])) {
        $permissions[$perm] = array();
      }
      if (!in_array($role, $permissions[$perm])) {
        $permissions[$perm][] = $role;
      }
    }
  }
  return $permissions;
}