? rpx-935302.patch
Index: rpx.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/rpx/rpx.module,v
retrieving revision 1.8.2.55
diff -u -p -r1.8.2.55 rpx.module
--- rpx.module	19 Sep 2010 16:48:23 -0000	1.8.2.55
+++ rpx.module	7 Oct 2010 22:50:32 -0000
@@ -34,7 +34,7 @@ function rpx_theme() {
  * Implementation of hook_menu()
  */
 function rpx_menu() {
-  
+
   $items['admin/settings/rpx'] = array(
       'title' => 'RPX',
       'description' => t('Configure the settings for RPX.'),
@@ -103,7 +103,7 @@ function rpx_menu() {
     'access arguments' => array(1),
     'type' => MENU_CALLBACK,
   );
-  
+
   return $items;
 }
 
@@ -161,20 +161,20 @@ function rpx_registration() {
       '#default_value' => $_SESSION['rpx']['profile']['preferredUsername'],
       '#description' => t('Please enter your preferred user name.')
     );
-  
+
   $form['mail'] = array(
       '#title' => t('E-Mail'),
       '#type' => 'textfield',
       '#default_value' => $_SESSION['rpx']['profile']['email'],
       '#description' => t('Please enter your e-mail address.')
     );
-    
+
   $form['submit'] = array(
       '#type' => 'submit',
       '#value' => t('Submit'),
       '#weight' => 99
     );
-  
+
   // Add other stuff that needs to go to registration page.
   $null = NULL;
   $extra = _user_forms($null, NULL, NULL, 'register');
@@ -195,7 +195,7 @@ function rpx_registration() {
     }
     $form = array_merge($form, $extra);
   }
- 
+
   return $form;
 }
 
@@ -207,7 +207,7 @@ function rpx_registration_validate($form
   elseif (user_load( array( 'name' => $form_state['values']['name'] ) ) ) {
     form_set_error('name', t('Someone is already using that user name, please use another.') );
   }
-  
+
   // must be a valid and unique mail
   if (empty($form_state['values']['mail']) && empty($_SESSION['rpx']['profile']['email'])) {
     form_set_error('mail', t('Your login provider did not provide an email address. Please enter one below to complete your registration.'));
@@ -233,20 +233,20 @@ function rpx_registration_submit($form, 
     'status' => variable_get('user_register', 1) == 1, // enforce status
     'authname_rpx' => $_SESSION['rpx']['profile']['identifier'],  // for external authorization
   );
-    
+
   $values = $form_state['values'];
   // The unset below is needed to prevent these form values from being saved as
   // user data.
   unset($values['form_token'], $values['submit'], $values['op'], $values['form_id'], $values['form_build_id'], $values['destination']);
   $account = user_save('', array_merge($values, $merge_data));
-  
+
   // Terminate if an error occured during user_save().
   if (!$account) {
     drupal_set_message(t("Error saving user account."), 'error');
     $form_state['redirect'] = '';
     return;
   }
-  
+
   $verify_email = variable_get('user_email_verification', TRUE);
   if (variable_get('rpx_bypass_email_verification', FALSE) ||
       strtolower($account->mail) == strtolower($_SESSION['rpx']['profile']['verifiedEmail'])) {
@@ -258,9 +258,9 @@ function rpx_registration_submit($form, 
   $account = _rpx_populate_user_record($account, $_SESSION['rpx']);
   $account = _rpx_save_profile_fields($account);
   watchdog('user', 'New user: %name (%email).', array('%name' => $account->name, '%email' => $account->mail), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
-  
+
   $account->password = $pass;
-  
+
   if ($account->status && !$verify_email) {
     // No email verification required, so log them in
     _user_mail_notify('register_no_approval_required', $account);
@@ -280,7 +280,7 @@ function rpx_registration_submit($form, 
 }
 
 function rpx_end_point() {
-  
+
   // first, check to see if we have a token -- we're completing an RPX transaction, in that case!
   if (isset($_POST['token'])) {
       $token = $_POST['token'];
@@ -293,10 +293,10 @@ function rpx_end_point() {
   if ($token) {
     // see if we are linking to an existing account from within the system
     $_SESSION['rpx'] = RPX::auth_info( $token, variable_get('rpx_apikey', '') );
-    
+
     if ($add_to_account) {
       global $user;
-      
+
       // ensure they are actually logged in
       if ($user->uid) {
         $result = NULL;
@@ -326,7 +326,7 @@ function rpx_end_point() {
       // fresh meat, go get registered.
       if (! _rpx_blind_registration() ) {
         $dest = $_REQUEST['destination'];
-        unset($_REQUEST['destination']); 
+        unset($_REQUEST['destination']);
         drupal_goto('rpx/registration', 'destination='. $dest); // hmm, missing pieces.  go get 'em.
       }
       else {
@@ -334,7 +334,7 @@ function rpx_end_point() {
       }
     }
   }
-  else {  
+  else {
     // LMT: not sure why we're heading home here. Perhaps drupal_access_denied() or set a message like below
     drupal_set_message(t('You need a token to be here!'));
     drupal_access_denied();
@@ -349,7 +349,7 @@ function rpx_end_point() {
 function _rpx_blind_registration() {
   // check if users are allowed to register on their own
   if (variable_get('user_register', 1) && !variable_get('rpx_force_registration_form', 0)) {
-    
+
     // fill in the default data
     $form_state['values']['name'] = $_SESSION['rpx']['profile']['preferredUsername'];
     $mail = '';
@@ -372,7 +372,7 @@ function _rpx_blind_registration() {
     else {
       return FALSE;
     }
-  } 
+  }
   else {
     return FALSE;
   }
@@ -404,7 +404,7 @@ function _rpx_user_register() {
     '#title' => t('External Providers'),
     '#collapsible' => TRUE,
     '#weight' => 4,
-    '#description' => t('You may also use your account with one of the providers below to register.'));  
+    '#description' => t('You may also use your account with one of the providers below to register.'));
   $form['rpx_providers']['signin'] = array(
     '#value' => _rpx_signin_block()
   );
@@ -444,7 +444,7 @@ function rpx_email_confirm($uid, $timest
  * Populates a given account's data with $profile from an RPX server
  */
 function _rpx_populate_user_record(&$account, $payload) {
-  $rpx_data = array('rpx_data' => $payload);    
+  $rpx_data = array('rpx_data' => $payload);
   return user_save($account, $rpx_data);
 }
 
@@ -502,13 +502,14 @@ function rpx_footer($main = 0) {
  */
 function rpx_javascript() {
   static $added = FALSE;
-  
+
   // Only attempt to add javascript once
   if ($added == TRUE) {
     return FALSE;
   }
-  
+
   drupal_add_css(drupal_get_path('module', 'rpx') .'/rpx.css');
+  $social_pub_js = '';
   if (variable_get('rpx_social_pub', 0)) {
     $social_pub_js = '
       var rpxJsHost = (("https:" == document.location.protocol) ? "https://" : "http://static.");
@@ -525,18 +526,18 @@ function rpx_javascript() {
   );
   $realm = variable_get('rpx_realm', '');
   $flags = 'delay_domain_check';
-  
+
   $output = '
       <!-- Begin RPX Sign In from JanRain. Visit http://www.rpxnow.com/ -->';
   if (!(arg(0) == 'user' && arg(2) == 'rpx')) {
-    $token_url = _rpx_token_url(); 
+    $token_url = _rpx_token_url();
     $output .= '
     RPXNOW.token_url = "'. $token_url .'"';
   }
   else {
     $flags .= ',show_provider_list';
   }
-      
+
   $output .= '
   RPXNOW.realm = "' . $realm . '";
   RPXNOW.overlay = true;
@@ -567,7 +568,7 @@ function _rpx_ssl() {
  * Return the current Drupal locale if available from rpxnow.com, otherwise default to english
  */
 function _rpx_locale() {
-  global $language; 
+  global $language;
 
   // Default to English
   $locale = 'en';
@@ -597,7 +598,7 @@ function _rpx_update_user_login_form( &$
     unset($form['openid_identifier']);
     unset($form['openid.return_to']);
   }
-  
+
   rpx_javascript();
   $items = array();
   $realm = variable_get('rpx_realm', '');
@@ -613,7 +614,7 @@ function _rpx_update_user_login_form( &$
     'data' => l((variable_get('rpx_signin_string', RPX_SIGNIN_STRING)=='') ? RPX_SIGNIN_STRING : variable_get('rpx_signin_string', RPX_SIGNIN_STRING), $sign_in_url, array('query' => array('token_url' => $token_url), 'attributes' => array('class' => 'rpxnow', 'onclick' => 'return false;'))) .'<br />'. $icons,
     'class' => 'rpx-link',
   );
-  
+
   $form['rpx_links'] = array(
     '#value' => theme('item_list', $items),
     '#weight' => 1,
@@ -636,7 +637,7 @@ function _rpx_token_url($rpx_params = ar
   if (is_array($rpx_params)) {
     $query = array_merge($query, $rpx_params);
   }
-  
+
   return url('rpx/end_point', array('query' => $query, 'absolute' => TRUE));
 }
 
@@ -663,22 +664,22 @@ function _rpx_providers($entire_list = F
   $providers['netlog'] = array('name' => 'netlog', 'title' => 'Netlog', 'domain' => 'netlog.com');
   $providers['verisign'] = array('name' => 'verisign', 'title' => 'Verisign', 'domain' => 'verisign.com');
   $providers['linkedin'] = array('name' => 'linkedin', 'title' => 'LinkedIn', 'domain' => 'linkedin.com');
-  
+
   if ($entire_list)
     return $providers;
-  
+
   $config_providers = variable_get('rpx_enabled_providers', FALSE);
   if ($config_providers) {
     $active = array();
     foreach ($config_providers as $p) {
       $key = str_replace("rpx_", "", $p);
-      $active[$key] = $providers[$key]; 
+      $active[$key] = $providers[$key];
     }
   }
   else {
     $active = $providers;
   }
-  
+
   return $active;
 }
 
@@ -694,19 +695,19 @@ function theme_rpx_icon($provider, $styl
 
 function _rpx_signin_block() {
   global $user;
-  
+
   // If already authenticated then don't show this block
   if ($user->uid > 0) {
     return FALSE;
   }
-  
+
   rpx_javascript();
   $realm = variable_get('rpx_realm', '');
   $realm_scheme = variable_get('rpx_realm_scheme', 'http');
   $signin_url = "{$realm_scheme}://{$realm}/openid/v2/signin";
   $token_url = _rpx_token_url();
   $providers = _rpx_providers();
-  
+
   return theme('rpx_icon_links', $providers, $signin_url, $token_url);
 }
 
@@ -715,7 +716,7 @@ function _rpx_signin_block() {
  */
 function theme_rpx_icon_links($providers, $signin_url, $token_url) {
   foreach ($providers as $provider) {
-    $line[] = theme('rpx_icon', $provider, 'rpx-icon') .' '. l($provider['title'], $sign_in_url, array('query' => array('token_url' => $token_url), 'attributes' => array('class' => 'rpxnow', 'onclick' => 'return false;')), 'rpx-icon');
+    $line[] = theme('rpx_icon', $provider, 'rpx-icon') .' '. l($provider['title'], $signin_url, array('query' => array('token_url' => $token_url), 'attributes' => array('class' => 'rpxnow', 'onclick' => 'return false;')), 'rpx-icon');
   }
   return theme('item_list', $line);
 }
@@ -726,7 +727,7 @@ function _rpx_add_to_account_block() {
   $realm_scheme = variable_get('rpx_realm_scheme', 'http');
   $sign_in_url = "$realm_scheme://$realm/openid/v2/signin";
   $token_url = _rpx_token_url(array('add_to_account' => 'true'));
-  
+
   $output = l('Add 3rd party identifier', $sign_in_url, array('query' => array('token_url' => $token_url), 'attributes' => array('class' => 'rpxnow', 'onclick' => 'return false;')));
   return $output;
 }
@@ -739,7 +740,7 @@ function _rpx_publish_widget($comment, $
   $output .= '<a href="javascript:publishComment'. $comment->cid .'()">share</a>';
   $output .= '<script type="text/javascript">
       function publishComment'. $comment->cid .'(){
-          
+
           RPXNOW.loadAndRun([\'Social\'], function () {
           var activity = new RPXNOW.Social.Activity("Share your comment",
           "'. preg_replace("/\r?\n/", ' ', strip_tags($comment->comment)) .'",
@@ -757,7 +758,7 @@ function _rpx_publish_widget($comment, $
 function rpx_link($type, $object, $teaser = FALSE) {
   $links = array();
   // enable RPX to share comments
-  if ($type == 'comment') {  
+  if ($type == 'comment') {
     if (variable_get('rpx_social_pub', FALSE) && variable_get('rpx_attach_share_link', 0)) {
       if (node_comment_mode($object->nid) == COMMENT_NODE_READ_WRITE) {
         if (user_access('post comments')) {
@@ -797,10 +798,10 @@ function rpx_user_identities($account) {
   while ($identity = db_fetch_object($result)) {
     $rows[] = array(check_plain($identity->authname), l(t('Delete'), 'user/'. $account->uid .'/rpx/delete/'. $identity->aid));
   }
- 
+
   $output = theme('table', $header, $rows);
   $output .= _rpx_add_to_account_block();
-  
+
   return $output;
 }
 
@@ -822,7 +823,7 @@ function rpx_user_delete_form($form_stat
     '#type' => 'value',
     '#value' => $aid,
   );
-  
+
   return confirm_form($form, t('Are you sure you want to delete the identity %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/'. $account->uid .'/rpx');
 }
 
@@ -891,14 +892,14 @@ function _rpx_save_profile_picture(&$acc
           $fields['picture'] = $file->filepath;
           $account = user_save($account, $fields);
         }
-  
+
       }
       // clean up
       file_delete($tmp_photo);
     }
   }
   return $fields;
-  
+
 }
 
 function _rpx_data_map($data, $field) {
