function _fb_user_track in Drupal for Facebook 5
Same name and namespace in other branches
- 5.2 fb_user.module \_fb_user_track()
- 6.2 fb_user.module \_fb_user_track()
2 calls to _fb_user_track()
- fb_user_fb in ./
fb_user.module - Implementation of hook_fb.
- fb_user_post_remove_cb in ./
fb_user.module - The post-remove page is visited by Facebook after a user removes the application. The user never visits the page, it is simply called by Facebook to notify us of the change.
File
- ./
fb_user.module, line 359 - This module allows Drupal user records to be associated with Facebook user ids. It can create local user accounts when Facebook users visit an application's canvas pages.
Code
function _fb_user_track($fb, $fb_app, $user) {
// Keep track of all our app users. We need this info when updating
// profiles during cron. We keep session keys in case user has an
// infinite session, and we can actually log in as them during cron.
// TODO: is this a violation of facebook terms?
// In special cases, do not modify the uid column.
$fb_app_data = fb_app_get_data($fb_app);
$fb_user_data = $fb_app_data['fb_user'];
// our configuration
if (!$user->uid || $user->uid == $fb_user_data['not_logged_in_uid'] || $user->uid == $fb_user_data['logged_in_uid']) {
$result = db_query("REPLACE INTO {fb_user_app} (apikey, fbu, added, time_access, session_key, session_key_expires) VALUES ('%s', %d, %d, %d, '%s', %d)", $fb_app->apikey, fb_facebook_user(), $fb->api_client
->users_isAppAdded(), time(), $fb->api_client->session_key, $_REQUEST['fb_sig_expires']);
}
else {
// Uid is accurate.
$result = db_query("REPLACE INTO {fb_user_app} (apikey, fbu, uid, added, time_access, session_key, session_key_expires) VALUES ('%s', %d, %d, %d, %d, '%s', %d)", $fb_app->apikey, fb_facebook_user(), $user->uid, $fb->api_client
->users_isAppAdded(), time(), $fb->api_client->session_key, $_REQUEST['fb_sig_expires']);
}
if ($result === FALSE) {
watchdog('fb_user', t("Failed to update fb_user_app table."), WATCHDOG_ERROR);
}
}