Index: extensions/oAuth/admin/providers.php
===================================================================
--- extensions/oAuth/admin/providers.php	(revision 21583)
+++ extensions/oAuth/admin/providers.php	(revision 21584)
@@ -11,5 +11,4 @@
   foreach ($_POST['providers'] as $id => $data)
   {
-    $error = false;
     $data['enabled'] = $data['enabled']=='true';
     
@@ -21,16 +20,10 @@
       ) {
         array_push($page['errors'], sprintf(l10n('%s: invalid keys'), $PROVIDERS_CONFIG[$id]['provider_name']));
-        $error = true;
       }
     }
-    else
-    {
-      unset($data['keys']);
-    }
     
-    if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] )
+    if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] ) // in the template, OpenID must be before other OpenID based providers
     {
       array_push($page['errors'], sprintf(l10n('OpenID must be enabled in order to use %s authentication'), $id));
-      $error = true;
     }
     
Index: extensions/oAuth/include/providers_stats.inc.php
===================================================================
--- extensions/oAuth/include/providers_stats.inc.php	(revision 21583)
+++ extensions/oAuth/include/providers_stats.inc.php	(revision 21584)
@@ -7,5 +7,4 @@
     'require_client_id' => true,
     'new_app_link'      => 'https://developers.facebook.com/apps',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html',
     'scope'             => 'email',
   ),
@@ -17,5 +16,4 @@
     'require_client_id' => true,
     'new_app_link'      => 'https://code.google.com/apis/console',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html',
     'scope'             => 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
   ),
@@ -26,5 +24,4 @@
     'require_client_id' => true,
     'new_app_link'      => 'http://instagram.com/developer/clients/manage',
-    'userguide_section' => null,
   ),
   'LinkedIn' => array( 
@@ -32,5 +29,4 @@
     'provider_name'     => 'LinkedIn',
     'new_app_link'      => 'https://www.linkedin.com/secure/developer',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_LinkedIn.html',
   ),
   'Tumblr' => array(
@@ -38,5 +34,4 @@
     'provider_name'     => 'Tumblr',
     'new_app_link'      => 'http://www.tumblr.com/oauth/apps',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Tumblr.html',
   ),
   'Twitter' => array( 
@@ -44,5 +39,4 @@
     'provider_name'     => 'Twitter',
     'new_app_link'      => 'https://dev.twitter.com/apps',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Twitter.html',
   ),
   'Live' => array( 
@@ -51,5 +45,4 @@
     'require_client_id' => true,
     'new_app_link'      => 'https://manage.dev.live.com/ApplicationOverview.aspx',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Live.html',
   ),
   'Yahoo' => array( 
@@ -57,5 +50,4 @@
     'provider_name'     => 'Yahoo!',
     'new_app_link'      => 'https://developer.apps.yahoo.com/projects/',
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Yahoo.html',
   ),
   'OpenID' => array( 
@@ -63,5 +55,4 @@
     'provider_name'     => 'OpenID',
     'new_app_link'      => null,
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
   ),
   'Flickr' => array( 
@@ -69,5 +60,4 @@
     'provider_name'     => 'Flickr',
     'new_app_link'      => null,
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
   ),
   'Wordpress' => array( 
@@ -75,5 +65,4 @@
     'provider_name'     => 'Wordpress',
     'new_app_link'      => null,
-    'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
   ),
 );
Index: extensions/oAuth/include/public_events.inc.php
===================================================================
--- extensions/oAuth/include/public_events.inc.php	(revision 21583)
+++ extensions/oAuth/include/public_events.inc.php	(revision 21584)
@@ -61,4 +61,11 @@
       $adapter = $hybridauth->authenticate($provider);
       $remote_user = $adapter->getUserProfile();
+      
+      // security, check remote identifier
+      if ($remote_user->identifier != $user_identifier)
+      {
+        pwg_unset_session_var('oauth_new_user');
+        throw new Exception('Hacking attempt!');
+      }
     
       $template->assign(array(
@@ -73,11 +80,4 @@
       
       $oauth_id = $provider.'---'.$remote_user->identifier;
-      
-      // security, check remote identifier
-      if ($remote_user->identifier != $user_identifier)
-      {
-        pwg_unset_session_var('oauth_new_user');
-        throw new Exception('Hacking attempt!');
-      }
       
       // form submited
@@ -96,5 +96,5 @@
           $user_id = get_userid($_POST['login']);
           
-          // udpdate oauth field
+          // update oauth field
           $query = '
 UPDATE '.USERS_TABLE.'
@@ -235,5 +235,5 @@
   $template->assign('REDIRECT_TO', get_gallery_home_url());
   
-  $template->set_prefilter('menubar', 'oauth_add_menubar_buttons');
+  $template->set_prefilter('menubar', 'oauth_add_menubar_buttons_prefilter');
 }
 
@@ -254,7 +254,7 @@
   $add = 'disabled="disabled" ';
   $script = '
-{footer_script}{literal}
+{footer_script}
 jQuery("input[type=\'password\'], input[name=\'send_password_by_mail\']").parent("li").css("display", "none");
-{/literal}{/footer_script}';
+{/footer_script}';
 
   $content = str_replace($search, $search.$add, $content);
@@ -269,5 +269,5 @@
 }
 
-function oauth_add_menubar_buttons($content)
+function oauth_add_menubar_buttons_prefilter($content)
 {
   $search = '{include file=$block->template|@get_extent:$id }';
Index: extensions/oAuth/template/identification_common.tpl
===================================================================
--- extensions/oAuth/template/identification_common.tpl	(revision 21583)
+++ extensions/oAuth/template/identification_common.tpl	(revision 21584)
@@ -41,6 +41,6 @@
 
 // click on a button
-$("a.oauth").click(function() {
-  var idp = $(this).data('idp');
+jQuery("a.oauth").click(function() {
+  var idp = jQuery(this).data('idp');
   
   switch(idp) {
@@ -49,20 +49,20 @@
 {/literal}
         case 'OpenID':
-          $("#openid_label").html('{'Please enter your OpenID URL'|@translate|escape:javascript}'); break;
+          jQuery("#openid_label").html('{'Please enter your OpenID URL'|@translate|escape:javascript}'); break;
         case 'Wordpress': case 'Flickr':
-          $("#openid_label").html('{'Please enter your username'|@translate|escape:javascript}'); break;
+          jQuery("#openid_label").html('{'Please enter your username'|@translate|escape:javascript}'); break;
       }
       
-      $("#openid_form").css('background-color', $("#the_page #content").css('background-color'));
-      $("#openid_form .oauth_38px").removeClass().addClass("oauth_38px " + idp.toLowerCase());
-      $("#openid_form h3").html(idp);
-      $("#openid_form").data('idp', idp);
+      jQuery("#openid_form").css('background-color', $("#the_page #content").css('background-color'));
+      jQuery("#openid_form .oauth_38px").removeClass().addClass("oauth_38px " + idp.toLowerCase());
+      jQuery("#openid_form h3").html(idp);
+      jQuery("#openid_form").data('idp', idp);
 {literal}  
-      $.colorbox({
+      jQuery.colorbox({
         inline:true,
         href:"#openid_form",
         initialWidth:0,
         initialHeight:0,
-        onComplete:function(){ $.colorbox.resize({speed:0}) } // prevent misalignement when icon not loaded
+        onComplete:function(){ jQuery.colorbox.resize({speed:0}) } // prevent misalignement when icon not loaded
       })
       break;
@@ -77,12 +77,12 @@
 });
 
-$("#openid_form").submit(function() {
-  var idp = $(this).data('idp');
-  var oi = $("#openid_form input[name='openid_identifier']").val();
-  $("#openid_form input[name='openid_identifier']").val('');
+jQuery("#openid_form").submit(function() {
+  var idp = jQuery(this).data('idp');
+  var oi = jQuery("#openid_form input[name='openid_identifier']").val();
+  jQuery("#openid_form input[name='openid_identifier']").val('');
   
-  $("#openid_label").removeClass('error');
+  jQuery("#openid_label").removeClass('error');
   if (!oi) {
-    $("#openid_label").addClass('error');
+    jQuery("#openid_label").addClass('error');
     return false;
   }
@@ -95,11 +95,11 @@
   open_auth("{$OAUTH_URL}OpenID&openid_identifier="+ encodeURI(oi));
 {literal}
-  $.colorbox.close();
+  jQuery.colorbox.close();
   return false;
 });
 
-$("#openid_cancel").click(function() {
-  $("#openid_label").removeClass('error');
-  $.colorbox.close();
+jQuery("#openid_cancel").click(function() {
+  jQuery("#openid_label").removeClass('error');
+  jQuery.colorbox.close();
   return false;
 });
Index: extensions/oAuth/template/identification_menubar.tpl
===================================================================
--- extensions/oAuth/template/identification_menubar.tpl	(revision 21583)
+++ extensions/oAuth/template/identification_menubar.tpl	(revision 21584)
@@ -1,3 +1,3 @@
-{if $id == "mbIdentification" and isset($U_LOGIN)}
+{if $id == "mbIdentification" and isset($U_LOGIN) and count($PROVIDERS)}
   {if not $OAUTH_JS_LOADED}
     {assign var=OAUTH_JS_LOADED value=true}
Index: extensions/oAuth/template/identification_page.tpl
===================================================================
--- extensions/oAuth/template/identification_page.tpl	(revision 21583)
+++ extensions/oAuth/template/identification_page.tpl	(revision 21584)
@@ -1,17 +1,19 @@
-{if not $OAUTH_JS_LOADED}
-  {assign var=OAUTH_JS_LOADED value=true}
-  {include file=$OAUTH_ABS_PATH|cat:'template/identification_common.tpl'}
+{if count($PROVIDERS)}
+  {if not $OAUTH_JS_LOADED}
+    {assign var=OAUTH_JS_LOADED value=true}
+    {include file=$OAUTH_ABS_PATH|cat:'template/identification_common.tpl'}
+  {/if}
+  {html_style}{literal}
+    #oauth_wrap .oauth {
+      margin:0 2px;
+    }
+  {/literal}{/html_style}
+    
+  <fieldset style="text-align:center;" id="oauth_wrap">
+    <legend>{'Or sign in with'|@translate}</legend>
+    
+  {foreach from=$PROVIDERS item=provider key=p}{strip}
+    <a href="#" class="oauth oauth_{$oauth.identification_icon} {$p|strtolower}" data-idp="{$p}" title="{$provider.name}"></a>
+  {/strip}{/foreach}
+  </fieldset>
 {/if}
-{html_style}{literal}
-  #oauth_wrap .oauth {
-    margin:0 2px;
-  }
-{/literal}{/html_style}
-  
-<fieldset style="text-align:center;" id="oauth_wrap">
-  <legend>{'Or sign in with'|@translate}</legend>
-  
-{foreach from=$PROVIDERS item=provider key=p}{strip}
-  <a href="#" class="oauth oauth_{$oauth.identification_icon} {$p|strtolower}" data-idp="{$p}" title="{$provider.name}"></a>
-{/strip}{/foreach}
-</fieldset>
