You are here

function panels_page_access in Panels 5.2

Same name and namespace in other branches
  1. 6.2 panels_page/panels_page.read.inc \panels_page_access()

Determine if the specified user has access to a panel.

1 call to panels_page_access()
_panels_page_create_menu_item in panels_page/panels_page.module
Create a menu item for a panel page.

File

panels_page/panels_page.module, line 431
panels_page.module

Code

function panels_page_access($panel_page, $account = NULL) {
  if (!$account) {
    global $user;
    $account = $user;
  }

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

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

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