function _fb_user_get_fbu in Drupal for Facebook 5
Same name and namespace in other branches
- 5.2 fb_user.module \_fb_user_get_fbu()
- 6.3 fb_user.module \_fb_user_get_fbu()
- 6.2 fb_user.module \_fb_user_get_fbu()
- 7.3 fb_user.module \_fb_user_get_fbu()
3 calls to _fb_user_get_fbu()
- fb_user_fb in ./
fb_user.module - Implementation of hook_fb.
- fb_user_token_values in ./
fb_user.module - fb_user_user in ./
fb_user.module - Implementation of hook_user.
File
- ./
fb_user.module, line 972 - 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_get_fbu($uid, $fb_app) {
static $cache = array();
if (!$cache[$uid]) {
$cache[$uid] = array();
// Look up this user in the authmap
$result = db_query("SELECT * FROM {authmap} WHERE uid=%d AND authname LIKE '%@facebook.com'", $uid);
while (!$fbu && ($data = db_fetch_object($result))) {
// get the part before the '@'
$substr = substr($data->authname, 0, strpos($data->authname, '@'));
// then split at the '-'
$parts = explode('-', $substr);
if ($parts[1]) {
// $parts[1] is app id
$cache[$uid][$parts[1]] = $parts[0];
}
else {
$cache[$uid]['global'] = $parts[0];
}
}
}
// Return either the global or the app-specific mapping, depending on the app configuration.
$fb_app_data = fb_app_get_data($fb_app);
$fb_user_data = $fb_app_data['fb_user'];
// our configuration
if ($fb_user_data['unique_account']) {
// Return the app-specific mapping
return $cache[$uid][$fb_app->apikey];
}
else {
// Return the global mapping
return $cache[$uid]['global'];
}
}