You are here

function _quictabs_access_block in Quick Tabs 6.3

Same name and namespace in other branches
  1. 6.2 quicktabs.module \_quictabs_access_block()

Helper function to determine if user has access to a specific block delta.

1 call to _quictabs_access_block()
quicktabs_render_tabpage in ./quicktabs.module
Render quicktabs tabpage.

File

./quicktabs.module, line 695

Code

function _quictabs_access_block($module = '', $delta = '') {
  global $user;
  $rids = array_keys($user->roles);
  $result = db_query("SELECT rid from {blocks_roles} br WHERE module = '%s' and delta = '%s'", $module, $delta);
  $authorized_rids = array();
  while ($rid = db_result($result)) {
    $authorized_rids[] = $rid;
  }

  // Return whether the user can access the block:
  // - Either all roles have access - no record in {blocks_roles}
  // - Or only specific roles have access - in which case rids should match.
  return count($authorized_rids) == 0 || count(array_intersect($authorized_rids, $rids)) != 0;
}