You are here

function panels_pane_access in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/plugins.inc \panels_pane_access()
  2. 6.3 includes/plugins.inc \panels_pane_access()
  3. 7.3 includes/plugins.inc \panels_pane_access()

Master pane access function; combines all the relevant parameters that natively used by the Panels API to determine a pane's access. Called from panels_render_panes().

Parameters

$pane: The pane object to test for access.

$display: The display object containing the pane object to be tested.

Related topics

1 call to panels_pane_access()
panels_render_panes in includes/display-render.inc
Render all the panes in a display into a $content array to be used by the display theme function.

File

includes/plugins.inc, line 160
plugins.inc

Code

function panels_pane_access($pane, $display) {
  global $user;

  // Administrator privileges
  if (user_access('view all pane', $user)) {
    return TRUE;
  }
  $role_access = _panels_pane_access_role($pane, $user);
  $type = panels_get_content_type($pane->type);
  if (!($visibility_check = panels_plugin_get_function('content_types', $type, 'visibility check'))) {
    return $role_access;
  }

  // Call the content type's custom-defined visibility rendering check.
  // Pass as much possibly relevant data as possible.
  $visibility_access = $visibility_check($pane, $display, $user);

  // Content type marked both access modes to be ANDed together.
  if (!empty($type['roles and visibility'])) {
    return $visibility_access === TRUE && $role_access === TRUE ? TRUE : FALSE;
  }

  // Err on the safe side: if EVERYTHING else has failed, then don't render the pane.
  return isset($visibility_access) ? $visibility_access : FALSE;
}