You are here

function merci_permissions_get_permissions_for_role in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 modules/merci_permissions/merci_permissions.module \merci_permissions_get_permissions_for_role()

returns an array of permissions for a given role

2 calls to merci_permissions_get_permissions_for_role()
merci_permissions_grant_permissions in modules/merci_permissions/merci_permissions.module
Helper function to grant permissions to a role.
merci_permissions_revoke_permissions in modules/merci_permissions/merci_permissions.module
Helper function to revoke permissions from a role.

File

modules/merci_permissions/merci_permissions.module, line 307
Provides functions for resetting permissions on the permission page.

Code

function merci_permissions_get_permissions_for_role($role_name) {
  $role = merci_permissions_get_role($role_name);
  $permissions = array();
  if ($role->rid > 0) {
    $perm_string = db_result(db_query("SELECT perm FROM {permission} WHERE rid = %d", $role->rid));
    if (strlen($perm_string) > 0) {
      $permissions = explode(',', $perm_string);
      foreach ($permissions as $index => $perm) {
        $permissions[$index] = trim($perm);
      }
    }
  }
  return $permissions;
}