function boost_user in Boost 5
Same name and namespace in other branches
- 6 boost.module \boost_user()
Implementation of hook_user(). Acts on user account actions.
File
- ./
boost.module, line 259 - Provides static page caching for Drupal.
Code
function boost_user($op, &$edit, &$account, $category = NULL) {
if (!BOOST_ENABLED) {
return;
}
global $user;
switch ($op) {
case 'login':
// Set special cookie to prevent logged-in users getting served pages from the static page cache.
$expires = ini_get('session.cookie_lifetime');
$expires = !empty($expires) && is_numeric($expires) ? time() + (int) $expires : 0;
setcookie(BOOST_COOKIE, $user->uid, $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
break;
case 'logout':
setcookie(BOOST_COOKIE, FALSE, time() - 86400, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
break;
case 'insert':
// TODO: create user-specific cache directory.
break;
case 'delete':
// Expire the relevant user page from the static page cache to prevent serving stale content:
if (!empty($account->uid)) {
boost_cache_expire('user/' . $account->uid);
}
// TODO: recursively delete user-specific cache directory.
break;
}
}