You are here

function authcache_authcache_account_exclude in Authenticated User Page Caching (Authcache) 7.2

Implements hook_authcache_account_exclude().

Related topics

1 call to authcache_authcache_account_exclude()
_authcache_debug_watchdog_enabled in modules/authcache_debug/authcache_debug.module
Return true when log-to-watchdog is enabled for the logged in user.

File

./authcache.module, line 997
Authenticated User Page Caching (and anonymous users, too!)

Code

function authcache_authcache_account_exclude($account) {

  // Bail out from requests by superuser (uid=1)
  if ($account->uid == 1 && !variable_get('authcache_su', 0)) {
    return t('Caching disabled for superuser');
  }

  // Check for non-cacheable roles of the account.
  $extra_roles = authcache_diff_roles($account->roles, authcache_get_roles());
  if (!empty($extra_roles)) {
    return format_plural(count($extra_roles), 'Account has non-cachable role @roles', 'Account has non-cachable roles @roles', array(
      '@roles' => implode(', ', $extra_roles),
    ));
  }

  // Ensure that at least one pagecaching rule matches for this account.
  $no_rule_matches = TRUE;
  $pagecaching = variable_get('authcache_pagecaching', _authcache_default_pagecaching());
  foreach ($pagecaching as $page_rules) {

    // Do caching page roles apply to the given account?
    if (authcache_role_restrict_access($page_rules['roles'], $account)) {
      $no_rule_matches = FALSE;
      break;
    }
  }
  if ($no_rule_matches) {
    return t('Account does not match any page caching rule.');
  }
}