You are here

function cas_logout in CAS 6

Same name and namespace in other branches
  1. 5.4 cas.module \cas_logout()
  2. 5 cas.module \cas_logout()
  3. 5.3 cas.module \cas_logout()
  4. 6.3 cas.module \cas_logout()
  5. 6.2 cas.module \cas_logout()
  6. 7 cas.module \cas_logout()

Logs a user out of drupal and then out of cas

1 string reference to 'cas_logout'
cas_menu in ./cas.module
Implements hook_menu.

File

./cas.module, line 570

Code

function cas_logout() {
  global $user;
  watchdog('user', 'Session closed for %name.', array(
    '%name' => theme('placeholder', $user->name),
  ));

  // Destroy the current session:
  session_destroy();
  module_invoke_all('user', 'logout', NULL, $user);

  // We have to use $GLOBALS to unset a global variable:
  $user = user_load(array(
    'uid' => 0,
  ));
  $port = variable_get('cas_port', '443');
  $server = variable_get('cas_server', 'cas');
  $uri = variable_get('cas_uri', '');

  // Begin constructing logout destination
  $logout_destination = 'https://' . $server;

  // Add abnormal port
  if ($port != '443') {
    $logout_destination .= ':' . $port;
  }

  // Add logout
  $logout_destination .= '/' . $uri . '/logout';

  // If admin has set and enabled a logout destination, add it
  if (variable_get('cas_logout_redirect', 0) && variable_get('cas_logout_destination', '')) {
    $logout_destination .= '?service=' . variable_get('cas_logout_destination', '');
  }

  // Go to the constructed logout destination
  drupal_goto($logout_destination);
}