function panels_page_access in Panels 6.2
Same name and namespace in other branches
- 5.2 panels_page/panels_page.module \panels_page_access()
Determine if the specified user has access to a panel.
3 calls to panels_page_access()
- panels_page_access_handler in panels_page/
panels_page.module - Check whether the current page request is allowed.
- panels_page_preview_page in panels_page/
panels_page.admin.inc - _panels_page_master_loader in panels_page/
panels_page.module - Determine the render-time behavior of panels_page.
File
- panels_page/
panels_page.read.inc, line 276 - panels_page.write.inc
Code
function panels_page_access($id, $account = NULL) {
// FIXME this is a horrible lazy hack, but works until we REALLY solve it.
static $access_data = NULL;
if (is_null($access_data)) {
$result = db_query('SELECT pid, name, access FROM {panels_page}');
while ($row = db_fetch_object($result)) {
if (!empty($row->access)) {
$access_data[$row->pid] = explode(', ', $row->access);
$access_data[$row->name] =& $access_data[$row->pid];
}
}
}
if (!$account) {
global $user;
$account = $user;
}
// Administrator privileges
if (user_access('access all panel-pages', $account)) {
return TRUE;
}
// All panels displays with an empty access setting are available to all roles.
if (empty($access_data[$id]) || !is_array($access_data[$id])) {
return TRUE;
}
// Otherwise, check roles
$roles = array_keys($account->roles);
if (empty($account->uid)) {
$roles[] = DRUPAL_ANONYMOUS_RID;
}
return array_intersect($access_data[$id], $roles);
}