You are here

function block_access_user_access in Block Access 7

Same name and namespace in other branches
  1. 6.2 block_access.module \block_access_user_access()
  2. 6 block_access.module \block_access_user_access()
17 calls to block_access_user_access()
block_access_can_config in ./block_access.module
block_access_can_config_body in ./block_access.module
block_access_can_config_description in ./block_access.module
block_access_can_config_lang in ./block_access.module
block_access_can_config_page in ./block_access.module

... See full list

File

./block_access.module, line 152

Code

function block_access_user_access($module, $delta, $perm) {
  global $user;
  static $perms = array();
  if (!isset($perms[$module])) {
    $perms[$module] = array(
      $delta => array(),
    );
  }
  if (!isset($perms[$module][$delta])) {
    $perms[$module][$delta] = array();
  }
  if (!isset($perms[$module][$delta][$perm])) {
    $perms[$module][$delta][$perm] = FALSE;
    module_load_include('inc', 'block_access', 'block_access.db');
    $roles = block_access_get_roles($module, $perm, $delta);
    foreach ($roles as $rid) {
      if (in_array($rid, array_keys($user->roles))) {
        $perms[$module][$delta][$perm] = TRUE;
        break;
      }
    }
  }
  return $perms[$module][$delta][$perm];
}