--- C:/Ratschiller/www/sites/all/modules/fbconnect/fbconnect.module	Sun Apr 05 11:13:09 2009
+++ C:/temp/fbconnect/fbconnect.module	Fri Mar 13 12:37:52 2009
@@ -13,20 +13,12 @@
 define('FBCONNECT_COMMENT_FEED_BUNDLEID', 47874003217);
 define('FBCONNECT_USE_FBAVATAR', 1);
 
-function fbconnect_init()
-{
-	global $user;
-	
-
-}
-
 /**
  * Implementation of hook_menu().
  */
 function fbconnect_menu($may_cache) {
  global $user;
  if ($may_cache) {
- 	
     $items[] = array(
       'path' => 'admin/settings/fbconnect',
       'title' => 'Fbconnect', 
@@ -61,7 +53,6 @@
     );
   }
   else {
-	
     // Renders the JS necessary for any Facebook interaction to work.
     _fbconnect_render_js();
     
@@ -100,21 +91,12 @@
     '#collapsible' => FALSE,
     '#weight' => -5,
   );
-  
   $form['api']['fbconnect_fast_reg'] = array(
     '#type' => 'checkbox',
     '#title' => t('Fast registration mode'),
     '#default_value' => variable_get('fbconnect_fast_reg', NULL),
     '#description' => t('Enabling this mode allows the user to create an account in one click.')
   );
-  
-  $form['api']['fbconnect_fast_reg_import_anyway'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Import user data in fast registration mode.'),
-    '#default_value' => variable_get('fbconnect_fast_reg_import_anyway', NULL),
-    '#description' => t('Import user data from Facebook anyway when using fast registration mode (without asking the user for permission).')
-  );
-    
   $form['api']['fbconnect_api_key'] = array( 
     '#type' => 'textfield', 
     '#title' => t('Facebook API KEY'), 
@@ -203,8 +185,6 @@
  * Called when user perform facebook registration
  */
 function fbconnect_register_page() {
-  global $user;
-	
   if (!$fbuid = fbconnect_get_fbuid()) {
     drupal_set_message(t('Your Facebook session has expired, try to reconnect'));
     drupal_goto();
@@ -228,17 +208,7 @@
       'status' => 1,
       'mail' => $mail,
     );
-    
     fbconnect_register_user($udata);
-    
-    if(variable_get('fbconnect_fast_reg_import_anyway', false))
-    {
-	    $options =  array_values(variable_get('fbconnect_profile_fields', NULL));
-	    $options = array_filter($options, 'fbconnect_import_filter');
-	    
-	    fbconnect_profile_insert_user_info($user->uid, $options);
-    }    
-
     drupal_set_message(t('Registration successful')); 
     drupal_goto();
   }
@@ -689,7 +659,7 @@
  * This function manage all javascripts used by this module.
  */
 function _fbconnect_render_js() {
-  global $base_url, $user;
+  global $base_url;
   $url = drupal_to_js($base_url);
   drupal_add_js(drupal_get_path('module', 'fbconnect') .'/js/fbconnect.js', 'module', 'footer');
 
@@ -718,63 +688,10 @@
     unset($_SESSION['fbconnect_feed']);
   }
   
-  $fb_uid = fbconnect_get_fbuid();
-  
-	// This is our local uid, if user is logged in
-	$uid = $user->uid;
-	
-	if ($fb_uid && $_GET['fblogout']) {
-	$onload_js = 'FB.Connect.logout(function() { window.location = '. $url .';});';
-	}
-	
-	// Does the FB user have a local uid?
-	$fbuser_uid = _is_fbconnect_user($fb_uid);
-	$fbuser_uid = $fbuser_uid["uid"];
-	
-	// Is the local user a Fb user?
-	if($uid)
-		$is_fb_local_user = _is_fbconnect_user_by_uid($uid);
-	
-	// If we have a FB user, and the Fb user is also a local user, and there is no currently logged in user, and we are not on $_POST (for example by fbconnect login)
-	if(!empty($fb_uid) && $fbuser_uid && !$uid && !isset($_GET["fblogout"]) && empty($_POST))
-	{
-
-		drupal_set_message(t("You are being logged in because you are logged in to Facebook."));
-		$account = user_load(array('uid' => $fbuser_uid, 'status' => 1));
-		if ($account === FALSE) {
-		}
-		
-		$user = $account;
-		
-		watchdog('user',
-		t('Session opened for %name (via FbConnect).',
-		  array('%name' => $user->name))
-		);
-		
-		// Update the user table timestamp noting that the user has logged in.
-		db_query("UPDATE {users} SET login = %d WHERE uid = %d", time(), $user->uid);
-		
-		sess_regenerate();
-		
-		$edit = array();
-		user_module_invoke('login', $edit, $user);
-	}
-	
-	#var_dump($fb_uid);
-	
-	// If there is no Fb user anymore, and the user is logged in, and the current user is a Fb User
-	if($fb_uid == NULL && $user->uid && $is_fb_local_user)
-	{
-		$sitename  = check_plain(variable_get('site_name', t('this website')));
-		drupal_set_message(t("You have been logged out of !site_name because you have logged out of Facebook.", array("!site_name" => $sitename)));
-		$onload_js = 'window.location = '/';';
-		user_logout(); 	 	
-	}	  
-  
-  if ($fb_uid && $_GET['fblogout'] && $is_fb_local_user) {
+  if (fbconnect_get_fbuid() && $_GET['fblogout']) {
     $onload_js = 'FB.Connect.logout(function() { window.location = '. $url .';});';
-  }  
-  
+  }
+
   $xd_path = drupal_to_js(base_path() . drupal_get_path('module', 'fbconnect') .'/xd_receiver.html');
   drupal_add_js('FB.Bootstrap.requireFeatures(["Connect","XFBML"], function() {
                     FB.Facebook.init("'. $conf['api_key'] .'", '. $xd_path .');
@@ -956,29 +873,8 @@
  *   facebook user id
  */
 function fbconnect_get_fbuid() {
-  if ($fb = facebook_client()) {
-  	#var_dump($fb);
-    try {
-        // This call checks the full session, not just the local
-        // cookies. Its possible that the cookies are good, but
-        // the session has timed out. This case isn't really handled
-        // by the facebookObj, so we consult the api_client for the
-        // real state of the user.
-        $fb_uid = facebook_client()->get_loggedin_user();
-        
-    } catch (FacebookRestClientException $e) {
-    	#var_dump($fb);exit;
-        // API_EC_PARAM means we don't have a logged in user, otherwise who
-        // knows what it means, so just throw it.
-        if ($e->getCode() != FacebookAPIErrorCodes::API_EC_PARAM) {
-            $fb_uid = "expired"; // TODO - Make 0 in this case??
-        } else {
-            $fb_uid = "expired";
-        }
-    }
-
-  	
-    return $fb_uid;
+  if (facebook_client()) {
+    return facebook_client()->get_loggedin_user();
   }
 }
 
@@ -989,24 +885,11 @@
  *   Facebook user id
  * @return array
  */
-function _is_fbconnect_user_by_uid($uid) {
-  $data = db_fetch_array(db_query('SELECT uid FROM {fbconnect_users} WHERE uid = %d', $uid));
-  return ($data) ? $data : FALSE;
-}
-
-/**
- * Check by uid if user already registered in the fbconnect_users table
- *
- * @param integer $uid
- *   Drupal user id
- * @return array
- */
 function _is_fbconnect_user($fbuid) {
   $data = db_fetch_array(db_query('SELECT uid FROM {fbconnect_users} WHERE fbuid = %d', $fbuid));
   return ($data) ? $data : FALSE;
 }
 
-
 function fbconnect_import_filter($var) {
   return (is_string($var)) ? $var : NULL;
 }
@@ -1066,7 +949,6 @@
 function facebook_client() {
   static $fb = NULL;
   if (!$fb instanceof Facebook) {
-  	
     if ($conf = fbconnect_get_config()) {
       // Facebook php client API
       $lib_path = drupal_get_path('module', 'fbconnect') .'/facebook-client/';
@@ -1092,7 +974,6 @@
       }
     }
   }
-  #var_dump($fb);
   return $fb;
 }
 
--- C:/Ratschiller/www/sites/all/modules/fbconnect/modules/fbconnect_profile/fbconnect_profile.install	Sat Apr 04 10:49:40 2009
+++ C:/temp/fbconnect/modules/fbconnect_profile/fbconnect_profile.install	Thu Mar 12 18:30:26 2009
@@ -34,9 +34,7 @@
       ) /*!40100 DEFAULT CHARACTER SET utf8 */");
   }
   $facebook_fields = array(
-  	'first_name'          => t('First name'),
-  	'last_name'           => t('Last name'),
-    'name'                => t('Full name'),
+    'name'                => t('Facebook name'),
     'affiliations'        => t('Affiliations'),
     'religion'            => t('Religious Views'),
     'birthday'            => t('Birthday'),
--- C:/Ratschiller/www/sites/all/modules/fbconnect/modules/fbconnect_profile/fbconnect_profile.module	Sat Apr 04 17:56:05 2009
+++ C:/temp/fbconnect/modules/fbconnect_profile/fbconnect_profile.module	Thu Mar 12 18:30:26 2009
@@ -271,8 +271,7 @@
 function fbconnect_profile_insert_user_info($uid, $fields_setting) {
   $fbuid = fbconnect_get_fbuid();  
   $fb_user_profile = fbconnect_get_info_from_fb($fbuid, implode(',', $fields_setting));
-  #var_dump($fields_setting);var_dump($fb_user_profile);exit;
-    
+  
   if (count($fields_setting) != count($fb_user_profile)) {
     watchdog('fbconnect', 'Error importing from facebook for fbuid : %fbuid', array('%fbuid' => $fbuid));
     drupal_set_message(t('Error importing from facebook'), 'error');    
@@ -288,15 +287,10 @@
     $values[] = (is_array($value)) ? serialize($value) : $value;
     $s[] = "'%s'";
   }
-  
-  #var_dump($values);exit;
   // Save user information imported from Facebook 
   db_query('REPLACE INTO {fbconnect_profile} ('. implode(', ', $fields) .') VALUES ('. implode(', ', $s) .')', $values);
   // Update the 24h cache timer and save fields settings.
   db_query("UPDATE {fbconnect_users} SET timestamp = %d, import_setting = '%s' WHERE uid = %d", time(), serialize($fields_setting), $uid);
-  
-  module_invoke_all("fbconnect_profile_insert", $uid, $fb_user_profile);
-  
   return TRUE;
 }
 
