You are here

function farm_access_current_perms in farmOS 7

Gets a list of the permissions currently assigned to farm roles.

Parameters

string $role: A farm role machine name to get current permissions for.

Return value

array Returns an array of permission strings.

1 call to farm_access_current_perms()
farm_access_compare_perms in modules/farm/farm_access/farm_access.module
Compares available permissions to actual permissions.

File

modules/farm/farm_access/farm_access.module, line 343
Farm Access module.

Code

function farm_access_current_perms($role) {

  // Load all farm roles.
  $roles = farm_access_roles();

  // If the role doesn't have a name, bail.
  if (empty($roles[$role]['name'])) {
    return array();
  }

  // Load the role.
  $role = user_role_load_by_name($roles[$role]['name']);

  // If the role does not exist, bail.
  if (empty($role)) {
    return array();
  }

  // Load the permissions that are currently assigned to the role.
  $perms = user_role_permissions(array(
    $role->rid => $role->name,
  ));

  // Return the permissions for this role, as an array of strings.
  return array_keys($perms[$role->rid]);
}