You are here

function panels_access in Panels 5

Determine if the specified user has access to a panel.

1 call to panels_access()
panels_menu in ./panels.module
Implementation of hook_menu()

File

./panels.module, line 26

Code

function panels_access($panel, $account = NULL) {
  if (!$account) {
    global $user;
    $account = $user;
  }

  // Administrator privileges
  if (user_access('access all panels', $account)) {
    return TRUE;
  }

  // All views with an empty access setting are available to all roles.
  if (!$panel->access) {
    return TRUE;
  }

  // Otherwise, check roles
  static $roles = array();
  if (!isset($roles[$account->uid])) {
    $roles[$account->uid] = array_keys($account->roles);
  }
  return array_intersect($panel->access, $roles[$account->uid]);
}