function _authcache_is_account_cacheable in Authenticated User Page Caching (Authcache) 6
Same name and namespace in other branches
- 7 authcache.helpers.inc \_authcache_is_account_cacheable()
Should user account receive cached pages?
2 calls to _authcache_is_account_cacheable()
- authcache_form_alter in ./authcache.module 
- Implements hook_form_alter(),
- _authcache_is_cacheable in ./authcache.helpers.inc 
- Should the current page be cached?
File
- ./authcache.helpers.inc, line 93 
- Helper functions for the Authcache module (no Drupal hooks here).
Code
function _authcache_is_account_cacheable($account = FALSE) {
  if (!$account) {
    global $user;
    $account = $user;
  }
  // Check if caching is enabled for user's role
  $cache_roles = variable_get('authcache_roles', array());
  // Anonymous
  if (!$account->uid && !in_array(DRUPAL_ANONYMOUS_RID, $cache_roles)) {
    return FALSE;
  }
  elseif ($account->uid) {
    unset($cache_roles[DRUPAL_ANONYMOUS_RID]);
    $extra_roles = array_diff(array_keys($account->roles), $cache_roles);
    // Admin selected a role, but did not selected "authenticated user"
    if ($extra_roles && $extra_roles[0] == DRUPAL_AUTHENTICATED_RID && count($extra_roles) == 1 && count($account->roles) > 1) {
      return TRUE;
    }
    if (!empty($extra_roles)) {
      return FALSE;
    }
  }
  return TRUE;
}