You are here

function mobile_tools_views_check_access in Mobile Tools 6.2

Same name and namespace in other branches
  1. 6.3 mobile_tools.module \mobile_tools_views_check_access()

Implementation of hook_views_check_access().

1 call to mobile_tools_views_check_access()
mobile_tools_plugin_access_mobile::access in views/plugins/mobile_tools_plugin_access_mobile.inc
Check access directly.
1 string reference to 'mobile_tools_views_check_access'
mobile_tools_plugin_access_mobile::get_access_callback in views/plugins/mobile_tools_plugin_access_mobile.inc

File

./mobile_tools.module, line 718
Primarily Drupal hooks.

Code

function mobile_tools_views_check_access($device, $perms, $rids) {
  global $user;

  // First check device permission
  $current_device = mobile_tools_site_type();

  // General case of mobile site
  if (!empty($device[$current_device])) {
    $access = TRUE;
  }
  else {
    return FALSE;
  }

  // Additional check
  if (!empty($perms)) {
    foreach ($perms as $perm) {
      $access = $access && user_access($perm);
    }
  }
  $account = isset($account) ? $account : $user;
  $roles = array_keys($account->roles);
  $roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
  if ($rids) {
    $access = $access && (user_access('access all views', $account) || array_intersect(array_filter($rids), $roles));
  }
  return $access;
}