summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Cohen2009-02-02 19:34:27 (GMT)
committer Dave Cohen2009-02-02 19:34:27 (GMT)
commit357aa34e03e0c8515a6bcadb9183ea88ff19be3f (patch)
treee18af1adf8d811ff00609b3cc6c5a9db990cc945
parentfbeda9d543aeec6f13b5b00050d88ef1cf4fec1d (diff)
use hook_fb to allow other modules to inject javascript after fb connect init.
-rw-r--r--fb_connect.module14
1 files changed, 10 insertions, 4 deletions
diff --git a/fb_connect.module b/fb_connect.module
index a9d4bd8..35b9449 100644
--- a/fb_connect.module
+++ b/fb_connect.module
@@ -74,12 +74,14 @@ function fb_connect_expire($apikey) {
function fb_connect_app_init($fb_app) {
$fb = fb_api_init($fb_app, FB_FBU_CURRENT);
$fbu = $fb->get_loggedin_user();
+ // TODO: sometimes this method indicates we are logged in when we really are not. Find a way to verify.
if ($fbu) {
// The user has authorized the app and we now know something about them. Use a hook to trigger the actions of other modules.
fb_invoke(FB_OP_APP_IS_AUTHORIZED, array('fbu' => $fbu,
- 'fb_app' => $fb_app,
- 'fb' => $fb));
+ 'fb_app' => $fb_app,
+ 'fb' => $fb));
}
+
// Store state in session
if (!$_SESSION['fb_connect']) {
$_SESSION['fb_connect'] = array();
@@ -177,6 +179,10 @@ function fb_connect_footer($is_front) {
$feature_data = fb_connect_require_feature();
if (count($feature_data)) {
foreach ($feature_data as $data) {
+ // Give other modules a chance to add javascript which executes after init.
+ $extra = fb_invoke(FB_OP_CONNECT_JS_INIT, $data, array());
+ $extra_js = implode("\n", $extra);
+
$fb_app = $data['fb_app'];
$features = $data['features'];
// drupal_add_js cannot add external javascript, so we use hook_footer instead.
@@ -194,7 +200,7 @@ function fb_connect_footer($is_front) {
//FB.FBDebug.isEnabled = true;
FB.Facebook.init(\"{$fb_app->apikey}\", \"{$receiver}\");
-
+ {$extra_js}
});
});
</script>\n";
@@ -233,8 +239,8 @@ function fb_connect_block($op = 'list', $delta = 0, $edit = array()) {
// Login block
$label = substr($delta, 6); // length of 'login_'
$fb_app = fb_get_app(array('label' => $label));
- $fbu = fb_connect_already_loggedin($fb_app);
$fb = fb_connect_app_init($fb_app);
+ $fbu = fb_connect_already_loggedin($fb_app);
fb_connect_require_feature('XFBML', $fb_app);
$base = drupal_get_path('module', 'fb_connect');