asking about the code below, as far as i see it, it doesnt do anything unless if (!user_is_logged_in()) { .... am i wrong?
if im not wrong, they why not put the whole footer hook inside that "if", it would save me a few seconds load time on the page, javascript errors from that facebook lib (like basedomain not set stuff.. in ajax calls sometimes..), exemplification in code snip 2.. is this code ok?

/**
 * Implementation of hook_footer().
 */
function fbconnect_footer() {
  $url = 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php';
  $footer = '<script type="text/javascript" src="'. $url .'"></script>';
  // Display the autoconnect form.
  $footer .= drupal_get_form('fbconnect_autoconnect_form');
  return $footer;
}

/**
 * This form is submitted by javascript when facebook session is detected.
 */
function fbconnect_autoconnect_form() {
  $form['#validate'] = array('fbconnect_autoconnect_form_validate');
  $form['fbconnect'] = array('#type' => 'hidden');
  return $form;
}
function fbconnect_autoconnect_form_validate($form, &$form_state) {
  if (!user_is_logged_in()) {
    $fbuid = fbconnect_get_fbuid();
    if ($fbuid) {
      $uid = _is_fbconnect_user($fbuid);

      if (!$uid) {
        drupal_goto('fbconnect/register/prompt');
      }
      elseif ($uid) {
       $user = user_load($uid);
       user_external_login($user);
       drupal_goto($_GET['q']);
      }
    }
  }
}
/**
 * Implementation of hook_footer().
 */
function fbconnect_footer() {
  $footer = '' ;
  if (!user_is_logged_in()) {
    $url = 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php';
    $footer = '<script type="text/javascript" src="'. $url .'"></script>';
    // Display the autoconnect form.
    $footer .= drupal_get_form('fbconnect_autoconnect_form');
  }
  return $footer;
}

Comments

vectoroc’s picture

Version: 6.x-1.0-beta8 »
Status: Active » Postponed