summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fb.admin.inc7
-rw-r--r--fb.js23
-rw-r--r--fb.module3
3 files changed, 23 insertions, 10 deletions
diff --git a/fb.admin.inc b/fb.admin.inc
index e076b55..1c4a667 100644
--- a/fb.admin.inc
+++ b/fb.admin.inc
@@ -311,6 +311,13 @@ function fb_admin_settings() {
'#description' => t('Store tokens and data needed by facebook\'s libraries in Drupal\'s session. Helps applications work even when third-party cookies are denied.'),
);
+ $form['fb_admin_session'][FB_VAR_RELOAD_APPEND_HASH] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Append hash on javascript page reload'),
+ '#default_value' => variable_get(FB_VAR_RELOAD_APPEND_HASH, FALSE),
+ '#description' => t('When fb.js reloads (on session change), append a query parameter which serves two purposes. First, it will break through a cache which may be desireable when facebook session changes. Second, it prevents infinite reloads when third-party cookies are not enabled. Enable this if you encounter either of those problems.'),
+ );
+
$form['fb_admin_languages'] = array(
'#title' => t('Languages and Locales'),
'#type' => 'fieldset',
diff --git a/fb.js b/fb.js
index 3292979..5667420 100644
--- a/fb.js
+++ b/fb.js
@@ -69,20 +69,23 @@ FB_JS.getUrlVars = function(href) {
/**
* Reload the current page, whether on canvas page or facebook connect.
+ *
+ * append fbsig, a hash of the session data, to avoid infinite reloads
+ * in some cases.
*/
FB_JS.reload = function(destination) {
- // Determine fbu.
+ // Determine url hash.
var session = FB.getSession();
- var fbu;
+ var fbhash;
if (session != null)
- fbu = session.uid;
+ fbhash = session.sig; // Use sig rather than compute a new hash.
else
- fbu = 0;
+ fbhash = 0;
- // Avoid infinite reloads
+ // Avoid infinite reloads. Still needed? It would be nice to do away with this code if not needed.
///@TODO - does not work on iframe because facebook does not pass url args to canvas frame when cookies not accepted. http://forum.developers.facebook.net/viewtopic.php?id=77236
var vars = FB_JS.getUrlVars(window.location.href);
- if (vars.fbu == fbu) {
+ if (vars.fbhash == fbhash) {
return; // Do not reload (again)
}
@@ -108,11 +111,13 @@ FB_JS.reload = function(destination) {
path = destination.substr(0, destination.indexOf('?'));
}
- // Add fbu to params before reload.
- vars.push('fbu=' + fbu);
+ // Add fbhash to params before reload.
+ if (Drupal.settings.fb.reload_url_append_hash) {
+ vars.push('fbhash=' + fbhash);
+ }
// Use window.top for iframe canvas pages.
- destination = path + '?' + vars.join('&');
+ destination = vars.length ? (path + '?' + vars.join('&')) : path;
if(Drupal.settings.fb.reload_url_fragment) {
destination = destination + "#" + Drupal.settings.fb.reload_url_fragment;
diff --git a/fb.module b/fb.module
index 11ab5eb..1259e70 100644
--- a/fb.module
+++ b/fb.module
@@ -58,6 +58,7 @@ define('FB_VAR_APIKEY', 'fb_apikey'); // Deprecated. Use FB_VAR_ID
define('FB_VAR_ID', 'fb_id');
define('FB_VAR_USE_COOKIE', 'fb_use_cookie');
define('FB_VAR_USE_SESSION', 'fb_use_session');
+define('FB_VAR_RELOAD_APPEND_HASH', 'fb_reload_append_hash');
define('FB_VAR_CURL_NOVERIFY', 'fb_curl_noverify');
// node_access realms (belongs here?)
@@ -260,7 +261,7 @@ function fb_init() {
'fb_canvas' => fb_is_canvas(),
'language' => (object) array('prefix' => NULL, 'language' => NULL), // http://drupal.org/node/1000452
)));
-
+ fb_js_settings('reload_url_append_hash', variable_get(FB_VAR_RELOAD_APPEND_HASH, FALSE));
}
if ($channel = variable_get(FB_VAR_JS_CHANNEL, TRUE)) {