You are here

function boost_user in Boost 6

Same name and namespace in other branches
  1. 5 boost.module \boost_user()

Implementation of hook_user(). Acts on user account actions.

File

./boost.module, line 2028
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_user($op, &$edit, &$account, $category = NULL) {
  global $user, $_boost;
  if (BOOST_VERBOSE >= 9 && isset($_boost['verbose_option_selected']['boost_user_op'])) {
    watchdog('boost', 'Debug: boost_user() <br />The %op operation was sent for user %user', array(
      '%op' => $op,
      '%user' => $user->uid,
    ));
  }
  switch ($op) {
    case 'login':

      // Set a special cookie to prevent authenticated users getting served
      // pages from the static page cache.
      boost_set_cookie($user->uid);
      break;
    case 'logout':

      // set the cookie to 0, then remove at the following request, this way browsers won't show a cached logged in page
      boost_set_cookie(-1);
      break;
    case 'delete':
      if (!variable_get('boost_enabled', CACHE_NORMAL)) {
        return;
      }

      // Expire the relevant user page from the static page cache to prevent serving stale content:
      if (!empty($account->uid)) {
        if (BOOST_NO_DATABASE) {
          $paths[] = 'user/' . $account->uid;
          $flushed = boost_cache_expire_derivative($paths, TRUE, TRUE);
        }
        else {
          $data[] = array(
            'page_callback' => 'user',
            'page_id' => $account->uid,
          );
          boost_set_base_dir_in_array($data);
          $flushed = boost_cache_expire_router($data, TRUE, TRUE);
        }
        if (BOOST_VERBOSE >= 7 && isset($_boost['verbose_option_selected']['boost_user_delete'])) {
          watchdog('boost', 'Debug: boost_user() <br />User !uid was deleted resulting in !flushed pages being expired from the cache', array(
            '!uid' => $account->uid,
            '!flushed' => $flushed,
          ));
        }
      }
      break;
  }
}