Index: fbconnect.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect.admin.inc,v
retrieving revision 1.19.2.3
diff -u -p -r1.19.2.3 fbconnect.admin.inc
--- fbconnect.admin.inc	30 Oct 2010 12:18:35 -0000	1.19.2.3
+++ fbconnect.admin.inc	21 Jan 2011 23:01:24 -0000
@@ -1,20 +1,20 @@
 <?php
 // $Id: fbconnect.admin.inc,v 1.19.2.3 2010/10/30 12:18:35 vectoroc Exp $
 
-/** 
- * @file 
- * Administration page callbacks for the fbconnect module. 
- */ 
-
-function fbconnect_api_keys_settings(&$form_state) {
-  $form['fbconnect_appid'] = array( 
-    '#type' => 'textfield', 
+/**
+ * @file
+ * Administration page callbacks for the fbconnect module.
+ */
+
+function fbconnect_api_keys_settings($form, &$form_state) {
+  $form['fbconnect_appid'] = array(
+    '#type' => 'textfield',
     '#required' => TRUE,
-    '#title' => t('Application ID'), 
+    '#title' => t('Application ID'),
     '#default_value' => variable_get('fbconnect_appid', NULL),
     '#description' => t('Your Application ID, <strong> not API Key </strong>'),
   );
-  
+
   $form['fbconnect_skey'] = array(
     '#type' => 'textfield',
     '#required' => TRUE,
@@ -22,14 +22,14 @@ function fbconnect_api_keys_settings(&$f
     '#default_value' => variable_get('fbconnect_skey', NULL),
     '#description' => t('Do not share your secret key with anyone'),
   );
-  
+
   $form['fbconnect_language_code'] = array(
     '#type' => 'textfield',
     '#title' => (module_exists('i18n')) ? t('Default language code') : t('Language code'),
     '#description' => t('Enter your country code here to get translated versions of facebook connect. (e.g. en_US or de_DE)'),
     '#default_value' => variable_get('fbconnect_language_code', 'en_US'),
   );
-  
+
   if (module_exists('i18n')) {
     $form['language_codes'] = array(
       '#type'          => 'fieldset',
@@ -47,31 +47,31 @@ function fbconnect_api_keys_settings(&$f
         '#options'       => array('' => t('- Use default -')) + _fbconnect_language_codes(),
       );
     }
-  }  
-  
+  }
+
   $form['fbconnect_debug'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Debug mode'),      
+    '#title' => t('Debug mode'),
     '#default_value' => variable_get('fbconnect_debug', FALSE),
-  );  
-  
+  );
+
   $form['fbconnect_connect_url'] = array(
     '#type' => 'item',
     '#title' => t('Connect url'),
     '#description' => t('Copy this value into Facebook Applications on Connect settings tab'),
     '#value' => variable_get('fbconnect_connect_url', $GLOBALS['base_url'] . '/'),
   );
-    
-//  locale
-//  connect_logo_url
-//  about_url
-//  base_domain
-//  tos_url
+
+  //  locale
+  //  connect_logo_url
+  //  about_url
+  //  base_domain
+  //  tos_url
 
   return system_settings_form($form);
 }
 
-function fbconnect_appearance_settings(&$form_state) {
+function fbconnect_appearance_settings($form, &$form_state) {
   $form['site'] = array(
     '#type' => 'fieldset',
     '#title' => t('Settings for !site', array('!site' => variable_get('site_name', t('Your Site')))),
@@ -84,7 +84,7 @@ function fbconnect_appearance_settings(&
     '#default_value' => variable_get('fbconnect_fast_reg', NULL),
     '#description' => t('Enable this mode will bypass drupal\'s standard registration form.'),
   );
-  
+
   $form['site']['fbconnect_loginout_mode'] = array(
     '#type' => 'select',
     '#title' => t('Login/logout mode'),
@@ -96,27 +96,27 @@ function fbconnect_appearance_settings(&
     '#default_value' => variable_get('fbconnect_loginout_mode', FALSE),
     '#description' => t('Login to drupal/logout from facebook. Enable this if you don\'t want to logout automatically from facebook.'),
   );
-  
-  // TODO: rename to more clear name 
+
+  // TODO: rename to more clear name
   $form['site']['fbconnect_reg_options'] = array(
     '#type' => 'checkbox',
     '#title' => t('Disable linking accounts during registration'),
     '#default_value' => variable_get('fbconnect_reg_options', 0),
     '#description' => t('Disables the option to link local account to a FB account on registration'),
   );
-  
+
   $form['display'] = array(
     '#title' => t('Display Settings'),
     '#type' => 'fieldset',
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
   );
-  
-  if (fbconnect_get_config()) {  
+
+  if (fbconnect_get_config()) {
     $button = array(
-      'small_short'  => fbconnect_render_button(array('size' => 'small' , 'onclick' => 'return false;')),
+      'small_short'  => fbconnect_render_button(array('size' => 'small', 'onclick' => 'return false;')),
       'medium_short' => fbconnect_render_button(array('size' => 'medium', 'onclick' => 'return false;')),
-      'large_short'  => fbconnect_render_button(array('size' => 'large' , 'onclick' => 'return false;')),
+      'large_short'  => fbconnect_render_button(array('size' => 'large', 'onclick' => 'return false;')),
     );
 
     $form['display']['fbconnect_button'] = array(
@@ -129,9 +129,9 @@ function fbconnect_appearance_settings(&
       '#type' => 'textfield',
       '#description' => t('Enter the text you want to display on the Facebook Connect Button.'),
       '#default_value' => variable_get('fbconnect_button_text', 'Connect'),
-    );  
+    );
   }
-  
+
   $form['display']['fbconnect_pic_allow'] = array(
     '#type' => 'select',
     '#title' => t('Facebook picture settings'),
@@ -142,14 +142,14 @@ function fbconnect_appearance_settings(&
       'disallow' => t('Do not allow the use of facebook user picture at your site'),
     ),
   );
-  
+
   $options_pic_size = array(
     'thumb' => t('Thumb (50px wide)'),
     'small' => t('Small (100px wide)'),
     'normal' => t('Normal (200px wide)'),
     'square' => t('Square (50px by 50px)'),
   );
-  
+
   $form['display']['fbconnect_pic_size'] = array(
     '#type' => 'select',
     '#title' => t('Default Facebook picture size'),
@@ -157,7 +157,7 @@ function fbconnect_appearance_settings(&
     '#default_value' => variable_get('fbconnect_pic_size', 'square'),
     '#options' => $options_pic_size,
   );
-  
+
   $form['display']['fbconnect_pic_size_nodes'] = array(
     '#type' => 'select',
     '#title' => t('Node Facebook picture size'),
@@ -178,7 +178,7 @@ function fbconnect_appearance_settings(&
     '#description' => t('This will set the picture size when viewing a user\'s profile page. If your user decides to use his facebook picture, choose its size here.'),
     '#default_value' => variable_get('fbconnect_pic_size_profile', 'small'),
     '#options' => $options_pic_size,
-  );  
+  );
 
   $form['display']['fbconnect_pic_logo'] = array(
     '#type' => 'checkbox',
@@ -191,35 +191,35 @@ function fbconnect_appearance_settings(&
 }
 
 
-function fbconnect_fbapp_settings(&$form_state) {
+function fbconnect_fbapp_settings($form, &$form_state) {
   if (!facebook_client()) {
     drupal_set_message(t('Ensure that you entered valid api keys.'), 'error');
-    drupal_goto('admin/settings/fbconnect');
+    drupal_goto('admin/config/fbconnect');
   }
-  
+
   if (!fbconnect_get_fbuid()) {
     $button_attr = array('text' => t('Connect with your Facebook account'));
     $form['fbconnect'] = array(
       '#value' => fbconnect_render_button($button_attr),
     );
-    
+
     return $form;
   }
-  
+
   $form['fbconnect_base_domaine'] = array(
     '#type' => 'textfield',
     '#title' => t('Base Domain Url'),
     '#description' => t('Use this to enable your Facebook Connect implementation to span multiple subdomains (e.g., using example.com would enable  www.example.com, foo.example.com or bar.example.com,).'),
     '#default_value' => variable_get('fbconnect_base_domaine', NULL),
   );
-  
+
   $form['fbconnect_connect_url'] = array(
     '#type' => 'textfield',
     '#title' => t('Connect Url'),
     '#description' => t('Your site\'s main URL.'),
     '#default_value' => variable_get('fbconnect_connect_url', $GLOBALS['base_url'] . '/'),
   );
-  
+
   $form['fbconnect_uninstall_url'] = array(
     '#type' => 'textfield',
     '#title' => t('Post-Remove Callback Url'),
@@ -229,7 +229,7 @@ function fbconnect_fbapp_settings(&$form
       url('fbconnect/post-remove', array('absolute' => TRUE))
     ),
   );
-  
+
   $form = system_settings_form($form);
   $form['#submit'][] = 'fbconnect_fbapp_settings_submit';
   return $form;
@@ -241,16 +241,16 @@ function fbconnect_fbapp_settings_submit
     'base_domain'   => $form_state['values']['fbconnect_base_domaine'],
     'uninstall_url' => $form_state['values']['fbconnect_uninstall_url'],
   );
-  
+
   if (!facebook_client()) {
     drupal_set_message(t('Unable to get a facebook client, check your api key'), 'error');
-    return FALSE;  
+    return FALSE;
   }
   if (!fbconnect_get_fbuid()) {
     drupal_set_message(t('Unable to autoconfigure your application settings, make sure you are logged into Facebook'), 'warning');
     return FALSE;
   }
-  
+
   try {
     $res = facebook_client()->api(array(
       'method' => 'admin.setAppProperties',
@@ -264,7 +264,7 @@ function fbconnect_fbapp_settings_submit
     drupal_set_message(t('Checking your facebook session, you are not allowed to change this application settings'), 'error');
   }
   else {
-    drupal_set_message(t('Your facebook app settings has been updated'));      
+    drupal_set_message(t('Your facebook app settings has been updated'));
   }
 }
 
@@ -384,4 +384,4 @@ function _fbconnect_language_codes() {
     'zh_TW' => 'Traditional Chinese (Taiwan)',
     'zu_ZA' => 'Zulu',
   );
-}
\ No newline at end of file
+}
Index: fbconnect.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect.info,v
retrieving revision 1.10.4.1
diff -u -p -r1.10.4.1 fbconnect.info
--- fbconnect.info	24 Aug 2010 14:07:15 -0000	1.10.4.1
+++ fbconnect.info	21 Jan 2011 23:01:24 -0000
@@ -2,5 +2,4 @@
 name = Fbconnect
 description = Allows users to connect with Facebook account
 package = "Authentication"
-core = "6.x"
-version = "6.x-2.x-dev"
\ No newline at end of file
+core = 7.x
Index: fbconnect.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect.install,v
retrieving revision 1.14.4.5
diff -u -p -r1.14.4.5 fbconnect.install
--- fbconnect.install	10 Oct 2010 12:39:10 -0000	1.14.4.5
+++ fbconnect.install	21 Jan 2011 23:01:24 -0000
@@ -2,30 +2,35 @@
 // $Id: fbconnect.install,v 1.14.4.5 2010/10/10 12:39:10 vectoroc Exp $
 
 /**
- * Implementation of hook_requirements().
+ * @file
+ * Install, update and uninstall functions for the fbconnect module.
+ */
+
+/**
+ * Implements hook_requirements().
  */
 function fbconnect_requirements($phase) {
-  $requirements = array(); 
-  $t = get_t(); 
-  
+  $requirements = array();
+  $t = get_t();
+
   if (!function_exists('curl_init')) {
     $requirements['curl']['title'] = $t('cURL library');
     $requirements['curl']['value'] = $t('Not installed');
     $requirements['curl']['severity'] = REQUIREMENT_ERROR;
     $requirements['curl']['description'] = $t('The cURL library is not installed. Please check the <a href="@url">PHP cURL documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/curl.setup.php'));
   }
-  
+
   if (!function_exists('json_decode')) {
     $requirements['json']['title'] = $t('JSON extension');
     $requirements['json']['value'] = $t('Not installed');
     $requirements['json']['severity'] = REQUIREMENT_ERROR;
     $requirements['json']['description'] = $t('The JSON library is not installed. Facebook needs the JSON PHP extension');
   }
-  
+
   if ($phase == 'runtime') {
     drupal_load('module', 'fbconnect');
     _facebook_client_load_include();
-    
+
     $requirements['facebook-php-sdk']['title'] = $t('Facebook PHP sdk');
     if (!class_exists('Facebook')) {
       $requirements['facebook-php-sdk']['value'] = $t('Not installed');
@@ -40,22 +45,22 @@ function fbconnect_requirements($phase) 
     else {
       $requirements['facebook-php-sdk']['value'] = l(constant('Facebook::VERSION'), 'http://github.com/facebook/php-sdk', array('external' => TRUE));
       $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_OK;
-      
-//      $sdk_include_path_1 = drupal_get_path('module', 'fbconnect') .'/facebook-php-sdk/src/facebook.php';
-//      $sdk_include_path_2 = module_invoke('libraries', 'get_path', 'facebook-php-sdk') .'/src/facebook.php';
-//
-//      if (!file_exists($sdk_include_path_1) || !file_exists($sdk_include_path_2)) {
-//        $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_WARNING;
-//        $requirements['facebook-php-sdk']['value'] .= ' '. $t('You installed Facebook PHP sdk in deprecated path. See README.txt');
-//      }      
+
+      //      $sdk_include_path_1 = drupal_get_path('module', 'fbconnect') .'/facebook-php-sdk/src/facebook.php';
+      //      $sdk_include_path_2 = module_invoke('libraries', 'get_path', 'facebook-php-sdk') .'/src/facebook.php';
+      //
+      //      if (!file_exists($sdk_include_path_1) || !file_exists($sdk_include_path_2)) {
+      //        $requirements['facebook-php-sdk']['severity'] = REQUIREMENT_WARNING;
+      //        $requirements['facebook-php-sdk']['value'] .= ' '. $t('You installed Facebook PHP sdk in deprecated path. See README.txt');
+      //      }
     }
-    
+
     if (!fbconnect_get_config()) {
       $requirements['fbconnect_conf'] = array(
         'title' => $t('FBConnect'),
         'value' => $t('Not configured'),
         'severity' => REQUIREMENT_WARNING,
-        'description' => $t('Please ensure that you entered Application ID and Secret Key. !link', array('!link' => l($t('Settings page'), 'admin/settings/fbconnect'))),
+        'description' => $t('Please ensure that you entered Application ID and Secret Key. !link', array('!link' => l($t('Settings page'), 'admin/config/fbconnect'))),
       );
     }
   }
@@ -63,111 +68,133 @@ function fbconnect_requirements($phase) 
   return $requirements;
 }
 
-
 /**
  * @file
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function fbconnect_install() {
-  drupal_install_schema('fbconnect'); 
   _fbconnect_change_user_mail_field();
 }
- 
-/** 
- * Implementation of hook_uninstall(). 
- */ 
-function fbconnect_uninstall() { 
-  drupal_uninstall_schema('fbconnect');
+
+/**
+ * Implements hook_uninstall().
+ */
+function fbconnect_uninstall() {
   _fbconnect_change_user_mail_field('uninstall');
   // Delete our module's variable from the variables table.
   variable_del('fbconnect_appid');
-  variable_del('fbconnect_skey');  
+  variable_del('fbconnect_skey');
   variable_del('fbconnect_base_domaine');
   variable_del('fbconnect_connect_url');
   variable_del('fbconnect_language_code');
   variable_del('fbconnect_debug');
-  
+
   variable_del('fbconnect_fast_reg');
   variable_del('fbconnect_reg_options');
   variable_del('fbconnect_loginout_mode');
   variable_del('fbconnect_invite_msg');
-  variable_del('fbconnect_invite_name');  
+  variable_del('fbconnect_invite_name');
   variable_del('fbconnect_invite_dest');
-  variable_del('fbconnect_button');  
+  variable_del('fbconnect_button');
   variable_del('fbconnect_button_text');
   variable_del('fbconnect_pic_allow');
   variable_del('fbconnect_pic_size');
   variable_del('fbconnect_pic_logo');
 }
 
-/** 
- * Implementation of hook_schema(). 
- */ 
-function fbconnect_schema() { 
-  $schema['fbconnect_users'] = array( 
-    'fields' => array( 
-      'uid'            => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 
-      'fbuid'          => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'big'),
-      'timestamp'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-    ), 
-    'primary key' => array('fbuid'), 
+/**
+ * Implements hook_schema().
+ */
+function fbconnect_schema() {
+  $schema['fbconnect_users'] = array(
+    'fields' => array(
+      'uid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'fbuid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'size' => 'big',
+      ),
+      'timestamp' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'primary key' => array('fbuid'),
   );
-    
-  return $schema; 
+
+  return $schema;
 }
 
 function fbconnect_update_6002() {
-//  variable_set('fbconnect_reg_feed_id', FBCONNECT_REG_FEED_BUNDLEID);
-//  variable_set('fbconnect_com_feed_id', FBCONNECT_COMMENT_FEED_BUNDLEID);
+  //  variable_set('fbconnect_reg_feed_id', FBCONNECT_REG_FEED_BUNDLEID);
+  //  variable_set('fbconnect_com_feed_id', FBCONNECT_COMMENT_FEED_BUNDLEID);
 
-  $ret = array();
-  db_drop_field($ret, 'fbconnect_users', 'import_setting');
-  db_drop_field($ret, 'fbconnect_users', 'avatar');
-  db_drop_field($ret, 'fbconnect_users', 'visibility');
+  db_drop_field('fbconnect_users', 'import_setting');
+  db_drop_field('fbconnect_users', 'avatar');
+  db_drop_field('fbconnect_users', 'visibility');
 
-  return $ret;
+  return t('Remove obsolete database fields.');
 }
 
 /**
- * Alter fbuid field to allow for 64-bit facebook ids
+ * Alter fbuid field to allow for 64-bit facebook ids.
  */
 function fbconnect_update_6003() {
-  $ret = array();
-  db_drop_primary_key($ret, 'fbconnect_users');
-  db_change_field($ret, 'fbconnect_users', 'fbuid', 'fbuid',
-    array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'big'),
+  db_drop_primary_key('fbconnect_users');
+  db_change_field('fbconnect_users', 'fbuid', 'fbuid',
+    array(
+      'type' => 'int',
+      'unsigned' => TRUE,
+      'not null' => TRUE,
+      'default' => 0,
+      'size' => 'big',
+    ),
     array('primary key' => array('fbuid'))
   );
-  return $ret;
+  return t('Allow for 64-bit Facebook IDs.');
 }
 
 function fbconnect_update_6004() {
-  return _fbconnect_change_user_mail_field();
+  _fbconnect_change_user_mail_field();
+  return t('Extend minumum length of emails to 320 chars.');
 }
 
-
 /**
- * delete unnesessary bundle_ids from system table
+ * Delete unnesessary bundle_ids from system table
  */
 function fbconnect_update_6005() {
-  $res = array();
   variable_del('fbconnect_reg_feed_id');
   variable_del('fbconnect_com_feed_id');
-  return $res;
+  return t('Delete obsolete variables.');
 }
 
 function fbconnect_update_6200() {
-  $res = array();
-  $res[] = update_sql("UPDATE {variable} SET name = 'fbconnect_appid' WHERE name = 'fbconnect_key'");
-  $res[] = update_sql('UPDATE {blocks} SET module = "fbconnect_invite" WHERE module = "fbconnect" AND delta = 0');
-  
-  return $res;
+  db_update('variable')
+    ->fields(array('name' => 'fbconnect_appid')
+    ->condition('name', 'fbconnect_key', '=')
+    ->execute();
+  db_update('block')
+    ->fields(array('module' => 'fbconnect_invite')
+    ->condition('module', 'fbconnect_key', '=')
+    ->condition('delta', '0', '=')
+    ->execute();
+
+  return t('Rename fbconnect_key.');
 }
 
 /**
- * Implementation of hook_schema_alter()
+ * Implements hook_schema_alter().
  * @param array $schema
- * @todo remove it / create updating tool 
+ * @todo remove it / create updating tool
  */
 function fbconnect_schema_alter(&$schema) {
   $schema['users']['fields']['mail']['length'] = 320;
@@ -178,7 +205,9 @@ function fbconnect_schema_alter(&$schema
  */
 function _fbconnect_change_user_mail_field($action = 'install') {
   $schema = array('users' => drupal_get_schema('users'));
-  if ($action == 'install') fbconnect_schema_alter($schema);
-  db_change_field($res, 'users', 'mail', 'mail', $schema['users']['fields']['mail']);
+  if ($action == 'install') {
+    fbconnect_schema_alter($schema);
+  }
+  db_change_field('users', 'mail', 'mail', $schema['users']['fields']['mail']);
   return $res;
-}
\ No newline at end of file
+}
Index: fbconnect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect.module,v
retrieving revision 1.32.2.12
diff -u -p -r1.32.2.12 fbconnect.module
--- fbconnect.module	2 Nov 2010 22:17:15 -0000	1.32.2.12
+++ fbconnect.module	21 Jan 2011 23:01:24 -0000
@@ -2,42 +2,42 @@
 // $Id: fbconnect.module,v 1.32.2.12 2010/11/02 22:17:15 vectoroc Exp $
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function fbconnect_menu() {
-  $items['admin/settings/fbconnect'] = array(
-    'title' => 'Facebook Connect', 
-    'page callback' => 'drupal_get_form', 
-    'page arguments' => array('fbconnect_api_keys_settings'), 
+  $items['admin/config/fbconnect'] = array(
+    'title' => 'Facebook Connect',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('fbconnect_api_keys_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'fbconnect.admin.inc',
   );
-  
-  $items['admin/settings/fbconnect/api-keys'] = array(
-    'title' => 'Api Keys', 
-    'type' => MENU_DEFAULT_LOCAL_TASK, 
+
+  $items['admin/config/fbconnect/api-keys'] = array(
+    'title' => 'Api Keys',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
     'file' => 'fbconnect.admin.inc',
   );
-  
-  $items['admin/settings/fbconnect/apperance'] = array(
-    'title' => 'Appearance', 
-    'type' => MENU_LOCAL_TASK, 
-    'page callback' => 'drupal_get_form', 
-    'page arguments' => array('fbconnect_appearance_settings'), 
+
+  $items['admin/config/fbconnect/apperance'] = array(
+    'title' => 'Appearance',
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('fbconnect_appearance_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'fbconnect.admin.inc',
   );
-  
-  $items['admin/settings/fbconnect/fb-app'] = array(
-    'title' => 'App Settings', 
-    'type' => MENU_LOCAL_TASK, 
-    'page callback' => 'drupal_get_form', 
-    'page arguments' => array('fbconnect_fbapp_settings'), 
+
+  $items['admin/config/fbconnect/fb-app'] = array(
+    'title' => 'App Settings',
+    'type' => MENU_LOCAL_TASK,
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('fbconnect_fbapp_settings'),
     'access arguments' => array('administer site configuration'),
     'file' => 'fbconnect.admin.inc',
     'weight' => 3,
   );
-  
+
   $items['user/%user_category/edit/fbconnect'] = array(
     'title' => 'Facebook',
     'page callback' => 'fbconnect_user_identities',
@@ -50,7 +50,7 @@ function fbconnect_menu() {
   );
 
   $items['fbconnect/register/prompt'] = array(
-    'title' => 'Facebook connect',  
+    'title' => 'Facebook connect',
     'page callback' => 'fbconnect_prompt_page',
     'access callback' => 'user_is_anonymous',
     'type' => MENU_CALLBACK,
@@ -71,42 +71,59 @@ function fbconnect_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
-  
+
   $items['fbconnect/link'] = array(
     'page callback' => 'fbconnect_link_callback',
     'access callback' => 'user_is_logged_in',
     'type' => MENU_CALLBACK,
     'file' => 'fbconnect.pages.inc',
   );
-  
+
   return $items;
 }
 
 /**
- * Implementation of hook_theme()
+ * Implements hook_theme().
  */
 function fbconnect_theme() {
   return array(
     'fbconnect_user_picture_override' => array(
-      'arguments' => array('fbuid' => NULL, 'account' => NULL, 'user_url' => NULL, 'size' => '', 'logo' => TRUE),
-      'file'      => 'fbconnect.pages.inc',
+      'variables' => array(
+        'fbuid' => NULL,
+        'account' => NULL,
+        'user_url' => NULL,
+        'size' => '',
+        'logo' => TRUE,
+      ),
+      'file' => 'fbconnect.pages.inc',
     ),
     'fbconnect_login_button' => array(
-      'arguments' => array('text' => '', 'attr' => ''),
+      'variables' => array(
+        'text' => '',
+        'attr' => '',
+      ),
     ),
     'fbconnect_user_profile_tab_connected' => array(
-      'arguments' => array('account' => NULL, 'conf' => NULL, 'uid' => NULL),
-      'file'      => 'fbconnect.pages.inc',
+      'variables' => array(
+        'account' => NULL,
+        'conf' => NULL,
+        'uid' => NULL,
+      ),
+      'file' => 'fbconnect.pages.inc',
     ),
     'fbconnect_user_profile_tab_unconnected' => array(
-      'arguments' => array('account' => NULL, 'conf' => NULL, 'uid' => NULL),
-      'file'      => 'fbconnect.pages.inc',
+      'variables' => array(
+        'account' => NULL,
+        'conf' => NULL,
+        'uid' => NULL,
+      ),
+      'file' => 'fbconnect.pages.inc',
     ),
   );
 }
 
 /**
- * Implementation of hook_init().
+ * Implements hook_init().
  */
 function fbconnect_init() {
   fbconnect_render_js();
@@ -114,13 +131,13 @@ function fbconnect_init() {
   if ($conf && facebook_client() && user_is_anonymous()) {
     if ($conf['loginout_mode'] == 'auto') {
       $fbuid = fbconnect_get_fbuid();
-      if ($fbuid && _is_fbconnect_user($fbuid)) { 
+      if ($fbuid && _is_fbconnect_user($fbuid)) {
         $form_state = array('values' => array('op' => 'connect'));
-        drupal_execute('fbconnect_autoconnect_form', $form_state);
+        drupal_form_submit('fbconnect_autoconnect_form', $form_state);
         drupal_goto($form_state['redirect']);
       }
     }
-  } 
+  }
   // During registration the cache is disabled
   if (arg(0) == 'fbconnect' && arg(1) == 'register') {
     $GLOBALS['conf']['cache'] = FALSE;
@@ -128,22 +145,25 @@ function fbconnect_init() {
 }
 
 /**
- * Implementation of hook_user().
+ * Implements hook_user_cancel().
  */
-function fbconnect_user($op, &$edit, &$user, $category = NULL) {
-  switch ($op) {
-    case 'delete':
-      db_query('DELETE FROM {fbconnect_users} WHERE uid = %d', $user->uid);
-      break;
-    case 'categories':
-      return array(
-        array(
-          'name' => 'fbconnect',
-          'title' => 'Facebook',
-          'weight' => 3,
-        ),
-      );
-  }
+function fbconnect_user_cancel($edit, $account, $method) {
+  db_delete('fbconnect_users')
+    ->condition('uid', $user->uid)
+    ->execute();
+}
+
+/**
+ * Implements hook_user_categories().
+ */
+function fbconnect_user_categories() {
+  return array(
+    array(
+      'name' => 'fbconnect',
+      'title' => 'Facebook',
+      'weight' => 3,
+    ),
+  );
 }
 
 /**
@@ -152,7 +172,7 @@ function fbconnect_user($op, &$edit, &$u
  */
 function fbconnect_redirect_submit($form, &$form_state) {
   global $user;
-  
+
   drupal_get_messages('status');
   $fbuid = fbconnect_get_fbuid();
   if ($fbuid) {
@@ -168,40 +188,40 @@ function fbconnect_redirect_submit($form
       }
     }
   }
-  
-  if ($_REQUEST['destination'] == 'fbconnect/link') {
-    unset($_REQUEST['destination']);
-    $form_state['redirect'] = 'user/'. $user->uid .'/edit/fbconnect';
+
+  if ($_GET['destination'] == 'fbconnect/link') {
+    unset($_GET['destination']);
+    $form_state['redirect'] = 'user/' . $user->uid . '/edit/fbconnect';
   }
 }
 
 /**
- * Impletementation of hook_form_alter().
+ * Implements hook_form_alter().
  */
 function fbconnect_form_alter(&$form, $form_state, $form_id) {
-  
+
   if (isset($form['account'])) {
     $form['account']['mail']['#maxlength'] = 320;
   }
-  
-  switch ($form_id):
+
+  switch ($form_id) :
     case 'user_login':
-      if (@$_REQUEST['destination'] == 'fbconnect/link') {        
+      if (@$_GET['destination'] == 'fbconnect/link') {
         drupal_set_message(t('Please log in, in order to link your account with Facebook Connect'));
         $form['#submit'][] = 'fbconnect_redirect_submit';
       }
       // don't break here since we want to run the next user_login_block case too
 
-    // Render fbconnect on login block.
+      // Render fbconnect on login block.
     case 'user_login_block':
-      if (@$_REQUEST['destination'] != 'fbconnect/link' && facebook_client()) {
-        
+      if (@$_GET['destination'] != 'fbconnect/link' && facebook_client()) {
+
         #848354 : ask user for email permission when account linking is disabled
         $attr = array();
         if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) {
           $attr = array('perms' => 'email');
         }
-        
+
         $form['fbconnect_button'] = array(
           '#type' => 'item',
           '#description' => t('Sign in using Facebook'),
@@ -224,7 +244,7 @@ function fbconnect_form_alter(&$form, $f
         }
       }
       break;
-      
+
   endswitch;
 }
 
@@ -253,43 +273,43 @@ function fbconnect_render_button($attr =
     'background' => 'dark',
     'v'          => 2,
   );
-  
+
   $attr = array_merge($default_attr, $attr);
   $text = $attr['text'];
   unset($attr['text']);
 
-  return theme('fbconnect_login_button', $text, $attr);
+  return theme('fbconnect_login_button', array('text' => $text, 'attr' => $attr));
 }
 
 function _facebook_client_search_paths() {
   return array_filter(array(
-    drupal_get_path('module', 'fbconnect') .'/facebook-php-sdk',
+    drupal_get_path('module', 'fbconnect') . '/facebook-php-sdk',
     module_invoke('libraries', 'get_path', 'facebook-php-sdk'),
-    drupal_get_path('module', 'fbconnect') .'/facebook-client',
+    drupal_get_path('module', 'fbconnect') . '/facebook-client',
     drupal_get_path('module', 'fbconnect'),
     module_invoke('libraries', 'get_path', 'facebook-platform'),
     module_invoke('libraries', 'get_path', 'facebook-client'),
   ));
-} 
+}
 
 function _facebook_client_load_include() {
   if (!class_exists('Facebook')) {
-    $lib_paths = _facebook_client_search_paths(); 
-    
+    $lib_paths = _facebook_client_search_paths();
+
     foreach ($lib_paths as $dir) {
       $lib_paths[] = $dir . '/php';
       $lib_paths[] = $dir . '/src';
     }
-    
+
     foreach ($lib_paths as $path) {
       $client_include = $path . '/facebook.php';
       if (file_exists($client_include)) {
-        include_once($client_include);
+        include_once DRUPAL_ROOT . '/' . $client_include;
         break;
       }
     }
   }
-  
+
   return class_exists('Facebook') && defined('Facebook::VERSION');
 }
 
@@ -300,24 +320,24 @@ function _facebook_client_load_include()
  */
 function facebook_client() {
   static $fb = NULL;
-  
+
   if (is_null($fb)) {
     $conf = fbconnect_get_config();
-    
+
     if ($conf && _facebook_client_load_include()) {
       $initParams = array(
         'appId'  => $conf['app_id'],
         'secret' => $conf['secret_api_key'],
         'cookie' => TRUE,
       );
-      
+
       $fb = new Facebook($initParams);
       // hack for #902542
       Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
       Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
     }
   }
-  
+
   return $fb;
 }
 
@@ -329,25 +349,25 @@ function facebook_client() {
 function fbconnect_get_config() {
   global $base_url;
   static $config;
-  
+
   if (!$config) {
     $config['user_pictures'] = variable_get('fbconnect_pic_allow', 'allow');
     $config['language_code'] = variable_get('fbconnect_language_code', 'en_US');
-    
+
     $config['app_id'] = variable_get('fbconnect_appid', NULL);
     $config['secret_api_key'] = variable_get('fbconnect_skey', NULL);
     $config['debug'] = variable_get('fbconnect_debug', FALSE);
     $config['connect_js'] = "document.location.protocol + '//connect.facebook.net/$config[language_code]/all.js'";
-    
+
     if (module_exists('i18n')) {
       global $language;
-      $switch_code = variable_get('fbconnect_language_code_'. $language->language, '');
+      $switch_code = variable_get('fbconnect_language_code_' . $language->language, '');
 
       if ($switch_code) {
         $config['language_code'] = $switch_code;
       }
-    }    
-    
+    }
+
     $config['loginout_mode'] = variable_get('fbconnect_loginout_mode', 'manual');
     $config['invite_name'] = variable_get('fbconnect_invite_name', variable_get('site_name', $base_url));
     $config['fast_reg_mode'] = variable_get('fbconnect_fast_reg', NULL);
@@ -355,7 +375,7 @@ function fbconnect_get_config() {
     // allow third party modules to change settings
     drupal_alter('fbconnect_config', $config);
   }
-  
+
   if ($config['app_id'] && $config['secret_api_key']) {
     return $config;
   }
@@ -363,7 +383,7 @@ function fbconnect_get_config() {
 
 /**
  * Check facebook session.
- * 
+ *
  * @param boolean $check_connected
  *   ensure that active user is connected with active facebook account
  *
@@ -372,18 +392,18 @@ function fbconnect_get_config() {
  */
 function fbconnect_get_fbuid($check_connected = FALSE) {
   global $user;
-  
+
   $client = facebook_client();
 
   if ($client && $session = $client->getSession()) {
     $fbuid = $session['uid'];
-    
+
     if ($check_connected && $fbuid) {
-      if (_get_user_fbuid($user->uid) != $fbuid) { 
-        $fbuid = NULL; 
+      if (_get_user_fbuid($user->uid) != $fbuid) {
+        $fbuid = NULL;
       }
     }
-    
+
     return $fbuid;
   }
 }
@@ -394,9 +414,9 @@ function fbconnect_get_fbuid($check_conn
 function fbconnect_render_js() {
   global $base_url;
   global $user;
-  
+
   $module_path = drupal_get_path('module', 'fbconnect');
-  
+
   if ($config = fbconnect_get_config()) {
     unset($config['secret_api_key']);
     $config['fbuid'] = fbconnect_get_fbuid();
@@ -404,19 +424,19 @@ function fbconnect_render_js() {
       'uid'   => $user->uid,
       'fbuid' => @$user->fbuid,
     );
-    drupal_add_js(array('fbconnect' => $config), 'setting');
+    drupal_add_js(array('fbconnect' => $config), array('type' => 'setting', 'scope' => JS_DEFAULT));
     drupal_add_js($module_path . '/fbconnect.js');
     drupal_add_css($module_path . '/fbconnect.css');
   }
 }
 
 /**
- * Implementation of hook_footer().
+ * Implements hook_footer().
  */
 function fbconnect_footer() {
   if (facebook_client()) {
     $config = fbconnect_get_config();
-    $footer = array();    
+    $footer = array();
     $footer['fb-init-code'] = <<<CODE
       <div id="fb-root"></div>
       <script type="text/javascript">
@@ -428,10 +448,10 @@ function fbconnect_footer() {
             xfbml  : true,
             logging: '$config[debug]'
           });
-          
+
           jQuery(document).trigger('fb:init');
         };
-      
+
         (function() {
           var e = document.createElement('script');
           e.src = $config[connect_js];
@@ -450,9 +470,9 @@ CODE;
       // Display the autoconnect form.
       $footer['autoconnect-form'] = '<div style="display: none">' . drupal_get_form('fbconnect_autoconnect_form') . '</div>';
     }
-    
-//    drupal_alter('fbconnect_footer', $footer);
-    
+
+    //    drupal_alter('fbconnect_footer', $footer);
+
     return join("\n", $footer);
   }
 }
@@ -460,16 +480,16 @@ CODE;
 /**
  * This form is submitted by javascript when facebook session is detected.
  */
-function fbconnect_autoconnect_form() {
+function fbconnect_autoconnect_form($form) {
   $form['#id'] = 'fbconnect-autoconnect-form';
-  
-  if (arg(0) == 'user' && in_array(arg(1), array('login', 'register', 'password')) && !isset($_REQUEST['destination'])) {
+
+  if (arg(0) == 'user' && in_array(arg(1), array('login', 'register', 'password')) && !isset($_GET['destination'])) {
     $form['#action'] = url('user');
   }
   else {
     $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
   }
-  
+
   $form['connect'] = array(
     '#type'   => 'submit',
     '#value'  => 'Connect',
@@ -479,31 +499,31 @@ function fbconnect_autoconnect_form() {
 }
 
 function fbconnect_autoconnect_form_submit($form, &$form_state) {
-  $fbuid = fbconnect_get_fbuid();  
+  $fbuid = fbconnect_get_fbuid();
   if (!$fbuid) {
-    $error_msg = 'fbconnect_autoconnect_form_submit has been called without valid facebook session. ' 
+    $error_msg = 'fbconnect_autoconnect_form_submit has been called without valid facebook session. '
                . 'Check your Application Secret on fbconnect settings page';
-               
-    watchdog('fbconnect', $error_msg, array(), WATCHDOG_ALERT, l(t('configure'), 'admin/settings/fbconnect'));
-    return ;
+
+    watchdog('fbconnect', $error_msg, array(), WATCHDOG_ALERT, l(t('configure'), 'admin/config/fbconnect'));
+    return;
   }
-  
+
   if (user_is_anonymous()) {
     if ($fbuid) {
       $uid = _is_fbconnect_user($fbuid);
       $form_state['values']['uid']   = $uid;
       $form_state['values']['fbuid'] = $fbuid;
-      
+
       if (!$uid) {
         if (variable_get('fbconnect_reg_options', 0) == 1) {
-          $form_state['redirect'] = array( 'fbconnect/register/create', drupal_get_destination() );
+          $form_state['redirect'] = array('fbconnect/register/create', drupal_get_destination() );
         }
         else {
-          $form_state['redirect'] = array( 'fbconnect/register/prompt', drupal_get_destination() );
+          $form_state['redirect'] = array('fbconnect/register/prompt', drupal_get_destination() );
         }
-        
+
         #805846 : No linking with FB page appears, when "destination" variable exist in url
-        unset($_REQUEST['destination']);
+        unset($_GET['destination']);
       }
       elseif ($uid) {
         $account = user_load($uid);
@@ -526,26 +546,26 @@ function fbconnect_autoconnect_form_subm
  */
 function _is_fbconnect_user($fbuid) {
   if ($fbuid) {
-    $query = <<<SQL
-      SELECT u.uid FROM {users} u 
-      INNER JOIN {fbconnect_users} f ON u.uid = f.uid 
-      WHERE fbuid = '%s'
-SQL;
-    return db_result(db_query($query, $fbuid));
+    $query = db_select('users', 'u')
+      ->fields('u', 'uid')
+      ->innerJoin('fbconnect_users', 'f', 'u.uid = f.uid')
+      ->condition('fbuid', $fbuid)
+      ->execute();
+    return $query->fetchField();
   }
 }
 
 /**
  * Returns fbuid by uid
- * 
+ *
  * @param Int $uid
  *   Drupal user id
  * @return Int $fbuid
  */
-function _get_user_fbuid($uid) { 
+function _get_user_fbuid($uid) {
   if ($uid) {
     $query = "SELECT fbuid FROM {fbconnect_users} where uid = %d";
-    return db_result(db_query($query, $uid));
+    return db_query($query, $uid)->fetchField();
   }
 }
 
@@ -558,28 +578,43 @@ function _get_user_fbuid($uid) { 
  *   Facebook user id
  */
 function fbconnect_register($uid, $fbuid) {
-  if (_get_user_fbuid($uid)) return FALSE;
-  if (_is_fbconnect_user($fbuid)) return FALSE;
-  
+  if (_get_user_fbuid($uid)) {
+    return FALSE;
+  }
+  if (_is_fbconnect_user($fbuid)) {
+    return FALSE;
+  }
+
   $delete_query = 'DELETE FROM {fbconnect_users} WHERE uid = %d';
-  $insert_query = 'INSERT INTO {fbconnect_users} (uid, fbuid, timestamp) VALUES (%d, \'%s\', %d)';  
-  
-  db_query($delete_query, $uid);
-  if (db_query($insert_query, $uid, $fbuid, time())) {
+  $insert_query = 'INSERT INTO {fbconnect_users} (uid, fbuid, timestamp) VALUES (%d, \'%s\', %d)';
+
+  db_delete('fbconnect_users')
+    ->condition('uid', $uid)
+    ->execute();
+
+  $id = db_insert('fbconnect_users')
+    ->fields(array(
+      'uid' => $uid,
+      'fbuid' => $fbuid,
+      'timestamp' => REQUEST_TIME,
+    ))
+    ->execute();
+
+  if ($id) {
     $account = user_load($uid);
     $account->fbuid = $fbuid;
-    
+
     user_save($account, array('fbuid' => $fbuid));
     module_invoke('rules', 'invoke_event', 'fbconnect_user_registered', $account);
-     
+
     watchdog(
-      'fbconnect', 
+      'fbconnect',
       'User has connected his Facebook account (@fbuid)',
       array('@fbuid' => $fbuid),
       WATCHDOG_NOTICE,
       l(t('edit'), "user/$uid/edit/fbconnect")
     );
-    
+
     return TRUE;
   }
   return FALSE;
@@ -587,7 +622,7 @@ function fbconnect_register($uid, $fbuid
 
 /**
  * Remove user from table fbconnect
- * 
+ *
  * @param Int $fbuid
  *   Facebook user id
  * @return boolean
@@ -596,7 +631,7 @@ function fbconnect_unregister($fbuid) {
   if (!facebook_client()) {
     return FALSE;
   }
-  
+
   if ($fbuid && $uid = _is_fbconnect_user($fbuid)) {
     try {
       try {
@@ -615,29 +650,31 @@ function fbconnect_unregister($fbuid) {
       $args = array('@code' => $e->getMessage());
       watchdog('fbconnect', $msg, $args, WATCHDOG_ERROR);
     }
-        
-    db_query('DELETE FROM {fbconnect_users} WHERE fbuid = %s', $fbuid);
+
+    db_delete('fbconnect_users')
+      ->condition('fbuid', $fbuid)
+      ->execute();
     $account = user_load($uid);
     $account->fbuid = NULL;
-    
+
     user_save($account, array('fbuid' => NULL));
     module_invoke('rules', 'invoke_event', 'fbconnect_user_unregistered', $account);
-    
+
     watchdog(
-      'fbconnect', 
-      "Users authorization is revoked (fbuid: @fbuid)", 
+      'fbconnect',
+      "Users authorization is revoked (fbuid: @fbuid)",
       array('@fbuid' => $fbuid),
       WATCHDOG_NOTICE,
       l(t('edit'), "user/$uid/edit/fbconnect")
     );
-    
+
     return TRUE;
   }
-  
+
   $msg = __FUNCTION__ . ' is called with wrong $fbuid(@fbuid) argument ';
   watchdog('fbconnect', $msg, array('@fbuid' => $fbuid), WATCHDOG_ERROR);
-  
-  return FALSE; 
+
+  return FALSE;
 }
 
 /**
@@ -663,7 +700,7 @@ function fbconnect_fql_query($query) {
     try {
       try {
         return facebook_client()->api($params);
-      } 
+      }
       catch (FacebookApiException $e) {
         drupal_set_message($e->getMessage(), 'error');
         throw $e;
@@ -673,7 +710,7 @@ function fbconnect_fql_query($query) {
       $msg = 'Exception thrown while using fbconnect_fql_query : @code';
       watchdog('fbconnect', $msg, array('@code' => $e->getMessage()), WATCHDOG_WARNING);
     }
-  }  
+  }
 }
 
 /**
@@ -687,7 +724,7 @@ function fbconnect_graph_query($path, $p
     try {
       try {
         return facebook_client()->api($path, $params);
-      } 
+      }
       catch (FacebookApiException $e) {
         drupal_set_message($e->getMessage(), 'error');
         throw $e;
@@ -697,7 +734,7 @@ function fbconnect_graph_query($path, $p
       $msg = 'Exception thrown while using fbconnect_graph_query : @code';
       watchdog('fbconnect', $msg, array('@code' => $e->getMessage()), WATCHDOG_WARNING);
     }
-  }  
+  }
 }
 
 
@@ -708,11 +745,11 @@ function fbconnect_graph_query($path, $p
  */
 function fbconnect_get_user_info($fields = array(), $fbuid = null) {
   $params = array();
-  
+
   if (!$fbuid) {
     $fbuid = fbconnect_get_fbuid();
   }
-  
+
   if (is_array($fields) && count($fields)) {
     $params['fields'] = join(',', $fields);
   }
@@ -721,7 +758,7 @@ function fbconnect_get_user_info($fields
   }
 
   if ($fbuid) {
-    return fbconnect_graph_query("/". $fbuid, $params);
+    return fbconnect_graph_query("/" . $fbuid, $params);
   }
 }
 
@@ -737,7 +774,7 @@ function fbconnect_get_info_from_fb($fbu
 }
 
 /**
- * Implementation of hook_theme_registry_alter().
+ * Implements hook_theme_registry_alter().
  *
  * Override theme functions for things that can be displayed using
  * XFBML.  Currently overriding user_picture.  We rename
@@ -771,10 +808,10 @@ function fbconnect_theme_user_picture_ov
   elseif (variable_get('fbconnect_pic_size', '')) {
     // Default user picture preset.
     $preset = variable_get('fbconnect_pic_size', 'square');
-  } 
-  
+  }
+
   if (!isset($account->fbuid)) {
-    $user_data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
+    $user_data = unserialize(db_query('SELECT data FROM {users} WHERE uid = :uid', array(':uid' => $account->uid))->fetchField());
     $account->fbuid     = @$user_data['fbuid'];
     $account->fb_avatar = @$user_data['fb_avatar'];
   }
@@ -783,10 +820,10 @@ function fbconnect_theme_user_picture_ov
   $user_url = url('user/' . $account->uid);
 
   if ($fbuid && $account->fb_avatar) {
-    $output = theme('fbconnect_user_picture_override', $fbuid, $account, $user_url, variable_get('fbconnect_pic_size', $preset), variable_get('fbconnect_pic_logo', TRUE));
-  } 
-  else {  
-    $output = theme('fbconnect_user_picture_orig', $account); // Markup without fb_connect.
+    $output = theme('fbconnect_user_picture_override', array('fbuid' => $fbuid, 'account' => $account, 'user_url' => $user_url, 'size' => variable_get('fbconnect_pic_size', $preset), 'logo' => variable_get('fbconnect_pic_logo', TRUE)));
+  }
+  else {
+    $output = theme('fbconnect_user_picture_orig', array('account' => $account)); // Markup without fb_connect.
   }
 
   return $output;
@@ -794,25 +831,24 @@ function fbconnect_theme_user_picture_ov
 }
 
 /**
- * Implements hook_profile_alter().
+ * Implements hook_user_view().
  * Change the user profile picture to use the preferred fbconnect preset.
  */
-function fbconnect_profile_alter(&$account) {
+function fbconnect_user_view($account, $view_mode) {
   if ($preset = variable_get('fbconnect_pic_size_profile', '')) {
     $account->fbconnect_picture_preset = $preset;
-    $account->content['user_picture']['#value'] = theme('user_picture', $account);
+    $account->content['user_picture']['#value'] = theme('user_picture', array('account' => $account));
   }
 }
 
 /**
- * Implements hook_comment().
- * Change comment user pictures to use the preferred fbconnect preset.
+ * Implements hook_comment_view().
  */
-function fbconnect_comment(&$comment, $op) {
-  if ($op == 'view' && theme_get_setting('toggle_comment_user_picture')) {
+function fbconnect_comment_view($comment) {
+  if (TRUE && theme_get_setting('toggle_comment_user_picture')) {
     // If this is a comment preview, we need to manually add $comment->picture.
     if (!empty($comment->uid) && !isset($comment->picture)) {
-      $comment->picture = db_result(db_query("SELECT picture FROM {users} WHERE uid = %d", $comment->uid));
+      $comment->picture = db_query("SELECT picture FROM {users} WHERE uid = :uid", array(':uid' => $comment->uid))->fetchField();
     }
     if ($preset = variable_get('fbconnect_pic_size_comments', '')) {
       $comment->fbconnect_picture_preset = $preset;
@@ -821,37 +857,45 @@ function fbconnect_comment(&$comment, $o
 }
 
 /**
- * Implements hook_nodeapi().
- * Change node user pictures to use the preferred fbconnect preset.
+ * Implements hook_node_view().
  */
-function fbconnect_nodeapi(&$node, $op) {
-  // Panels module uses $op = alter to render nodes.
-  if ($op == 'view' || $op == 'alter') {
-    if ($preset = variable_get('fbconnect_pic_size_nodes', '')) {
-      $node->fbconnect_picture_preset = $preset;
-    }
+function fbconnect_node_view($node, $view_mode = 'full') {
+  if ($preset = variable_get('fbconnect_pic_size_nodes', '')) {
+    $node->fbconnect_picture_preset = $preset;
+  }
+}
+
+/**
+ * Implements hook_node_build_alter().
+ */
+function fbconnect_node_build_alter($build) {
+  if ($preset = variable_get('fbconnect_pic_size_nodes', '')) {
+    $node->fbconnect_picture_preset = $preset;
   }
- }
+}
+
 
 /**
  * The post-remove callback for facebook. Unlinks facebook account
  * from the linked drupal one.
  */
 function fbconnect_post_remove_callback() {
-//  if ($fb = facebook_client()) {
-//    $fbuid = $fb->get_loggedin_user(); // TODO: update outdated code
-//    if ($fbuid && $fb->fb_params['uninstall'] == 1) {
-//      //The user has removed your app
-//      fbconnect_unregister($fbuid);
-//      watchdog(
-//        'fbconnect', 
-//        "User with fbuid @fbuid has revoked authorization", 
-//        array('@fbuid' => $fbuid)
-//      );
-//    }
-//  }
-}
-
-function theme_fbconnect_login_button($text, $attr) {
+  //  if ($fb = facebook_client()) {
+  //    $fbuid = $fb->get_loggedin_user(); // TODO: update outdated code
+  //    if ($fbuid && $fb->fb_params['uninstall'] == 1) {
+  //      //The user has removed your app
+  //      fbconnect_unregister($fbuid);
+  //      watchdog(
+  //        'fbconnect',
+  //        "User with fbuid @fbuid has revoked authorization",
+  //        array('@fbuid' => $fbuid)
+  //      );
+  //    }
+  //  }
+}
+
+function theme_fbconnect_login_button($variables) {
+  $text = $variables['text'];
+  $attr = $variables['attr'];
   return '<fb:login-button ' . drupal_attributes($attr) . '>' . $text . '</fb:login-button>';
-}
\ No newline at end of file
+}
Index: fbconnect.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect.pages.inc,v
retrieving revision 1.22.4.9
diff -u -p -r1.22.4.9 fbconnect.pages.inc
--- fbconnect.pages.inc	2 Nov 2010 22:17:15 -0000	1.22.4.9
+++ fbconnect.pages.inc	21 Jan 2011 23:01:24 -0000
@@ -1,23 +1,17 @@
 <?php
 // $Id: fbconnect.pages.inc,v 1.22.4.9 2010/11/02 22:17:15 vectoroc Exp $
 
-/** 
- * @file 
- * User pages callbacks for the fbconnect module. 
- */ 
+/**
+ * @file
+ * User pages callbacks for the fbconnect module.
+ */
 
 /**
  * Menu callback.
  * Called when user perform facebook registration
  */
 function fbconnect_prompt_page() {
-  $links = fbconnect_prompt_page_links();
-  $output = array();
-  foreach ($links as $link) {
-    array_push($output, theme('box', $link));
-  }
-
-  return join("\n", $output);   
+  return theme('links', array('links' => fbconnect_prompt_page_links()));
 }
 
 function fbconnect_prompt_page_links() {
@@ -34,32 +28,42 @@ function fbconnect_prompt_page_links() {
       'onclick' => 'Drupal.fbconnect.DoFastRegistration(this); return false;'
     ));
   }
-  
-  $reg_choice  = l($reg_msg, 'fbconnect/register/create', $reg_attr);
-  $link_choice = l($link_msg, 'user', array('query' => 'destination=fbconnect/link'));
-  
-  return array($reg_choice, $link_choice);
+
+  $links = array(
+    array(
+      'title' => $reg_msg,
+      'href' => 'fbconnect/register/create',
+      $reg_attr,
+    ),
+    array(
+      'title' => $link_msg,
+      'href' => 'user',
+      array('query' => 'destination=fbconnect/link'),
+    ),
+  );
+
+  return $links;
 }
 
 /**
  * Menu callback.
  * Called when user perform facebook registration
  */
-function fbconnect_register_page($form_state = array()) {
+function fbconnect_register_page($form, $form_state = array()) {
   $conf  = fbconnect_get_config();
-  $data  = fbconnect_get_user_info('name, email');    
+  $data  = fbconnect_get_user_info('name, email');
   $form  = drupal_retrieve_form('user_register', $form_state);
   $site  = $conf['invite_name'];
-  
+
   // #758918 : prevent users registration if admin has blocked free registration
   $user_reg_mode = variable_get('user_register', 1);
   if ($user_reg_mode == 0) {
     drupal_access_denied();
     return;
   }
-  
-  drupal_prepare_form('user_register', $form, $form_state);   
-  
+
+  drupal_prepare_form('user_register', $form, $form_state);
+
   $form['name']['#default_value'] = $data['name'];
 
   $form['fbconnect'] = array(
@@ -72,17 +76,17 @@ function fbconnect_register_page($form_s
     '#title' => t('Let my Facebook friends see me on @sitename', array('@sitename' => $site)),
     '#default_value' => 1,
   );
-  
+
   if (variable_get('user_pictures', 0) && $conf['user_pictures'] == 'allow') {
     $form['fbconnect']['fb_avatar'] = array(
       '#type' => 'checkbox',
       '#title' => t('Use my Facebook picture as user picture'),
       '#description' => t('Your picture will be loaded from facebook.'),
       '#default_value' => 1,
-    );  
+    );
   }
-  $form['#redirect'] = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
-  $form['#submit'][] = 'fbconnect_register_form_submit';  
+  $form_state['#redirect'] = isset($_GET['destination']) ? $_GET['destination'] : '';
+  $form['#submit'][] = 'fbconnect_register_form_submit';
 
   // Fast registration mode, we by pass std drupal reg form.
   if ($conf['fast_reg_mode']) {
@@ -92,7 +96,7 @@ function fbconnect_register_page($form_s
     $form_state['values']['status']     = 1;
     $form_state['values']['fb_visible'] = 1;
     $form_state['values']['fb_avatar']  = 1;
-    
+
     drupal_validate_form('user_register', $form, $form_state);
     $success = !form_get_errors();
     if (!$success) {
@@ -103,14 +107,14 @@ function fbconnect_register_page($form_s
       foreach ($messages['error'] as $message) {
         drupal_set_message( $message, 'error');
       }
-      
+
       drupal_goto('user/register', $dest['query']);
     }
-    
+
     fbconnect_register_form_submit($form, $form_state);
     drupal_goto();
   }
-    
+
   return $form;
 }
 
@@ -122,24 +126,24 @@ function fbconnect_register_form_submit(
     watchdog('fbconnect', 'Error creating account for @fbuid', array('@fbuid' => $fbuid), WATCHDOG_ALERT);
     drupal_goto();
   }
-   
+
   if (variable_get('fbconnect_fast_reg', NULL)) {
     $user = user_save(NULL, $form_state['values']);
   }
   else {
-    $user = $form_state['user'];    
+    $user = $form_state['user'];
   }
-  
+
   if (!$user) {
     drupal_set_message(t("Error saving user account."), 'error');
     drupal_goto();
   }
-  
-  fbconnect_register($user->uid, $fbuid);  
+
+  fbconnect_register($user->uid, $fbuid);
   $data['fb_avatar']  = $form_state['values']['fb_avatar'];
   $data['fb_visible'] = $form_state['values']['fb_visible'];
-  
-  user_save($user, $data);   
+
+  user_save($user, $data);
   user_external_login($user);
   $_SESSION['fbconnect_feed']['type'] = 'register';
 }
@@ -151,17 +155,17 @@ function fbconnect_user_identities($acco
   $conf  = fbconnect_get_config();
   $fbuid = fbconnect_get_fbuid();
   $uid   = _is_fbconnect_user($fbuid);
-  
-  drupal_set_title(check_plain($account->name));
-  
-  if ($account->fbuid) { 
+
+  drupal_set_title($account->name);
+
+  if ($account->fbuid) {
     return drupal_get_form('fbconnect_user_settings_form', $account);
   }
   elseif ($uid && $account->uid != $uid) {
-    return theme('fbconnect_user_profile_tab_connected', $account, $conf, $uid);
+    return theme('fbconnect_user_profile_tab_connected', array('account' => $account, 'conf' => $conf, 'uid' => $uid));
   }
   else {
-    return theme('fbconnect_user_profile_tab_unconnected', $account, $conf, $uid);
+    return theme('fbconnect_user_profile_tab_unconnected', array('account' => $account, 'conf' => $conf, 'uid' => $uid));
   }
 }
 
@@ -170,10 +174,10 @@ function fbconnect_user_identities($acco
  *
  *  Some options are visible only if facebook session is active.
  */
-function fbconnect_user_settings_form($form_state, $account) {
+function fbconnect_user_settings_form($form, $form_state, $account) {
   $conf = fbconnect_get_config();
-  // These fields manage the visibility of the user, 
-  // if the option is enabled, user's facebook friends 
+  // These fields manage the visibility of the user,
+  // if the option is enabled, user's facebook friends
   // will be able to see his presence on this site
   $form['fb_visible'] = array(
     '#type' => 'checkbox',
@@ -182,7 +186,7 @@ function fbconnect_user_settings_form($f
     '#default_value' => $account->fb_visible,
   );
 
-  // Whether user picture is enabled, 
+  // Whether user picture is enabled,
   // users can choose to use his facebook avatar as avatar
   if ($conf['user_pictures'] == 'allow') {
     $form['fb_avatar'] = array(
@@ -191,41 +195,41 @@ function fbconnect_user_settings_form($f
       '#default_value' => $account->fb_avatar,
     );
   }
-  
+
   if (!variable_get('user_pictures', 0)) {
     $form['fb_avatar']['#attributes'] = array(
       'disabled' => 'disabled',
     );
     $form['fb_avatar']['#description'] = t('Enable user picture support in !link', array(
       '!link' => l(t('User settings'), 'admin/user/settings'),
-    ));    
+    ));
   }
-  
+
   $form['account'] = array(
     '#type'  => 'value',
     '#value' => $account,
-  ); 
-  
+  );
+
   $form['fbconnect'] = array(
     '#title' => t('Facebook account'),
     '#type' => 'fieldset',
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
   );
-  
+
   $form['fbconnect']['profile'] = array(
     '#type' =>  'item',
     '#title' => t('Linked to this Facebook account'),
-    '#value' => '<fb:name uid="'. $account->fbuid .'" useyou="false" linked="true"></fb:name>',
+    '#value' => '<fb:name uid="' . $account->fbuid . '" useyou="false" linked="true"></fb:name>',
   );
-  
+
   $form['fbconnect']['unlink'] = array(
     '#type' => 'submit',
     '#description' => t('Click here to unlink this Facebook account'),
     '#value' => t('Unlink'),
     '#access' => !!facebook_client(), // don't show unlink button if fbconnect is'nt properly configured
-  ); 
-  
+  );
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save settings'),
@@ -234,28 +238,28 @@ function fbconnect_user_settings_form($f
 }
 
 /**
- * Handle post-validation user_settingsForm submission. 
+ * Handle post-validation user_settingsForm submission.
  */
 function fbconnect_user_settings_form_submit($form, &$form_state) {
-  $account = $form_state['values']['account']; 
+  $account = $form_state['values']['account'];
   $visible = $form_state['values']['visibility'];
   $avatar  = $form_state['values']['fb_avatar'];
   $op      = $form_state['values']['op'];
   $fbuid   = $account->fbuid;
-  
+
   $data['fb_visible'] = $form_state['values']['fb_visible'];
   $data['fb_avatar']  = $form_state['values']['fb_avatar'];
-  
+
   if ($op == $form['fbconnect']['unlink']['#value']) {
     if (fbconnect_unregister($fbuid)) {
       $data['fb_visible'] = NULL;
-      $data['fb_avatar'] = NULL;      
+      $data['fb_avatar'] = NULL;
     }
     else {
       form_set_error('fbconnect', t("Something went wrong. Can't unlink account"));
     }
   }
-  
+
   if ($data) {
     user_save($account, $data);
   }
@@ -265,33 +269,39 @@ function fbconnect_user_settings_form_su
 /**
  * Make rendering of facebook user picture themeable
  */
-function theme_fbconnect_user_picture_override($fbuid = '', $account = NULL, $user_url = '', $size = 'square', $logo = TRUE) {
+function theme_fbconnect_user_picture_override($variables) {
+  $fbuid = $variables['fbuid'];
+  $account = $variables['account'];
+  $user_url = $variables['user_url'];
+  $size = $variables['size'];
+  $logo = $variables['logo'];
   $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
-  $output = <<<PIC
-    <div class="picture">
-      <a href="$user_url">
-        <img src="$protocol://graph.facebook.com/$fbuid/picture?type=$size" />
-      </a>
-    </div>
-PIC;
-  return $output;
+  $path = $protocol . '://graph.facebook.com/' . $fbuid . ' /picture?type=' . $size;
+  $image = theme('image', array('path' => $path)); 
+  return '<div class="picture">' . l($image, $path, array('html' => TRUE)) . '</div>';
 }
 
 
 /**
  * Make rendering of facebook user profile tab themable
  */
-function theme_fbconnect_user_profile_tab_connected($account = NULL, $conf = NULL, $uid = NULL) {
+function theme_fbconnect_user_profile_tab_connected($variables) {
+  $account = $variables['account'];
+  $conf = $variables['conf'];
+  $uid = $variables['uid'];
   $site_name = $conf['invite_name'] ? $conf['invite_name'] : '';
   return t(
     "Your current Facebook session is associated to another account on our site.\n"
-   ."You can logout of Facebook and attempt to associate another Facebook account to your"
-   ."!site_name account, or you need to disconnect the current association."
+   . "You can logout of Facebook and attempt to associate another Facebook account to your"
+   . "!site_name account, or you need to disconnect the current association."
    , array('!site_name' => $site_name)
   );
 }
 
-function theme_fbconnect_user_profile_tab_unconnected($account = NULL, $conf = NULL, $uid = NULL) {
+function theme_fbconnect_user_profile_tab_unconnected($variables) {
+  $account = $variables['account'];
+  $conf = $variables['conf'];
+  $uid = $variables['uid'];
   return '<div>'
        . t('Click here to connect your Facebook account')
        . '</div><div class="fbconnect-button">'
@@ -300,10 +310,10 @@ function theme_fbconnect_user_profile_ta
 }
 
 /**
- * Workaround to play nice with LoginDestination #786662 
+ * Workaround to play nice with LoginDestination #786662
  */
 function fbconnect_link_callback() {
   global $user;
   drupal_get_messages('status');
   drupal_goto("user/{$user->uid}/edit/fbconnect");
-}
\ No newline at end of file
+}
Index: fbconnect.rules.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/Attic/fbconnect.rules.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 fbconnect.rules.inc
--- fbconnect.rules.inc	24 Aug 2010 14:07:15 -0000	1.1.2.1
+++ fbconnect.rules.inc	21 Jan 2011 23:01:24 -0000
@@ -8,9 +8,8 @@
  * @{
  */
 
-
 /**
- * Implementation of hook_rules_event_info().
+ * Implements hook_rules_event_info().
  */
 function fbconnect_rules_event_info() {
   return array(
@@ -18,21 +17,30 @@ function fbconnect_rules_event_info() {
       'label' => t('User has connected his Facebook Account'),
       'module' => 'fbconnect',
       'arguments' => array(
-        'account' => array('type' => 'user', 'label' => t('granted facebook auth user')),
+        'account' => array(
+          'type' => 'user',
+          'label' => t('granted facebook auth user'),
+        ),
       ),
     ),
     'fbconnect_user_unregistered' => array(
       'label' => t('User has disconnected his Facebook Account'),
       'module' => 'fbconnect',
       'arguments' => array(
-        'account' => array('type' => 'user', 'label' => t('revoked facebook auth user')),
+        'account' => array(
+          'type' => 'user',
+          'label' => t('revoked facebook auth user'),
+        ),
       ),
     ),
     'fbconnect_user_login' => array(
       'label' => t('User has logged in via Facebook'),
       'module' => 'fbconnect',
       'arguments' => array(
-        'account' => array('type' => 'user', 'label' => t('logged in via facebook user')),
+        'account' => array(
+          'type' => 'user',
+          'label' => t('logged in via facebook user'),
+        ),
       ),
     ),
   );
Index: fbconnect_invite/fbconnect_invite.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_invite/Attic/fbconnect_invite.info,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 fbconnect_invite.info
--- fbconnect_invite/fbconnect_invite.info	24 Aug 2010 14:07:15 -0000	1.1.2.1
+++ fbconnect_invite/fbconnect_invite.info	21 Jan 2011 23:01:24 -0000
@@ -2,4 +2,4 @@
 name = Facebook Friends Invite
 dependencies[] = fbconnect
 package = "Facebook Social"
-core = 6.x
\ No newline at end of file
+core = 7.x
Index: fbconnect_invite/fbconnect_invite.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_invite/Attic/fbconnect_invite.module,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 fbconnect_invite.module
--- fbconnect_invite/fbconnect_invite.module	12 Oct 2010 15:07:18 -0000	1.1.2.3
+++ fbconnect_invite/fbconnect_invite.module	21 Jan 2011 23:01:24 -0000
@@ -2,7 +2,7 @@
 // $Id: fbconnect_invite.module,v 1.1.2.3 2010/10/12 15:07:18 vectoroc Exp $
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function fbconnect_invite_menu() {
   $items['fbconnect/invite/friends'] = array(
@@ -12,7 +12,7 @@ function fbconnect_invite_menu() {
     'access arguments' => array('invite facebook friends'),
     'type' => MENU_CALLBACK,
   );
-  
+
   $items['fbconnect/invite/accept/%user'] = array(
     'title' => 'Accept invite',
     'page callback' => 'fbconnect_invite_accept',
@@ -20,104 +20,108 @@ function fbconnect_invite_menu() {
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
-  
-  $items['admin/settings/fbconnect/invite'] = array(
-    'title' => 'Friends Invite', 
-    'page callback' => 'drupal_get_form', 
-    'page arguments' => array('fbconnect_invite_settings'), 
+
+  $items['admin/config/fbconnect/invite'] = array(
+    'title' => 'Friends Invite',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('fbconnect_invite_settings'),
     'access arguments' => array('administer site configuration'),
     'type' => MENU_LOCAL_TASK,
   );
-  
+
   return $items;
 }
 
 /**
- * Implementation of hook_perm()
+ * Implements hook_permission().
  */
-function fbconnect_invite_perm() {
-  return array('invite facebook friends');
+function fbconnect_invite_permission() {
+  return array(
+    'invite facebook friends' => array(
+      'title' => t('invite facebook friends'),
+      'description' => t('Allow users to invite their Facebook friends.'),
+    ),
+  );
 }
 
 /**
- * Implementation of hook_theme()
+ * Implements hook_theme().
  */
 function fbconnect_invite_theme() {
   return array(
     'fbconnect_invite_form' => array(
-      'arguments' => array(
-        'request_form_attributes' => array(), 
-        'friends_selector_attributes' => array(),        
+      'variables' => array(
+        'request_form_attributes' => array(),
+        'friends_selector_attributes' => array(),
       ),
     ),
   );
 }
 
 /**
- * Implementation of hook_block().
+ * Implements hook_block_info().
  */
-function fbconnect_invite_block($op = 'list', $delta = 0, $edit = array()) {
-  switch ($op) {
-    case 'list':
-      $blocks[0]['info']  = t('Facebook Friends');
-      $blocks[0]['cache'] = BLOCK_NO_CACHE;
-      return $blocks;
-
-    case 'view':
-      $fbuid  = fbconnect_get_fbuid(TRUE);
-      if (user_is_logged_in() && $fbuid) {
-        $cid    = 'fbconnect:'. $fbuid;
-        $cached = cache_get($cid, 'cache_block');
-         
-        if ($cached->data) {
-          $content = $cached->data;
-        }
-        else {
-          $friends = fbconnect_get_connected_friends($fbuid);
-          if ($friends) {
-            foreach ($friends as $friend) {
-              $row[] = theme('username', $friend);
-            }
-            $content = theme('item_list', $row);
-            cache_set($cid, $content, 'cache_block' , time() + 3600);
-          }
-        }
-        
-        $link_options = array();
-        if (!drupal_is_front_page()) {
-          $link_options = array('query' => drupal_get_destination());
-        }
-        $invite_link = l(t('Invite Friends'), 'fbconnect/invite/friends', $link_options);
+function fbconnect_invite_block_info() {
+  $blocks['facebook_friends']['info']  = t('Facebook Friends');
+  $blocks['facebook_friends']['cache'] = BLOCK_NO_CACHE;
+  return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function fbconnect_invite_block_view($delta) {
+  $fbuid  = fbconnect_get_fbuid(TRUE);
+  if (user_is_logged_in() && $fbuid) {
+    $cid    = 'fbconnect:' . $fbuid;
+    $cached = cache_get($cid, 'cache_block');
 
-        $blocks['subject'] = t('Facebook Friends');
-        $blocks['content'] = $invite_link . $content;
-        return $blocks;
+    if ($cached->data) {
+      $content = $cached->data;
+    }
+    else {
+      $friends = fbconnect_get_connected_friends($fbuid);
+      if ($friends) {
+        foreach ($friends as $friend) {
+          $row[] = theme('username', array('account' => $friend));
+        }
+        $content = theme('item_list', array('items' => $row));
+        cache_set($cid, $content, 'cache_block', REQUEST_TIME + 3600);
       }
-      break;
+    }
+
+    $link_options = array();
+    if (!drupal_is_front_page()) {
+      $link_options = array('query' => drupal_get_destination());
+    }
+    $invite_link = l(t('Invite Friends'), 'fbconnect/invite/friends', $link_options);
+
+    $blocks['subject'] = t('Facebook Friends');
+    $blocks['content'] = $invite_link . $content;
+    return $blocks;
   }
 }
 
-
 /**
  * Render the facebook friends invite form.
  */
 function fbconnect_invite_friends_page() {
   global $base_url;
   global $user;
-  
-  $site = variable_get('site_name', $base_url);  
+
+  $site = variable_get('site_name', $base_url);
   $type = check_plain(variable_get('fbconnect_invite_name', $site));
   $join_btn = check_plain(variable_get('fbconnect_invite_label', t('Become a Member!')));
   $invite_msg = check_plain(variable_get('fbconnect_invite_msg', t('Enjoy!')));
   $action_txt = check_plain(t('Please select the Facebook friends you want to invite'));
-  $invite_dest = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : ''; 
-  $accept_url  = url('fbconnect/invite/accept/'. $user->uid, array(
-    'absolute' => TRUE, 
-    'query' => 'destionation='. urlencode($invite_dest)
+  $invite_dest = isset($_GET['destination']) ? $_GET['destination'] : '';
+  $accept_url  = url('fbconnect/invite/accept/' . $user->uid, array(
+    'absolute' => TRUE,
+    'query' => array('destination' => urlencode($invite_dest)),
   ));
-  
+
   $content = "$invite_msg <fb:req-choice url=\"$accept_url\" label=\"$join_btn\" />";
-             
+
   $request_form_attributes = array(
     'method'  => 'POST',
     'action'  => url($invite_dest, array('absolute' => TRUE)),
@@ -125,7 +129,7 @@ function fbconnect_invite_friends_page()
     'content' => $content,
     'invite'  => TRUE,
   );
-  
+
   $friends_selector_attributes = array(
     'cols' => "6",
     'rows' => "6",
@@ -134,11 +138,13 @@ function fbconnect_invite_friends_page()
     'actiontext' => $action_txt,
     'bypass' => "cancel",
   );
-  
-  return theme('fbconnect_invite_form', $request_form_attributes, $friends_selector_attributes);
+
+  return theme('fbconnect_invite_form', array('request_form_attributes' => $request_form_attributes, 'friends_selector_attributes' => $friends_selector_attributes));
 }
 
-function theme_fbconnect_invite_form($request_form_attributes, $friends_selector_attributes) {
+function theme_fbconnect_invite_form($variables) {
+  $request_form_attributes = $variables['request_form_attributes'];
+  $friends_selector_attributes = $variables['friends_selector_attributes'];
   $request_form_attr    = drupal_attributes($request_form_attributes);
   $friend_selector_attr = drupal_attributes($friends_selector_attributes);
 
@@ -187,50 +193,53 @@ function fbconnect_get_connected_friends
       }
 
       if ($fbid) {
-        $res = db_query('SELECT uid FROM {fbconnect_users} WHERE fbuid IN ('. implode($fbid, ',') .')');
-        while ($uid = db_result($res)) {
+        $res = db_select('fbconnect_users', 'f')
+          ->fields('f', 'uid')
+          ->condition('fbuid', implode($fbid, ','), 'IN')
+          ->execute();
+        while ($uid = $res->fetchField()) {
           $user = user_load($uid);
           if ($user->fb_visible) {
             $friends[] = $user;
           }
         }
-         
+
         return $friends;
       }
     }
   }
 }
 
-function fbconnect_invite_settings() {
+function fbconnect_invite_settings($form, &$form_state) {
   $form['fbconnect_invite_msg'] = array(
     '#type' => 'textfield',
-    '#title' => t('Invite message'),      
+    '#title' => t('Invite message'),
     '#default_value' => variable_get('fbconnect_invite_msg', t('Enjoy facebook connect')),
   );
-  
+
   $form['fbconnect_invite_label'] = array(
     '#type' => 'textfield',
-    '#title' => t('Invite button label'),      
+    '#title' => t('Invite button label'),
     '#default_value' => variable_get('fbconnect_invite_label', t('Become a Member!')),
   );
-  
+
   $form['fbconnect_invite_name'] = array(
     '#type' => 'textfield',
-    '#title' => t('Your site name'),      
+    '#title' => t('Your site name'),
     '#default_value' => variable_get('fbconnect_invite_name', variable_get('site_name', NULL)),
   );
-  
-// TODO: remove it
-//  $form['fbconnect_invite_dest'] = array(
-//    '#type' => 'textfield',
-//    '#title' => t('Destination, after user\'s valid or skip invite friend form'),
-//    '#default_value' => variable_get('fbconnect_invite_dest', $base_url),
-//  );
-//  
+
+  // TODO: remove it
+  //  $form['fbconnect_invite_dest'] = array(
+  //    '#type' => 'textfield',
+  //    '#title' => t('Destination, after user\'s valid or skip invite friend form'),
+  //    '#default_value' => variable_get('fbconnect_invite_dest', $base_url),
+  //  );
+  //
   return system_settings_form($form);
 }
 
 function fbconnect_invite_accept($inviter) {
   module_invoke('rules', 'invoke_event', 'fbconnect_invite_accepted', $inviter);
-  drupal_goto();  
-}
\ No newline at end of file
+  drupal_goto();
+}
Index: fbconnect_invite/fbconnect_invite.rules.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_invite/Attic/fbconnect_invite.rules.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 fbconnect_invite.rules.inc
--- fbconnect_invite/fbconnect_invite.rules.inc	6 Oct 2010 17:22:59 -0000	1.1.2.1
+++ fbconnect_invite/fbconnect_invite.rules.inc	21 Jan 2011 23:01:24 -0000
@@ -8,9 +8,8 @@
  * @{
  */
 
-
 /**
- * Implementation of hook_rules_event_info().
+ * Implements hook_rules_event_info().
  */
 function fbconnect_invite_rules_event_info() {
   return array(
@@ -18,7 +17,10 @@ function fbconnect_invite_rules_event_in
       'label' => t('Invitee User has accepted the invite'),
       'module' => 'fbconnect_invite',
       'arguments' => array(
-        'inviter' => array('type' => 'user', 'label' => t('inviter')),
+        'inviter' => array(
+          'type' => 'user',
+          'label' => t('inviter'),
+        ),
       ),
     ),
   );
Index: fbconnect_stream_publish/fbconnect_stream_publish.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_stream_publish/Attic/fbconnect_stream_publish.info,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 fbconnect_stream_publish.info
--- fbconnect_stream_publish/fbconnect_stream_publish.info	24 Aug 2010 14:07:15 -0000	1.1.2.1
+++ fbconnect_stream_publish/fbconnect_stream_publish.info	21 Jan 2011 23:01:24 -0000
@@ -1,4 +1,4 @@
 ; $Id: fbconnect_stream_publish.info,v 1.1.2.1 2010/08/24 14:07:15 vectoroc Exp $
 name =  Facebook Steam Publish
 package = "Facebook Social"
-core = 6.x
\ No newline at end of file
+core = 7.x
Index: fbconnect_stream_publish/fbconnect_stream_publish.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_stream_publish/Attic/fbconnect_stream_publish.install,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 fbconnect_stream_publish.install
--- fbconnect_stream_publish/fbconnect_stream_publish.install	12 Oct 2010 15:07:18 -0000	1.1.2.2
+++ fbconnect_stream_publish/fbconnect_stream_publish.install	21 Jan 2011 23:01:24 -0000
@@ -2,14 +2,19 @@
 // $Id: fbconnect_stream_publish.install,v 1.1.2.2 2010/10/12 15:07:18 vectoroc Exp $
 
 /**
- * Implementation of hook_update_6201().
+ * @file
+ * Install, update and uninstall functions for the fbconnect_stream_publish module.
+ */
+
+/**
+ * Implements hook_update_6201().
  *
  * Change content type activation variable
  */
 function fbconnect_stream_publish_update_6201() {
   $ret = array();
 
-  foreach (array_keys(node_get_types('names')) as $type_name) {
+  foreach (array_keys(node_type_get_names()) as $type_name) {
     //Old variable format variable_get('fbconnect_' . $form['#node_type']->type . '_onoff', 0)
     $old_format = 'fbconnect_' . $type_name . '_onoff';
     $new_format = 'fbconnect_stream_publish_onoff_' . $type_name;
@@ -20,15 +25,18 @@ function fbconnect_stream_publish_update
       variable_del($old_format);
     }
   }
-  // Delete any old existing variable
-  db_query("DELETE FROM {variable} WHERE name LIKE 'fbconnect\_%\_onoff'");
+  db_delete('variable')
+    ->condition('name', 'fbconnect\_%\_onoff', 'LIKE')
+    ->execute();
 
-  return $ret;
+  return t('Convert old variable formats.');
 }
 
 /**
- * Implement hook_uninstall().
+ * Implements hook_uninstall().
  */
 function fbconnect_stream_publish_uninstall() {
-  db_query("DELETE FROM {variable} WHERE name LIKE 'fbconnect\_stream\_publish\_onoff\_%'");
-}
\ No newline at end of file
+  db_delete('variable')
+    ->condition('name', 'fbconnect\_stream\_publish\_onoff\_%', 'LIKE')
+    ->execute();
+}
Index: fbconnect_stream_publish/fbconnect_stream_publish.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fbconnect/fbconnect_stream_publish/Attic/fbconnect_stream_publish.module,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 fbconnect_stream_publish.module
--- fbconnect_stream_publish/fbconnect_stream_publish.module	12 Oct 2010 15:07:18 -0000	1.1.2.6
+++ fbconnect_stream_publish/fbconnect_stream_publish.module	21 Jan 2011 23:01:24 -0000
@@ -17,24 +17,30 @@ function fbconnect_stream_publish_init()
 }
 
 /**
- * Impletementation of hook_theme(). 
+ * Impletementation of hook_theme().
  */
 function fbconnect_stream_publish_theme() {
   return array(
     'stream_publish_favicon' => array(
-      'arguments' => array(),
+      'variables' => array(),
     ),
   );
 }
 
 /**
- * Implementation of hook_nodeapi()
+ * Implements hook_node_validate().
  */
-function fbconnect_stream_publish_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  if ($op == 'validate' && isset($a3['form_id']['#post']['fbconnect_feed'])) {
+function fbconnect_stream_publish_node_validate($node, $form) {
+  if (isset($a3['form_id']['#post']['fbconnect_feed'])) {
     $_SESSION['fbconnect_feed']['submit'] = TRUE;
   }
-  if ($op == 'insert' && $_SESSION['fbconnect_feed']['submit'] === TRUE) {
+}
+
+/**
+ * Implements hook_node_insert().
+ */
+function fbconnect_stream_publish_node_insert($node) {
+  if ($_SESSION['fbconnect_feed']['submit'] === TRUE) {
     $_SESSION['fbconnect_feed'] = array(
       'type'    => 'node',
       'title'   => $node->title,
@@ -44,6 +50,11 @@ function fbconnect_stream_publish_nodeap
 }
 
 /**
+ * Implements hook_nodeapi().
+ */
+function fbconnect_stream_publish_nodeapi_OLD(&$node, $op, $a3 = NULL, $a4 = NULL) { }
+
+/**
  * Impletementation of hook_form_alter().
  */
 function fbconnect_stream_publish_form_alter(&$form, &$form_state, $form_id) {
@@ -64,17 +75,17 @@ function fbconnect_stream_publish_form_a
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
     );
-    
+
     $form['fbconnect_stream_publish']['fbconnect_feed'] = array(
       '#type' => 'checkbox',
-      '#title' => $favicon .' '. t('Publish to Facebook'),
+      '#title' => $favicon . ' ' . t('Publish to Facebook'),
       '#default_value' => 1,
     );
-  };
+  }
 }
 
 /**
- * Implementation of hook_form_FORM_ID_alter() for comment_form
+ * Implements hook_form_FORM_ID_alter() for comment_form().
  */
 function fbconnect_stream_publish_form_comment_form_alter(&$form, &$form_state) {
   // Facebook feed checkbox on comment form.
@@ -93,14 +104,14 @@ function fbconnect_stream_publish_form_c
       $favicon = theme('stream_publish_favicon');
       $form['fbconnect_stream_publish']['fbconnect_feed'] = array(
         '#type' => 'checkbox',
-        '#title' => $favicon .' '. t('Publish to Facebook'),
+        '#title' => $favicon . ' ' . t('Publish to Facebook'),
         '#default_value' => 1,
         '#weight' => 9,
       );
-      
+
       if (module_exists('ajax_comments')) {
         $form['submit']['#submit'][] = 'fbconnect_stream_publish_comment_feed_submit';
-        drupal_add_js(drupal_get_path('module', 'fbconnect_stream_publish') .'/fbconnect_stream_publish.js');
+        drupal_add_js(drupal_get_path('module', 'fbconnect_stream_publish') . '/fbconnect_stream_publish.js');
       }
       else {
         $form['#submit'][] = 'fbconnect_stream_publish_comment_feed_submit';
@@ -110,7 +121,7 @@ function fbconnect_stream_publish_form_c
 }
 
 /**
- * Implementation of hook_form_FORM_ID_alter() for node_type_form
+ * Implements hook_form_FORM_ID_alter() for node_type_form().
  */
 function fbconnect_stream_publish_form_node_type_form_alter(&$form, &$form_state) {
   // admin settings for enabling/disabling the ability to publish to Facebook, per node type
@@ -134,11 +145,11 @@ function fbconnect_stream_publish_form_n
 }
 
 /**
- *  Implement CCK's hook_content_extra_fields().
+ * Implements hook_content_extra_fields().
  */
 function fbconnect_stream_publish_content_extra_fields($type_name) {
   $extra = array();
-  if (variable_get('fbconnect_'. $type_name .'_onoff', 0)) {
+  if (variable_get('fbconnect_' . $type_name . '_onoff', 0)) {
     $extra['fbconnect_stream_publish'] = array(
       'label' => t('Facebook Connect'),
       'description' => t('Facebook Connect Confirmation'),
@@ -161,7 +172,7 @@ function fbconnect_stream_publish_commen
       'title'   => $node->title,
       'nodeurl' => url('node/' . $node->nid, array('absolute' => TRUE)),
     );
-    
+
     if (module_exists('ajax_comments')) {
       fbconnect_stream_publish_render_js($feed);
     }
@@ -177,7 +188,7 @@ function fbconnect_stream_publish_commen
  */
 function fbconnect_stream_publish_render_js($feed) {
   global $base_url;
-  
+
   $site = variable_get('site_name', $base_url);
 
   switch ($feed['type']) {
@@ -232,17 +243,16 @@ function fbconnect_stream_publish_render
    * @see http://developers.facebook.com/docs/reference/rest/stream.publish
    * @see http://developers.facebook.com/docs/guides/attachments
    */
-  $method = 'stream.publish';    
+  $method = 'stream.publish';
   $user_message_prompt = t('Share your thoughts');
   $streamPublishArgs = compact('method', 'message', 'attachment', 'action_links', 'user_message_prompt');
-    
-//  drupal_alter('fbconnect_stream_publish', $streamPublishArgs);
-  drupal_add_js(array('FB.streamPublish' => $streamPublishArgs), 'setting');
-  drupal_add_js(drupal_get_path('module', 'fbconnect_stream_publish') .'/fbconnect_stream_publish.js');
+
+  //  drupal_alter('fbconnect_stream_publish', $streamPublishArgs);
+  drupal_add_js(array('FB.streamPublish' => $streamPublishArgs), array('type' => 'setting', 'scope' => JS_DEFAULT));
+  drupal_add_js(drupal_get_path('module', 'fbconnect_stream_publish') . '/fbconnect_stream_publish.js');
 }
 
 function theme_stream_publish_favicon() {
   $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
-
-  return '<img src="'. $protocol .'facebook.com/images/connect_favicon.png" />';
-}
\ No newline at end of file
+  return '<img src="' . $protocol . 'facebook.com/images/connect_favicon.png" />';
+}
