Index: gigya.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gigya/Attic/gigya.admin.inc,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 gigya.admin.inc
--- gigya.admin.inc	18 Feb 2010 16:00:10 -0000	1.1.2.22
+++ gigya.admin.inc	15 Mar 2010 03:24:37 -0000
@@ -31,7 +31,7 @@
 define('GIGYA_DEFAULT_LOGINUI_COLOR_CAPTION_TEXT', '#FFFFFF');
 define('GIGYA_DEFAULT_LOGINUI_COLOR_BUTTON_TEXT', '#3A3A3A');
 define('GIGYA_DEFAULT_LOGINUI_COLOR_BACKGROUND_TRANSPARENT', TRUE);
-define('GIGYA_DEFAULT_LOGINUI_CONTAINERID', 'divConnect');
+define('GIGYA_DEFAULT_LOGINUI_CONTAINERID', 'divGigyaLogin');
 define('GIGYA_DEFAULT_FRIENDSUI_WIDTH', '360');
 define('GIGYA_DEFAULT_FRIENDSUI_HEIGHT', '400');
 define('GIGYA_DEFAULT_FRIENDSUI_COLOR_BACKGROUND', 'Transparent');
@@ -47,10 +47,10 @@
 define('GIGYA_DEFAULT_FRIENDSUI_SHOWCAPTION', FALSE);
 define('GIGYA_DEFAULT_FRIENDSUI_CAPTIONTEXT', 'Select Friends');
 define('GIGYA_DEFAULT_FRIENDSUI_LINKTITLE', 'View Site');
-define('GIGYA_DEFAULT_CONNECTUI_WIDTH', '360');
-define('GIGYA_DEFAULT_CONNECTUI_HEIGHT', '400');
+define('GIGYA_DEFAULT_CONNECTUI_WIDTH', '175');
+define('GIGYA_DEFAULT_CONNECTUI_HEIGHT', '65');
 define('GIGYA_DEFAULT_CONNECTUI_COLOR_BACKGROUND', 'Transparent');
-define('GIGYA_DEFAULT_CONNECTUI_COLOR_FRAME', '#DFDFDF');
+define('GIGYA_DEFAULT_CONNECTUI_COLOR_FRAME', '#FFFFFF');
 define('GIGYA_DEFAULT_CONNECTUI_COLOR_TEXT', '#3A3A3A');
 define('GIGYA_DEFAULT_CONNECTUI_COLOR_LINK', '#0066CC');
 define('GIGYA_DEFAULT_CONNECTUI_COLOR_NAVIGATION_ARROW', '#79BCFD');
@@ -67,7 +67,7 @@
 define('GIGYA_DEFAULT_SHARE_UI_LINK_TITLE', 'Share UI title');
 define('GIGYA_DEFAULT_SHARE_UI_SUBJECT', 'Share UI: A site recommendation for you');
 define('GIGYA_DEFAULT_SHARE_UI_MESSAGE', 'Share UI: I wanted to recommend this site <br/>to you. I enjoy it and think you will like it.');
-define('GIGYA_DEFAULT_LOGINUI_FBCONNECT', FALSE);
+define('GIGYA_DEFAULT_LOGINUI_FBCONNECT', TRUE);
 /**
  *
  */
@@ -115,98 +115,15 @@
     '#weight' => -100,
   );
 
-  /*
-  $form['posting'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Socialize status update options'),
-    '#description' => t('Users with social networks that allow status updates will
-                        be able to send updates when they create new content. Status updates
-                        in this case will be sent from the Node Add or Node Edit form itself.
-                        For Popup notifications you must configure an Action and Trigger.
-                        Newsfeeds can only be configured through Actions and Triggers.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#weight' => -2,
-  );
-  $form['posting']['gigya_status_types'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Node types for Status updates'),
-    '#options' => node_get_types('names'),
-    '#default_value' => variable_get('gigya_status_types', array('story' => 'story', 'blog' => 'blog')),
-  );
-  $form['posting']['gigya_default_format'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Default format string'),
-    '#maxlength' => 140,
-    '#description' => t('The given text will be posted to your social networks. You can use !url, !url-alias, !tinyurl, !title, and !user as replacement text.'),
-    '#default_value' => variable_get('gigya_default_format', 'New post: !title !tinyurl'),
-  );
-  
-  */
-  
-  /*
-  $form['share_ui'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Share UI settings'),
-    '#description' => t('Set which node types will have the Share UI functionality enabled.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#weight' => -10,
-  );
-
-  
-  $form['share_ui']['gigya_share_ui_link_title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Link text for "Share UI"'),
-    '#default_value' => variable_get('gigya_share_ui_link_title', GIGYA_DEFAULT_SHARE_UI_LINK_TITLE),
-  );  
-  
-  $form['share_ui']['gigya_share_ui_types'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Node types for "Share UI"'),
-    '#options' => node_get_types('names'),
-    '#default_value' => variable_get('gigya_share_types', array('story' => 'story', 'blog' => 'blog')),
-  );
-  $form['share_ui']['gigya_share_ui_message'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Suggested message for "Share UI"'),
-    '#default_value' => variable_get('gigya_share_ui_message', GIGYA_DEFAULT_SHARE_UI_MESSAGE),
-  );
-   */
-  
-  /*
-  
-  $form['sharing'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Share with a friend settings'),
-    '#description' => t('Set which node types will have the Share with Friends functionality enabled.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#weight' => -5,
-  );
-  
-  
-  $form['sharing']['gigya_share_link_title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Link text for "share with friends"'),
-    '#default_value' => variable_get('gigya_share_link_title', GIGYA_DEFAULT_SHARE_LINK_TITLE),
-  );
-    
-    
-  
-  $form['sharing']['gigya_share_types'] = array(
+   $form['gigya_requiredCapabilities'] = array(
     '#type' => 'checkboxes',
-    '#title' => t('Node types for "Share with a friend"'),
-    '#options' => node_get_types('names'),
-    '#default_value' => variable_get('gigya_share_types', array('story' => 'story', 'blog' => 'blog')),
-  );
-  $form['sharing']['gigya_share_message'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Suggested message for "Share with a friend"'),
-    '#default_value' => variable_get('gigya_share_message', GIGYA_DEFAULT_SHARE_MESSAGE),
+    '#title' => t('Required services for socialize'),
+    '#default_value' => variable_get('gigya_requiredCapabilities', array('login'=>'login')),
+    '#options' => $capabilities,
+    '#description' => t('Choose which capabilities you wish to enable when users connect to social networks.  Usually you should only check "login".'),
+    '#weight' => -8,
   );
   
-   */
   $form['login_uiconfig'] = array(
     '#type' => 'fieldset',
     '#title' => t('Parameters for Login UIConfig'),
@@ -227,21 +144,17 @@
     '#description' => t('Checking this option will enable users to login with their Social Network credentials and map those to the same Drupal user.'),
   );  
   
-  //display 'user register' options here to make it easier for site admins
-  $form['login_uiconfig']['user_register'] = array(
-    '#type' => 'radios', '#title' => t('Public Registration Settings'),
-    '#default_value' => variable_get('user_register', 1),
-    '#options' => array(
-      t('Only socialize or administrators can create new accounts.'),
-      t('Visitors can create accounts outside of socialize and no administrator approval is required.'),
-      t('Visitors can create accounts outside of socialize but administrator approval is required.')
-    ),
-    '#description' => t('Used in conjunction with the surpress login option above,
-                        you can effectively disable users from creating accounts
-                        unless they use socialize. Note, all socialize users will
-                        get automatically approved to use the site. Do not use
-                        socialize if the site is not for public registrants!'),
+  $form['login_uiconfig']['gigya_login_uiconfig_terms'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show terms link'),
+    '#default_value' => variable_get('gigya_login_uiconfig_terms', false),
+    '#description' => t('Display the Gigya terms of service link'),
   );
+  $form['login_uiconfig']['gigya_login_uiconfig_branding'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Hide Gigya branding'),
+    '#default_value' => variable_get('gigya_login_uiconfig_branding',true)
+  );  
   $form['login_uiconfig']['gigya_login_uiconfig_title'] = array(
     '#type' => 'textfield',
     '#title' => t('Login UI Title'),
@@ -346,13 +259,7 @@
     '#required' => TRUE,    
   );
   
-  /*$form['login_uiconfig']['login_advanced']['gigya_login_advanced_facebookconnect'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use facebook connect for facebook users?'),
-    '#default_value' => variable_get('gigya_login_advanced_facebookconnect', GIGYA_DEFAULT_LOGINUI_FBCONNECT),
-    '#description' => t('It is recommended to use facebook connect, !connect',
-                        array('!connect' => l('but you must follow these steps first to configure it', 'http://wiki.gigya.com/030_Gigya_Socialize_API_2.0/020_Socialize_Setup/10_Opening_a_Facebook_External_Application'))),
-  );  */
+
   $form['login_uiconfig']['login_advanced']['gigya_login_advanced_raw'] = array(
     '#type' => 'textarea',
     '#title' => t('Login UIConfig Advanced coding (Overwrites above settings)'),
@@ -362,148 +269,32 @@
   );
   
   
-  /*
-//friends UI
-  $form['friends_uiconfig'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Parameters for friends UIConfig'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_showCaption'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show caption?'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_showCaption', GIGYA_DEFAULT_FRIENDSUI_SHOWCAPTION),
-    '#description' => t('Uncheck to disable caption.'),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_captionText'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Friends UI Caption'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_captionText', GIGYA_DEFAULT_FRIENDSUI_CAPTIONTEXT),
-    '#description' => t('Leave blank for no title.'),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_link_title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Friends UI URL title'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_link_title', GIGYA_DEFAULT_FRIENDSUI_LINKTITLE),
-    '#description' => t('Leave blank to echo the raw url, otherwise put some text like "view site".'),
-  );  
-  
-  $form['friends_uiconfig']['gigya_friends_uiconfig_width'] = array(
-    '#type' => 'textfield',
-    '#title' => t('UI Box Width'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_width', GIGYA_DEFAULT_FRIENDSUI_WIDTH),
-    '#description' => t('Select width for Friends Box'),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_height'] = array(
-    '#type' => 'textfield',
-    '#title' => t('UI Box Height'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_height', GIGYA_DEFAULT_FRIENDSUI_HEIGHT),
-    '#description' => t('Select height for Friends Box'),
-  );
-  /**
-   * Colors for the loginUI. If colorpicker module is enabled, we'll use that instead.
-   */
-  /*
-  $color_field_type = (function_exists('colorpicker_2_or_later') ? 'colorpicker_' : '') .'textfield';
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_background'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Background'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_background', GIGYA_DEFAULT_FRIENDSUI_COLOR_BACKGROUND),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_background_transparent'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Transparent Background'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_background_transparent', GIGYA_DEFAULT_FRIENDSUI_COLOR_BACKGROUND_TRANSPARENT),
-    '#attributes' => array(
-      'onClick' => 'getElementById("edit-gigya-friends-uiconfig-color-background").value="";',
-    ),
-  );
-  
-  
-  if (variable_get('gigya_friends_uiconfig_color_background_transparent', GIGYA_DEFAULT_FRIENDSUI_COLOR_BACKGROUND_TRANSPARENT)) {
-    variable_set('gigya_friends_uiconfig_color_background', '');
-  }
-  */
-  
-  /*
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_frame'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Frame'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_frame', GIGYA_DEFAULT_FRIENDSUI_COLOR_FRAME),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_text'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Text'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_text', GIGYA_DEFAULT_FRIENDSUI_COLOR_TEXT),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_link'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Link'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_link', GIGYA_DEFAULT_FRIENDSUI_COLOR_LINK),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_navigation_arrow'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Navigation Arrow'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_navigation_arrow', GIGYA_DEFAULT_FRIENDSUI_COLOR_NAVIGATION_ARROW),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_caption_background'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Caption Background'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_caption_background', GIGYA_DEFAULT_FRIENDSUI_COLOR_CAPTION_BACKGROUND),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_caption_text'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Caption Text'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_caption_text', GIGYA_DEFAULT_FRIENDSUI_COLOR_CAPTION_TEXT),
-  );
-  $form['friends_uiconfig']['gigya_friends_uiconfig_color_button_text'] = array(
-    '#type' => $color_field_type,
-    '#title' => t('Button Text'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_color_button_text', GIGYA_DEFAULT_FRIENDSUI_COLOR_BUTTON_TEXT),
-  );
-  $form['friends_uiconfig']['friends_advanced'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Advanced friendsUI Settings'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#weight' => 2,
-  );
-  $form['friends_uiconfig']['friends_advanced']['gigya_friends_uiconfig_containerID'] = array(
-    '#type' => 'textfield',
-    '#title' => t('FriendsUI container ID:'),
-    '#default_value' => variable_get('gigya_friends_uiconfig_containerID', GIGYA_DEFAULT_FRIENDSUI_CONTAINERID),
-    '#description' => t('div ID for loginUI'),
-  );
-  $form['friends_uiconfig']['friends_advanced']['gigya_friends_advanced_raw'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Friends UIConfig Advanced coding (Overwrites above settings)'),
-    '#default_value' => variable_get('gigya_friends_advanced_raw', ''),
-    '#description' => t('Use this textbox to put in your own settings. If you are not using this box, make sure it is empty!'),
-  );
-  
-  */
+ 
   //connect UI
   $form['connect_uiconfig'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Parameters for editConnections UIConfig'),
+    '#title' => t('Parameters for Connect UIConfig'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
-  $form['connect_uiconfig']['gigya_connect_requiredCapabilities'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Required services for socialize connect'),
-    '#default_value' => variable_get('gigya_connect_requiredCapabilities', array("login" => "login", "notifications" => "notifications", "friends" => "friends", "status" => "status")),
-    '#options' => $capabilities,
-    '#description' => t('Choose which capabilities you wish to enable users when connecting to social networks'),
-    '#weight' => -8,
-  );
+
   $form['connect_uiconfig']['gigya_connect_uiconfig_captionText'] = array(
     '#type' => 'textfield',
     '#title' => t('ConnectUI Caption'),
     '#default_value' => variable_get('gigya_connect_uiconfig_captionText', GIGYA_DEFAULT_CONNECTUI_CAPTIONTEXT),
     '#description' => t('Leave blank for no title.'),
   );
+  $form['connect_uiconfig']['gigya_connect_uiconfig_terms'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show terms link'),
+    '#default_value' => variable_get('gigya_connect_uiconfig_terms', false),
+    '#description' => t('Display the Gigya terms of service link'),
+  );
+  $form['connect_uiconfig']['gigya_connect_uiconfig_branding'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Hide Gigya branding'),
+    '#default_value' => variable_get('gigya_connect_uiconfig_branding',true)
+  );  
   $form['connect_uiconfig']['gigya_connect_uiconfig_width'] = array(
     '#type' => 'textfield',
     '#title' => t('UI Box Width'),
@@ -518,7 +309,7 @@
   );
 
   /**
-   * Colors for the loginUI. If colorpicker module is enabled, we'll use that instead.
+   * Colors for the lconnectUI. If colorpicker module is enabled, we'll use that instead.
    */
   $color_field_type = (function_exists('colorpicker_2_or_later') ? 'colorpicker_' : '') .'textfield';
   $form['connect_uiconfig']['gigya_connect_uiconfig_color_background'] = array(
@@ -574,28 +365,28 @@
   );
   $form['connect_uiconfig']['connect_advanced'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Advanced editConnectionsUI Settings'),
+    '#title' => t('Advanced ConnectUI Settings'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
     '#weight' => 2,
   );
   $form['connect_uiconfig']['connect_advanced']['gigya_connect_uiconfig_containerID'] = array(
     '#type' => 'textfield',
-    '#title' => t('editconnectionsUI container ID:'),
+    '#title' => t('connectUI container ID:'),
     '#default_value' => variable_get('gigya_connect_uiconfig_containerID', GIGYA_DEFAULT_CONNECTUI_CONTAINERID),
     '#description' => t('div ID for connectUI'),
   );
-  $form['connect_uiconfig']['connect_advanced']['gigya_connect_advanced_raw'] = array(
+  $form['connect_uiconfig']['connect_advanced']['gigya_connect_uiconfig_raw'] = array(
     '#type' => 'textarea',
-    '#title' => t('editconnections UIConfig Advanced coding (Overwrites above settings)'),
-    '#default_value' => variable_get('gigya_connect_advanced_raw', ''),
+    '#title' => t('ConnectUI Advanced coding (Overwrites above settings)'),
+    '#default_value' => variable_get('gigya_connect_uiconfig_raw', ''),
     '#description' => t('Use this textbox to put in your own settings. If you are not using this box, make sure it is empty!'),
   );
   //we need to disable email verification, so the user just logs in.
-  $form['user_email_verification'] = array('#type' => 'value', '#value' => FALSE);
-  $form['user_mail_register_no_approval_required_notify'] = array('#type' => 'value', '#value' => TRUE);
+  //$form['user_email_verification'] = array('#type' => 'value', '#value' => FALSE);
+  //$form['user_mail_register_no_approval_required_notify'] = array('#type' => 'value', '#value' => TRUE);
 
-  if (variable_get('user_pictures',0)) {
+  /*if (variable_get('user_pictures',0)) {
     $form['picture'] = array(
       '#type' => 'fieldset',
       '#title' => t('Gigya user profile picture'),
@@ -609,7 +400,7 @@
       '#default_value' => variable_get('gigya_user_picture', FALSE),
       '#description' => t('Checking this option allows users to connect their user picture to their drupal profile picture'),
     );
-  }
+  }*/
   
   if (module_exists('profile')) {
     $form['profile'] = array(
Index: gigya.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gigya/Attic/gigya.inc,v
retrieving revision 1.1.2.23
diff -u -r1.1.2.23 gigya.inc
--- gigya.inc	18 Feb 2010 15:59:51 -0000	1.1.2.23
+++ gigya.inc	15 Mar 2010 03:24:37 -0000
@@ -77,7 +77,8 @@
     'notifications' => 'notifications',
     'friends' => 'friends',
     'status' => 'status',
-    'newsfeed' => 'newsfeed',
+    'photos' => 'photos',
+    'actions'=> 'actions'
   );
   return $services;
 }
Index: gigya.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gigya/Attic/gigya.js,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 gigya.js
--- gigya.js	18 Feb 2010 16:00:10 -0000	1.1.2.9
+++ gigya.js	15 Mar 2010 03:24:37 -0000
@@ -23,6 +23,23 @@
   };
 };
 
+$.extend({
+  getUrlVars: function(){
+    var vars = [], hash;
+    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+    for(var i = 0; i < hashes.length; i++)
+    {
+      hash = hashes[i].split('=');
+      vars.push(hash[0]);
+      vars[hash[0]] = hash[1];
+    }
+    return vars;
+  },
+  getUrlVar: function(name){
+    return $.getUrlVars()[name];
+  }
+});
+
 Drupal.gigya = {};
 
 /**
@@ -62,6 +79,12 @@
     }    
 }; 
 
+Drupal.gigya.login_callback = function (response) {
+  url_obj = {'signature':response['signature'],'timestamp':response['timestamp'],'UID':response['UID']};
+  new_url = response['context'].destination + '&' + $.param(url_obj);
+  window.location = new_url;
+  //alert(new_url);
+}
 
 /**
  * Callback for the getUserInfo function
Index: gigya.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gigya/Attic/gigya.module,v
retrieving revision 1.1.2.23
diff -u -r1.1.2.23 gigya.module
--- gigya.module	18 Feb 2010 16:00:10 -0000	1.1.2.23
+++ gigya.module	15 Mar 2010 03:51:01 -0000
@@ -144,6 +144,32 @@
   }*/
 }
 
+function gigya_block($op = 'list', $delta = 0, $edit = array()) {
+  if($op == 'list'){
+    return array(array(
+      'info' => t('Gigya login'),
+      'cache' => BLOCK_NO_CACHE
+    ),
+    array(
+      'info' => t('Gigya connectUI'),
+      'cache'=>BLOCK_NO_CACHE));
+  }
+  elseif($op == 'view'){
+    if($delta == 0){
+      return array(
+        'subject' => t('Log in using a social network'),
+        'content' => theme('gigya_login_block',null,true)
+      );
+    }
+    else{
+      return array(
+        'subject' => t('Social network connections'),
+        'content' => theme('gigya_connect_display')
+      );    
+    }
+  }
+}
+
 function gigya_menu_access_user_debug() {
   global $user;
   if (arg(1) == $user->uid)
@@ -154,15 +180,6 @@
  *  Actions and triggers
  */
 function gigya_action_info() {
-  /*$info['gigya_newsfeed_action'] = array(
-    'type' => 'system',
-    'description' => t('Post to Gigya Socialize News Feed'),
-    'configurable' => TRUE,
-    'hooks' => array(
-      'any' => TRUE,
-    ),
-  );  */
-  
   $info['gigya_shareUI_action'] = array(
     'type' => 'system',
     'description' => t('Share UI of Gigya Socialize'),
@@ -176,47 +193,44 @@
 
 function gigya_shareUI_action($object, $context) {
   global $base_path,$user;
-  
-   
  
   module_load_include('inc', 'gigya');
   
-  //if(!($user->setStatus_popup_hide)){
-    $hook = $context['hook'];
-    $_SESSION['shareUI_action'] = $hook;
-    switch ($hook) {
-  	  case 'comment':	    			      	      	   
-  	      $context['node'] = node_load($context[$hook]->nid);	      	        		
-  		  $_SESSION['shareUI_nid'] = $context['node']->nid;
-  		  $_SESSION['shareUI_node'] = $context['node'];
-  		  $_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];	
-  	    break;
-  	  case 'user':
-  		  $context['user'] = user_load($context['account']->uid);    	        		
-  		  $_SESSION['shareUI_uid'] = $context['user']->uid;
-  		  $_SESSION['shareUI_user'] = $context['user'];
-  		  
-  		  if ( $context['op'] ) {
-  		  	if ( $context['op'] == t('update') ) {
-  		  		$_SESSION['shareUI_default_message'] = 'Updated his/her profile';
-  		  	}
-  		  	else {
-  		  		$_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];
-  		  	}
-  		  }
-  		  else {		  
-  		  	$_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];
-  		  }
-  
-  	    break;
-  	  case 'nodeapi':
-  	  	$_SESSION['shareUI_nid'] = $context['node']->nid;
-  		  $_SESSION['shareUI_node'] = $context['node'];		  		  		
-  		  $_SESSION['shareUI_default_message'] = $context['shareUI_default_message'];
-  
-      	break;
-    }
-  //}
+  $hook = $context['hook'];
+  $_SESSION['shareUI_action'] = $hook;
+  switch ($hook) {
+    case 'comment':	    			      	      	   
+      $context['node'] = _comment_load($context[$hook]->cid);
+      $_SESSION['shareUI_nid'] = $context['node']->nid;
+      $_SESSION['shareUI_node'] = $context['node'];
+      $_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];	
+      break;
+    case 'user':
+      $context['user'] = user_load($context['account']->uid);    	        		
+      $_SESSION['shareUI_uid'] = $context['user']->uid;
+      $_SESSION['shareUI_user'] = $context['user'];
+      
+      if ( $context['op'] ) {
+        if ( $context['op'] == t('update') ) {
+          $_SESSION['shareUI_default_message'] = 'Updated his/her profile';
+        }
+        else {
+          $_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];
+        }
+      }
+      else {		  
+        $_SESSION['shareUI_default_message'] =$context['shareUI_default_message'];
+      }
+
+      break;
+    case 'nodeapi':
+      $_SESSION['shareUI_nid'] = $context['node']->nid;
+      $_SESSION['shareUI_node'] = $context['node'];		  		  		
+      $_SESSION['shareUI_default_message'] = $context['shareUI_default_message'];
+
+      break;
+  }
+
   
 }
 
@@ -228,14 +242,7 @@
     '#default_value' => isset($context['shareUI_default_message']) ? $context['shareUI_default_message'] : 'posted a Drupal site item',
     '#required' => TRUE,
   );
-  /*$form['shareUI_content_types'] = array(
-    '#type' => 'select',
-    '#title' => t('Restrict shareUI items to the following content types'),
-    '#options' => node_get_types('names'),
-    '#multiple' => TRUE,
-    '#default_value' => isset($context['shareUI_content_types']) ? $context['shareUI_content_types'] : '',
-  );  */
-  return $form;
+   return $form;
 }
 
 function gigya_shareUI_action_submit($form, $form_state) {  
@@ -325,66 +332,6 @@
   );
 }
 
-/**
- * Form for configurable Drupal action for newsfeeds and status popups.
- */
-/*
-function gigya_status_popup_action_form($context) {
-	
-	module_load_include('module','popups');
-  	drupal_add_js(drupal_get_path('module', 'popups') .'/popups.js', 'module');	
-	
-  $form['status_popup_content_types'] = array(
-    '#type' => 'select',
-    '#title' => t('Restrict status popup items to the following content types'),
-    '#options' => node_get_types('names'),
-    '#multiple' => TRUE,
-    '#default_value' => isset($context['status_popup_content_types']) ? $context['status_popup_content_types'] : '',
-  );
-  $form['gigya_status_user_description'] = array(
-    '#type' => 'textfield',
-    '#title' => t('User status update description'),
-    '#description' => t('Describe to your users what text should be put in the status update when looking at a user trigger'),
-    '#default_value' => isset($context['gigya_status_user_description']) ? $context['gigya_status_user_description'] : 'Update status. You can use !user, !profileurl, !sitename to represent the username, and link to user profile.',
-    '#required' => TRUE,
-  );
-  $form['gigya_status_user_default_message'] = array(
-    '#type' => 'textfield',
-    '#title' => t('User default message'),
-    '#description' => t('This is the default message populated in status popups for user triggers'),
-    '#default_value' => isset($context['gigya_status_user_default_message']) ? $context['gigya_status_user_default_message'] : 'Currently looking at my friend !user on !sitename. !profileurl',
-    '#required' => TRUE,
-  );
-  $form['gigya_status_node_description'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Node/comment status update description'),
-    '#description' => t('Describe to your users what text should be put in the status update when looking at a node/comment trigger'),
-    '#default_value' => isset($context['gigya_status_node_description']) ? $context['gigya_status_node_description'] : 'Update status. You can use !url, !url-alias, !tinyurl, !title and !user as replacement text.',
-    '#required' => TRUE,
-  );
-  $form['gigya_status_node_default_message'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Node/comment defualt message'),
-    '#description' => t('This is the default message populated in status popups for node/comment triggers'),
-    '#default_value' => isset($context['gigya_status_node_default_message']) ? $context['gigya_status_node_default_message'] : '!title is awesome, come take a look: !tinyurl',
-    '#required' => TRUE,
-  );
-  return $form;
-}
-
-function gigya_status_popup_action_submit($form, $form_state) {
-	
-	module_load_include('module','popups');
-  	drupal_add_js(drupal_get_path('module', 'popups') .'/popups.js', 'module');	
-	
-  return array(
-    'status_popup_content_types' => $form_state['values']['status_popup_content_types'],
-    'gigya_status_user_description' => $form_state['values']['gigya_status_user_description'],
-    'gigya_status_user_default_message' => $form_state['values']['gigya_status_user_default_message'],
-    'gigya_status_node_description' => $form_state['values']['gigya_status_node_description'],
-    'gigya_status_node_default_message' => $form_state['values']['gigya_status_node_default_message'],
-  );
-}*/
 
 function gigya_init() {
   global $base_path,$base_url,$user;
@@ -442,29 +389,29 @@
         	}
         } 
        
-		if ($user->gigya->HasCapability('Actions') || $userHasFacebook ) {											
-			$nType = $_SESSION['shareUI_action'];
-			if (is_numeric($_SESSION['shareUI_nid'])) {  //nodeapi and comments							
-				$currUrl = $base_url . '/node/' . $_SESSION['shareUI_nid'] ;	      	
-		      	module_load_include('inc', 'gigya', 'gigya.pages');
-		      	unset($_SESSION['shareUI_action']);
-		      	$currNode = $_SESSION['shareUI_node'];
-		      	unset($_SESSION['shareUI_node']);
-		      	return gigya_shareui_ajax($currNode,$nType,$_SESSION['shareUI_nid'],$currUrl);	      	     
-		  	}
-		  	else if (is_numeric($_SESSION['shareUI_uid'])) {  //users	    		    		    	
-	      		$currUrl = $base_url . '/user/' . $_SESSION['shareUI_uid'] ;
-	      		module_load_include('inc', 'gigya', 'gigya.pages');
-	      		unset($_SESSION['shareUI_action']);        
-	      		$currUser = $_SESSION['shareUI_user'];
-	      		unset($_SESSION['shareUI_user']);	    	
-				return gigya_shareui_ajax($currUser,$nType,$_SESSION['shareUI_uid'],$currUrl);			       
-		  	}
-		}
-		else {
-			watchdog('gigya', 'gigya_init: user ' . $user->uid . ' cannot use shareUI due to a lack of capabilities' ); 
-		}  
-  	}  	
+  		if ($user->gigya->HasCapability('Actions') || $userHasFacebook ) {											
+  			$nType = $_SESSION['shareUI_action'];
+  			if (is_numeric($_SESSION['shareUI_nid'])) {  //nodeapi and comments							
+  				$currUrl = $base_url . '/node/' . $_SESSION['shareUI_nid'] ;	      	
+  		      	module_load_include('inc', 'gigya', 'gigya.pages');
+  		      	unset($_SESSION['shareUI_action']);
+  		      	$currNode = $_SESSION['shareUI_node'];
+  		      	unset($_SESSION['shareUI_node']);
+  		      	return gigya_shareui_ajax($currNode,$nType,$_SESSION['shareUI_nid'],$currUrl);	      	     
+  		  	}
+  		  	else if (is_numeric($_SESSION['shareUI_uid'])) {  //users	    		    		    	
+  	      		$currUrl = $base_url . '/user/' . $_SESSION['shareUI_uid'] ;
+  	      		module_load_include('inc', 'gigya', 'gigya.pages');
+  	      		unset($_SESSION['shareUI_action']);        
+  	      		$currUser = $_SESSION['shareUI_user'];
+  	      		unset($_SESSION['shareUI_user']);	    	
+  				return gigya_shareui_ajax($currUser,$nType,$_SESSION['shareUI_uid'],$currUrl);			       
+  		  	}
+  		}
+  		else {
+  			watchdog('gigya', 'gigya_init: user ' . $user->uid . ' cannot use shareUI due to a lack of capabilities' ); 
+  		}  
+  	}
   
   	unset($_SESSION['shareUI_action']);
   	
@@ -475,30 +422,9 @@
     
   switch ($op) {
     case 'update':
+    break;
     case 'insert':
-      if (!empty($node->status) && !empty($node->gigya) && !empty($node->gigya['post'])) {
-        $replacements = array('!title' => $node->title,
-                              '!url' => url('node/'. $node->nid, array('absolute' => TRUE, 'alias' => TRUE)),
-                              '!url-alias' => url('node/'. $node->nid, array('absolute' => TRUE)),
-                              '!user' => $node->name);
-        // Only generate the shortened URL if it's going to be used. No sense
-        // burning through TinyURLs without a good reason.
-        if (strstr($node->gigya['status'], '!tinyurl') !== FALSE) {
-          $replacements['!tinyurl'] = gigya_shorten_url(url('node/'. $node->nid, array('absolute' => TRUE)));
-        }
-        $status = strtr($node->gigya['status'], $replacements);
-        if($user->uid){
-          if ($result = $user->gigya->SetStatus($status)) {
-            drupal_set_message(t('Successfully posted to social networks'));
-          }
-          else {
-            drupal_set_message(t('An error occurred when posting to your social network:'));
-          }
-        }
-        else{
-          drupal_set_message(t('You are not logged in to any social networks.'));
-        }
-      }
+
       break;
   }
 }
@@ -517,24 +443,7 @@
   module_load_include('inc', 'gigya');
   switch ($op) {
     case 'form' :
-      /*if($category == 'account'){
-        $form = array();
-        $form['gigya'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Social network user settings'),
-          '#weight' => -1,
-          '#collapsible' => TRUE,
-          '#collapsed' => FALSE,
-          '#description' => t('Configure your socialize behaviors')
-        );
-        
-        $form['gigya']['setStatus_popup_hide'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Never show popups for social network status updates'),
-          '#default_value' => $account->setStatus_popup_hide,
-          );
-        return $form;
-      } */
+  
     break;
     case 'load' :
       GigyaUser::Load($account);
@@ -692,7 +601,7 @@
     	$account = user_load($form['#uid']);    	    
    		$gigya_bio = $account->gigya->GetUserInfo();
     	if (!empty($gigya_bio)) {
-      		if($gigya_bio['loginProvider'] != 'siteaccount') unset($form['account']['pass']);
+      		//if($gigya_bio['loginProvider'] != 'siteaccount') unset($form['account']['pass']);
     	}
   	}
   }
@@ -703,17 +612,8 @@
     
     //if they haven't logged into gigya and they're not already logged in (as in the case of admin user creation) simply add the gigya login block
     if(!($_gigya_user = GigyaUser::UserFromUrl()) && !$user->uid){    
-      gigya_login_block_js();
-      $login_js = 'Drupal.behaviors.gigya_login = function(context){ Drupal.gigya.login(); }';
-      drupal_add_js($login_js, 'inline');
-      $item = array(
-        'data' => '<div id="'. variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID) .'"></div>',
-      );
-      $form['gigya_login'] = array(
-        '#value' => theme('gigya_login_block', $item),
-        '#weight' => -10,
-      );
-      $form['links']['#weight'] = 2;	  
+      
+      $form['#prefix'] .= theme('gigya_login_block', $form_id);
 	  }
     elseif($_gigya_user = GigyaUser::UserFromUrl()){// if they HAVE logged into gigya then populate some of the data and hide the password field
       $bio = $_gigya_user->GetUserInfo();
@@ -761,30 +661,12 @@
   
   if ($form_id == 'user_login') {    	
     module_load_include('inc', 'gigya');
-    if (!isset($_gigya_uid)) {
-      if (!isset($user) || $user->uid == 0) {
-        $drupal_logged_out = array(
-          'drupal_logged_out' => TRUE,
-        );
-        drupal_add_js(array('gigya' => $drupal_logged_out), 'setting');
-      }
-      gigya_login_block_js();
-      $login_js = 'Drupal.behaviors.gigya_login = function(context){ Drupal.gigya.login(); }';
-      drupal_add_js($login_js, 'inline');
-      $item = array(
-        'data' => '<div id="'. variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID) .'"></div>',
-      );
-      $form['gigya_login'] = array(
-        '#value' => theme('gigya_login_block', $item),
-        '#weight' => 1,
-      );
-      $form['links']['#weight'] = 2;
-    }
+    $form['#prefix'] .= theme('gigya_login_block', $form_id);    
   }
   
   if ($form_id == 'user_login_block') {
   	  	 	 
-    global $user, $_gigya_uid;  
+    global $user; 
       
     module_load_include('inc', 'gigya');
 
@@ -794,28 +676,9 @@
       unset($form['submit']);
       unset($form['links']);
     }    
-    else { //if drupal is logged out, we need to tell JS that so it logs out
-      if (!isset($user) || $user->uid == 0) {
-        $drupal_logged_out = array(
-          'drupal_logged_out' => TRUE,
-        );
-        drupal_add_js(array('gigya' => $drupal_logged_out), 'setting');
-      }
-    }
-    //if gigya is the only way to login, disable username and password block. NOTE admin can still login through /user
-    gigya_login_block_js();
-    $login_js = 'Drupal.behaviors.gigya_login = function(context){ Drupal.gigya.login(); }';
-    drupal_add_js($login_js, 'inline');
-    $item = array(
-      'data' => '<div style="margin-top: 10px; margin-left:auto; margin-right:auto;" id="'. variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID) .'"></div>',
-      'surpress' => variable_get('gigya_login_surpress_login', FALSE),
-    );
-    $form['gigya_login'] = array(
-      '#value' => theme('gigya_login_block', $item),
-      '#weight' => 1,
-    );
-    $form['links']['#weight'] = 2;
+    $form['#prefix'] .= theme('gigya_login_block', $item);
     
+    /*why is this here? 
   	if (isset($form['#action'])) {
   		$currAction = $form['#action'];
   		if (strpos($currAction,'socialize-login') ) {
@@ -825,47 +688,12 @@
         		unset($form['submit']);
   			unset($form['gigya_login']);
   		}  
-  	}
+  	}*/
 	
     return $form;
   }
   
-  /** alter the updates status upon node edit/created **/
-  if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
-    module_load_include('inc', 'gigya');
-    if(empty($user->uid)) return;
-    if (!$user->gigya->HasCapability('Status')) return;
-    
-    // If we haven't enabled Gigya Socialize posting on this node type, nothing to do
-    // here.
-    $type = $form['#node']->type;
-    $allowed_types = variable_get('gigya_status_types', array('story' => 'story', 'blog' => 'blog'));
-    if (empty($allowed_types[$type])) {
-      return;
-    }
-    $gigya_status_form = gigya_status_form();
-    if (!$gigya_status_form) {
-      return;
-    }
-    /*
-    $form['gigya'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Post update to Social Networks'),
-      '#collapsible' => TRUE,
-      '#collapsed' => FALSE,
-      '#tree' => TRUE,
-    );
-    $form['gigya']['post'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Announce this post to your social networks'),
-      '#default_value' => (empty($form['nid']['#value'])),
-      '#id' => 'gigya-toggle',
-    );
-    $form['gigya'] += $gigya_status_form;
-    $form['gigya']['status']['#default_value'] = variable_get('gigya_default_format', 'New post: !title !tinyurl');
-    $form['gigya']['status']['#description'] = variable_get('gigya_status_description', 'The given text will be posted to your social networks. You can use !url, !url-alias, !tinyurl, !title and !user as replacement text.');
-    */
-  }
+ 
 
   
   if ($form_id == 'gigya_admin_form') {  	   	  	  	   
@@ -907,10 +735,10 @@
 
 function gigya_load_params() {
   $params = array();
-  date_default_timezone_set('GMT');
+  //date_default_timezone_set('GMT');
   $params['apiKey'] = variable_get('gigya_APIKey', FALSE);    
   $params['nonce'] = mktime() . rand();
-  $params['timestamp'] = gmmktime();
+  $params['timestamp'] = mktime();
   return $params;
 }
 /**
@@ -968,17 +796,22 @@
   else {
     $login_UIConfig = "<config><body><captions background-color=\"". variable_get('gigya_login_uiconfig_color_caption_background', GIGYA_DEFAULT_LOGINUI_COLOR_CAPTION_BACKGROUND) ."\" color=\"". variable_get('gigya_login_uiconfig_color_caption_text', GIGYA_DEFAULT_LOGINUI_COLOR_CAPTION_TEXT) ."\"></captions><texts color=\"". variable_get('gigya_login_uiconfig_color_text', GIGYA_DEFAULT_LOGINUI_COLOR_TEXT) ."\"><links color=\"". variable_get('gigya_login_uiconfig_color_link', GIGYA_DEFAULT_LOGINUI_COLOR_LINK) ."\"></links></texts><controls><snbuttons buttonsize=\"". variable_get('gigya_login_uiconfig_iconsize', GIGYA_DEFAULT_ICONSIZE) ."\" color=\"". variable_get('gigya_login_uiconfig_color_button_text', GIGYA_DEFAULT_LOGINUI_COLOR_BUTTON_TEXT) ."\"></snbuttons><scrollingarrow color=\"". variable_get('gigya_login_uiconfig_color_navigation_arrow', GIGYA_DEFAULT_LOGINUI_COLOR_NAVIGATION_ARROW) ."\"></scrollingarrow></controls><background background-color=\"". variable_get('gigya_login_uiconfig_color_background', GIGYA_DEFAULT_LOGINUI_COLOR_BACKGROUND) ."\" frame-color=\"". variable_get('gigya_login_uiconfig_color_frame', GIGYA_DEFAULT_LOGINUI_COLOR_FRAME) ."\"></background></body></config>";
   }
+  
+  $behaviors_js = 'Drupal.behaviors.gigya_attachEvents = function(){ 
+      gigya.services.socialize.addEventHandlers(Drupal.settings.gigya.conf, {onLogin:Drupal.gigya.login_callback,context:{destination:\''. url('socialize-login',array('query'=>'destination='.$_REQUEST['destination'],'absolute'=>true)) .'\'}});
+    }';
+  drupal_add_js($behaviors_js, 'inline');
   $gigya_login_params = array(
     'login_params' => array(
       "headerText" => variable_get('gigya_login_uiconfig_title', ''),
-      "width" => variable_get('gigya_login_uiconfig_width', 120),
-      "height" => variable_get('gigya_login_uiconfig_height', 110),
+      "width" => variable_get('gigya_login_uiconfig_width', GIGYA_DEFAULT_LOGINUI_WIDTH),
+      "height" => variable_get('gigya_login_uiconfig_height', GIGYA_DEFAULT_LOGINUI_HEIGHT),
       "containerID" => variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID),
       "showTermsLink" => variable_get('gigya_login_uiconfig_terms', TRUE),
       "hideGigyaLink" => variable_get('gigya_login_uiconfig_branding', TRUE),
-      "useFacebookConnect" => variable_get('gigya_login_advanced_facebookconnect', GIGYA_DEFAULT_LOGINUI_FBCONNECT),
-      "redirectURL" => url('socialize-login'),
+      "useFacebookConnect" => true,
       "UIConfig" => $login_UIConfig,
+      'requiredCapabilities' => implode(',',array_filter(variable_get('gigya_requiredCapabilities','friends')))
     ),
   );
   if(variable_get('gigya_login_advanced_custombuttons', ''))
@@ -991,8 +824,8 @@
   global $base_path;
   module_load_include('inc', 'gigya');
   //setup the timestamp for validation through gigya_verify_signature
-  date_default_timezone_set('GMT');
-  $timestamp = date('Y-m-d H:i:s');
+  //date_default_timezone_set('GMT');
+  $timestamp = gmdate('Y-m-d H:i:s');
   
   
   $signature = _gigya_verify_signature($timestamp, $userID, variable_get('gigya_SecretKey', FALSE));
@@ -1011,27 +844,6 @@
 
 
 
-function gigya_link($type, $object, $teaser = FALSE) {
-  module_load_include('inc', 'gigya');
-  global $user;
-  $links = array();
-  if(!($user->uid)) return $links;
-  
-  if ($user->gigya->HasCapability('Notifications') && $user->gigya->HasCapability('Friends')) {
-    $allowed_types = variable_get('gigya_share_types', array('story' => 'story', 'blog' => 'blog'));
-    if ($type == 'node' && !empty($allowed_types[$object->type])) {
-    	//
-      /*$links['socialize_notify_friends'] = array(
-        'title' => variable_get('gigya_share_link_title', GIGYA_DEFAULT_SHARE_LINK_TITLE),
-        'href' => "gigya/notifyfriends/$object->nid",
-        'attributes' => array('title' => t('Tell your friends about !nodetitle.', array('!nodetitle' => $object->title)), 'class' => 'popups-form'),
-      );  */
-    }
-  }
-  return $links;
-}
-
-
 /**
  * Implementation of hook_theme().
  */
@@ -1042,10 +854,9 @@
       'template' => 'gigya-user-picture',
     ),    
     'gigya_connect_display' => array(
-      'arguments' => array('element'),
     ),
     'gigya_login_block' => array(
-      'arguments' => array('element'),
+      'arguments' => array('form_id'),
     ),
     'gigya_user_profile' => array(
       'arguments' => array('bio'),
@@ -1122,32 +933,40 @@
 /**
  * Display actions assigned to this hook-op combination in a table.
  *
- * @param array $element
- *   The fieldset including all assigned actions.
- * @return
- *   The rendered form with the table prepended.
- *
- * @ingroup themeable
  */
-function theme_gigya_connect_display($element) {  
-  $header = array();
-  $rows = array();
-  if (is_array($element['assigned']['#value'])) {
-    $header = array(array('data' => t('Login Provider')), array('data' => t('Operation')));
-    $rows = array();
-    foreach ($element['assigned']['#value'] as $aid => $info) {
-      $rows[] = array(
-        $info['description'],
-        $info['link']
-      );
-    }
-  }
-  if (count($rows)) {
-    $output = theme('table', $header, $rows) . drupal_render($element);
+function theme_gigya_connect_display() {  
+  global $user;
+  module_load_include('inc', 'gigya');
+  //gigya_login_block_js();
+  
+  $bio = $user->gigya->GetUserInfo();
+  
+  if (variable_get('gigya_connect_uiconfig_raw', '')) {
+    $connect_UIConfig = variable_get('gigya_connect_uiconfig_raw', '');
   }
   else {
-    $output = drupal_render($element);
+    $connect_UIConfig = "<config><body><captions background-color=\"". variable_get('gigya_connect_uiconfig_color_caption_background', GIGYA_DEFAULT_CONNECTUI_COLOR_CAPTION_BACKGROUND) ."\" color=\"". variable_get('gigya_connect_uiconfig_color_caption_text', GIGYA_DEFAULT_CONNECTUI_COLOR_CAPTION_TEXT) ."\"></captions><texts color=\"". variable_get('gigya_connect_uiconfig_color_text', GIGYA_DEFAULT_CONNECTUI_COLOR_TEXT) ."\"><links color=\"". variable_get('gigya_connect_uiconfig_color_link', GIGYA_DEFAULT_CONNECTUI_COLOR_LINK) ."\"></links></texts><controls><snbuttons buttonsize=\"". variable_get('gigya_connect_uiconfig_iconsize', GIGYA_DEFAULT_ICONSIZE) ."\" color=\"". variable_get('gigya_connect_uiconfig_color_button_text', GIGYA_DEFAULT_CONNECTUI_COLOR_BUTTON_TEXT) ."\"></snbuttons><scrollingarrow color=\"". variable_get('gigya_connect_uiconfig_color_navigation_arrow', GIGYA_DEFAULT_CONNECTUI_COLOR_NAVIGATION_ARROW) ."\"></scrollingarrow></controls><background background-color=\"". variable_get('gigya_connect_uiconfig_color_background', GIGYA_DEFAULT_CONNECTUI_COLOR_BACKGROUND) ."\" frame-color=\"". variable_get('gigya_connect_uiconfig_color_frame', GIGYA_DEFAULT_CONNECTUI_COLOR_FRAME) ."\"></background></body></config>";
   }
+  
+  $gigya_connect_params = array(
+    'connect_params' => array(
+      "headerText" => variable_get('gigya_connect_uiconfig_captionText', GIGYA_DEFAULT_CONNECTUI_CAPTIONTEXT),
+      "width" => variable_get('gigya_connect_uiconfig_width', GIGYA_DEFAULT_CONNECTUI_WIDTH),
+      "height" => variable_get('gigya_connect_uiconfig_height', GIGYA_DEFAULT_CONNECTUI_HEIGHT),
+      "containerID" => variable_get('gigya_connect_uiconfig_containerID', GIGYA_DEFAULT_CONNECTUI_CONTAINERID),
+      "showTermsLink" => variable_get('gigya_connect_uiconfig_terms', TRUE),
+      "hideGigyaLink" => variable_get('gigya_connect_uiconfig_branding', TRUE),
+      "useFacebookConnect" => variable_get('gigya_login_advanced_facebookconnect', GIGYA_DEFAULT_LOGINUI_FBCONNECT),
+      "UIConfig" => $connect_UIConfig,
+      'requiredCapabilities' => implode(',',array_filter(variable_get('gigya_requiredCapabilities','friends')))
+    ),
+  );
+  drupal_add_js(array('gigya' => $gigya_connect_params), 'setting');    
+  $output .= '<div id="'. variable_get('gigya_connect_uiconfig_containerID', GIGYA_DEFAULT_CONNECTUI_CONTAINERID) .'"></div>';
+  drupal_add_js('var connect_params = Drupal.settings.gigya.connect_params;
+        connect_params.width = parseInt(connect_params.width);
+        connect_params.height = parseInt(connect_params.height);
+        gigya.services.socialize.showConnectUI(Drupal.settings.gigya.conf,connect_params);','inline');
   return $output;
 }
 
@@ -1170,18 +989,20 @@
 	}
 }
 
-function theme_gigya_login_block($element) {  	
-  if (!isset($element['surpress']) || $element['surpress'] == FALSE) {
+function theme_gigya_login_block($form_id = NULL,$suppress_title = false) {
+  gigya_login_block_js();
+  $login_js = 'Drupal.behaviors.gigya_login = function(context){ Drupal.gigya.login(); }';
+  drupal_add_js($login_js, 'inline');
+
+  if (!$suppress_title) {
     $title = t('Login using social networks');
-    $output = '<h2 style="text-align: left !important; margin-top:10px;">'. $title .'</h2>';
+    $output = '<h2>'. $title .'</h2>';
   }
   else {
     $output = '';
   }
-  $data = $element['data'];
-  $output .= '<div class="gigya-login">';
-  $output .= $data;
-  $output .= '</div>';
+
+  $output .= '<div class="gigya-login"><div id="'. variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID) .'"></div></div>';
   return $output;
 }
 
@@ -1483,45 +1304,42 @@
 	
 	/*$xxx = gigya_printObject('',$currObj);
 	drupal_set_message('nodeeee= ' . $xxx);*/	 	
-	  
-	if ( t('comment')==$objType) {
-		// Setting the Title";
-		$current_title = $currObj->title;
-		if (empty($current_title)) {
-			$current_title = drupal_get_title();
-			if (empty($current_title)) {
-				$current_title = 'A Drupal site item';
-			}
-		}
 
-		// Setting the description";
-		if ( empty($currObj->teaser) ) {
-			$currBody = $currObj->body;
-		}
-		else {
-			$currBody = $currObj->teaser;
-		}
-		
-		$currAction = 'commented on item: ';
+  // Setting the Title";
+  $current_title = $currObj->title;
+  if (empty($current_title)) {
+    $current_title = drupal_get_title();
+    if (empty($current_title)) {
+      $current_title = 'A Drupal site item';
+    }
+  }
+
+  // Setting the description";
+  if ( !empty($currObj->teaser) ) {
+    $currBody = $currObj->teaser;
+  }
+  elseif( !empty($currObj->comment)) {
+    $currBody = $currObj->comment;
+  }
+  else{
+    $currBody = $currObj->body;
+  }
+  
+	if ( t('comment')==$objType) {
+		$currAction = 'said: ';
 	} 
 	else {
-		$current_title = drupal_get_title();
-		if (empty($current_title)) {
-			$current_title = 'A Drupal site item';
-		}	
-		$currBody = '';
-		
-		$currAction = 'viewed';
+		$currAction = 'viewed: ';
 	}
 		
-	$current_title = str_replace('039;','\\\'',$current_title);
-	$current_title = str_replace("'",'\'',$current_title);
+	//$current_title = str_replace('039;','\\\'',$current_title);
+	//$current_title = str_replace("'",'\'',$current_title);
 	
 	$currBody = strip_tags($currBody);	
-	$currBody = str_replace('039;','\\\'',$currBody);	
+	//$currBody = str_replace('039;','\\\'',$currBody);	
 	$currBody = str_replace("\r",' ',$currBody);	
 	$currBody = str_replace("\n",' ',$currBody);		
-	$currBody = str_replace("'",'\'',$currBody);
+	//$currBody = str_replace("'",'\'',$currBody);
 	
 		
 	/*
@@ -1554,24 +1372,24 @@
     	$replacements['!tinyurl'] = gigya_shorten_url(url('node/'. $objID, array('absolute' => TRUE)));
     }
     $finalUserMsg = strtr($currUserMsg, $replacements);	
-	$shareUI_js .= "var userMsg='$finalUserMsg'; ";
+	$shareUI_js .= "var userMsg=\"". htmlentities($finalUserMsg) ."\"; ";
 	$shareUI_js .= "act.setUserMessage(userMsg); ";
 	
 	
 		
-	$shareUI_js .= 'act.setTitle("' . $current_title . '"); ';
+	$shareUI_js .= 'act.setTitle("' . htmlentities($current_title) . '"); ';
 	
 	// Setting the Link Back
 	$shareUI_js .= " var currUrl='$currUrl'; ";	
 	$shareUI_js .= "act.setLinkBack(currUrl); ";
 	
 	// Setting the Description		 
-	$shareUI_js .= " var currBody='$currBody'; ";
+	$shareUI_js .= " var currBody=\"". htmlentities($currBody) ."\"; ";
 	$shareUI_js .= 'act.setDescription(currBody); ';	
 	
-	$shareUI_js .= gigya_shareUI_mediaItem_js();
+	//$shareUI_js .= gigya_shareUI_mediaItem_js();
 		
-	$currImg ='';
+	/*$currImg ='';
 	if ( $currObj->images ) { 			
 		$currImages = $currObj->images;		
 		if ($currImages['preview']) {
@@ -1595,7 +1413,7 @@
 			$shareUI_js .= " } ";
 		}
 	}
-			
+			*/
 		
 	// Adding an Action Link
 	$shareUI_js .= " var baseUrl='$base_url'; ";	
@@ -1609,6 +1427,7 @@
 
     //$shareUI_js .= " debugger;";
 	// Publishing the User Action
-	$shareUI_js .= "gigya.services.socialize.showShareUI(Drupal.settings.gigya.conf, shareUI_params); ";	
-	return 'Drupal.behaviors.gigya_init = function(context){'. $shareUI_js .'}';
+	$shareUI_js .= "gigya.services.socialize.showShareUI(Drupal.settings.gigya.conf, shareUI_params);";
+	return 'gigya_shareUI = function(){'. $shareUI_js .'};
+  Drupal.behaviors.gigya_shareUI = function(context){setTimeout(gigya_shareUI,1000);};';//the delay is a crude way of trying to allow the browser to scroll before popping up the share interface
 }
\ No newline at end of file
Index: gigya.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gigya/Attic/gigya.pages.inc,v
retrieving revision 1.1.2.18
diff -u -r1.1.2.18 gigya.pages.inc
--- gigya.pages.inc	18 Feb 2010 16:00:10 -0000	1.1.2.18
+++ gigya.pages.inc	15 Mar 2010 03:24:37 -0000
@@ -11,59 +11,8 @@
  * 
  */
 function gigya_connect($account, $name = NULL) {
-	
-  global $base_url;
-    
-  module_load_include('inc', 'gigya');
-  $title = isset($account->title) ? $account->title : $account->name;
-  drupal_set_title(check_plain($title));
-
-  $form = array();
-  gigya_login_block_js();
-  
-  $bio = gigya_getUserInfo($account->uid);
-       
-  if ($bio['isConnected'] == 1 || $bio['isConnected'] == true) {
-    
-    if (variable_get('gigya_connect_uiconfig_raw', '')) {
-      $connect_UIConfig = variable_get('gigya_connect_uiconfig_raw', '');
-    }
-    else {
-      $connect_UIConfig = "<config><body><captions background-color=\"". variable_get('gigya_connect_uiconfig_color_caption_background', GIGYA_DEFAULT_CONNECTUI_COLOR_CAPTION_BACKGROUND) ."\" color=\"". variable_get('gigya_connect_uiconfig_color_caption_text', GIGYA_DEFAULT_CONNECTUI_COLOR_CAPTION_TEXT) ."\"></captions><texts color=\"". variable_get('gigya_connect_uiconfig_color_text', GIGYA_DEFAULT_CONNECTUI_COLOR_TEXT) ."\"><links color=\"". variable_get('gigya_connect_uiconfig_color_link', GIGYA_DEFAULT_CONNECTUI_COLOR_LINK) ."\"></links></texts><controls><snbuttons buttonsize=\"". variable_get('gigya_connect_uiconfig_iconsize', GIGYA_DEFAULT_ICONSIZE) ."\" color=\"". variable_get('gigya_connect_uiconfig_color_button_text', GIGYA_DEFAULT_CONNECTUI_COLOR_BUTTON_TEXT) ."\"></snbuttons><scrollingarrow color=\"". variable_get('gigya_connect_uiconfig_color_navigation_arrow', GIGYA_DEFAULT_CONNECTUI_COLOR_NAVIGATION_ARROW) ."\"></scrollingarrow></controls><background background-color=\"". variable_get('gigya_connect_uiconfig_color_background', GIGYA_DEFAULT_CONNECTUI_COLOR_BACKGROUND) ."\" frame-color=\"". variable_get('gigya_connect_uiconfig_color_frame', GIGYA_DEFAULT_CONNECTUI_COLOR_FRAME) ."\"></background></body></config>";
-    }
-  }
-  
-  $gigya_connect_params = array(
-    'connect_params' => array(
-      "headerText" => variable_get('gigya_connect_uiconfig_captionText', GIGYA_DEFAULT_CONNECTUI_CAPTIONTEXT),
-      "width" => variable_get('gigya_connect_uiconfig_width', GIGYA_DEFAULT_CONNECTUI_WIDTH),
-      "height" => variable_get('gigya_connect_uiconfig_height', GIGYA_DEFAULT_CONNECTUI_HEIGHT),
-      "containerID" => variable_get('gigya_connect_uiconfig_containerID', GIGYA_DEFAULT_CONNECTUI_CONTAINERID),
-      "showTermsLink" => variable_get('gigya_connect_uiconfig_terms', TRUE),
-      "hideGigyaLink" => variable_get('gigya_connect_uiconfig_branding', TRUE),
-      "useFacebookConnect" => variable_get('gigya_login_advanced_facebookconnect', GIGYA_DEFAULT_LOGINUI_FBCONNECT),
-      "UIConfig" => $connect_UIConfig,
-    ),
-  );
-  drupal_add_js(array('gigya' => $gigya_connect_params), 'setting');    
-  $form['gigya'] = array(
-    '#type' => 'fieldset',
-    '#theme' => 'gigya_connect_display',
-    '#description' => t('You may connect your profile to additional social networks here.'),
-  );
-
-  $form['gigya']['connect'] = array(
-    '#weight' => 10,
-    '#value' => '&nbsp;',
-    '#prefix' => '<div class="gigya editConnectionsUI"><strong>Social Network Connections</strong><div id="'. variable_get('gigya_connect_uiconfig_containerID', GIGYA_DEFAULT_CONNECTUI_CONTAINERID) .'">',
-    '#suffix' => '</div><script type="text/javascript">
-        var connect_params = Drupal.settings.gigya.connect_params;
-        connect_params.width = parseInt(connect_params.width);
-        connect_params.height = parseInt(connect_params.height);
-        gigya.services.socialize.showEditConnectionsUI(Drupal.settings.gigya.conf,connect_params);</script></div>',
-  );
-
-  return drupal_render($form);
+	drupal_set_title('Edit your Social Network connections');
+  return theme('gigya_connect_display');
 }
 
 function gigya_shareui_ajax($currObj,$objType,$objID,$currUrl) {          
@@ -79,7 +28,7 @@
 
   $dest = $_REQUEST['destination'];
   if(empty($dest)) $dest = $base_path;
-  $logout_behavior = array("logout_location" => $base_path);
+  $logout_behavior = array("logout_location" => $dest);
   
   drupal_add_js(array('gigya' => $logout_behavior), 'setting');
 
@@ -100,11 +49,11 @@
 	if (!($user->uid)) { //not yet logged in to Drupal
   
     if($_gigya_user = GigyaUser::UserFromUrl()){
-         
+      
       $dest = $base_path . variable_get('gigya_login_uiconfig_urlredirect', 'user');
     
       $bio = $_gigya_user->GetUserInfo();
-          
+         
       //check to see if the gigya_user is a drupal user
       if ($account = user_load($_gigya_user->uid)) {    
         if (!variable_get('user_email_verification', true) || $account->login) {
@@ -113,6 +62,7 @@
           
           //log the user in
           user_external_login($account);
+          
         }
         else {
           drupal_set_message(t('You must validate your email address for this account before logging in via Gigya.'));
@@ -120,7 +70,7 @@
         drupal_goto();
       }
       elseif(variable_get('user_register', 1)){ //try to register them if we're allowed to
-        $form_state['redirect'] = NULL;
+        $form_state['redirect'] = $_REQUEST['destination'];
         $form_state['values']['name'] = (empty($bio['nickname']) ? '' : $bio['nickname']);
         $form_state['values']['mail'] = (empty($bio['email']) ? '' : $bio['email']);
         $form_state['values']['pass']  = user_password();
@@ -145,7 +95,10 @@
             $xxx = gigya_printObject('',$messages);
             // We were unable to register a valid new user
             watchdog('gigya', 'error:' . $xxx);
-            drupal_goto('socialize-register',array('signature'=>$_GET['signature'],'UID'=>$_GET['UID'],'timestamp'=>$_GET['timestamp']));            
+            
+            $dest = $_REQUEST['destination'];
+            unset($_REQUEST['destination']);
+            drupal_goto('socialize-register',array('signature'=>$_GET['signature'],'UID'=>$_GET['UID'],'timestamp'=>$_GET['timestamp'],'destination'=>$dest));
         }
         else {
           //save the new user

