You are here

function fb_user_user_logoutXXX in Drupal for Facebook 7.3

Implements hook_user_logout.

User has logged out.

File

./fb_user.module, line 786
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function fb_user_user_logoutXXX($account) {

  // Disabled.  Still needed?  Seems to cause problems in some cases.
  global $user, $_fb_app;
  if (fb_facebook_user() && fb_api_check_session($GLOBALS['_fb'])) {

    // Log out of facebook, as well as Drupal. Note that code in
    // fb_connect.js and fb_canvas.js attempts to call FB.logout. However,
    // that code is not reached if the user types "/logout" directly into
    // the browser URL. Also, a sometimes-occuring bug in firefox prevents
    // FB.logout from always succeeding.
    // Figure out where to send the user.
    if (isset($_REQUEST['destination'])) {
      $next_url = url($_REQUEST['destination'], array(
        'absolute' => TRUE,
        'fb_canvas' => fb_is_canvas(),
      ));

      // Unset desination so drupal_goto() below does what we need it to do.
      unset($_REQUEST['destination']);
    }
    else {
      $next_url = url('<front>', array(
        'absolute' => TRUE,
        'fb_canvas' => fb_is_canvas(),
      ));
    }
    $logout_url = $GLOBALS['_fb']
      ->getLogoutUrl(array(
      'next' => $next_url,
      'cancel_url' => $next_url,
    ));

    // Drupal 7 calls us before destroying the session, so destroy it here
    // manually, as we're about to redirect.
    session_destroy();
    drupal_goto($logout_url);
  }
}