You are here

function _authcache_is_account_cacheable in Authenticated User Page Caching (Authcache) 7

Same name and namespace in other branches
  1. 6 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 155
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) {
    $extra_roles = _authcache_diff_roles($account->roles, $cache_roles);
    if (!empty($extra_roles)) {
      return FALSE;
    }
  }
  return TRUE;
}