'#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',
/**
* 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)
}
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;
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?)
'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)) {