You are here

function autologout_footer in Automated Logout 5

Same name and namespace in other branches
  1. 6.4 autologout.module \autologout_footer()

Implementation of hook_footer()

File

./autologout.module, line 170
Used to automagically log out a user after a preset time, AjK May 2006

Code

function autologout_footer() {
  global $user;
  _autologout_debug("autologout_footer()");

  // if the user is UID 1 or anon or user in an excluded role, do nothing
  if ($user->uid < 2 || _autologout_by_role()) {
    return;
  }
  $timeout = (int) _autologout_local_settings('timeout');
  if (_autologout_local_settings('enabled')) {
    if (!isset($_SESSION['lastaccess']) || (int) $_SESSION['lastaccess'] + $timeout > time()) {
      $_SESSION['lastaccess'] = time();
      if ($refresh = (int) _autologout_local_settings('refresh_delta')) {
        $force_refresh = $timeout + $refresh;
        drupal_set_html_head("\n  <meta http-equiv=\"refresh\" content=\"{$force_refresh}\" />");
        return;
      }
    }
    else {

      // timeout occured, end session
      if (_autologout_local_settings('use_watchdog')) {
        watchdog('user', ' logout activated', WATCHDOG_NOTICE);
      }
      unset($_SESSION['lastaccess']);
      user_logout();
      return;
    }
  }
  return;
}