You are here

function _fb_user_set_map in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_user.module \_fb_user_set_map()
  2. 7.4 fb_user.module \_fb_user_set_map()

Helper function to add or update a row in the fb_user table, which maps local uid to facebook ids.

6 calls to _fb_user_set_map()
fb_user_create_local_user in ./fb_user.module
Creates a local Drupal account for the specified facebook user id.
fb_user_user_insert in ./fb_user.module
Implements hook_user_insert.
fb_user_user_login in ./fb_user.module
Implements hook_user_login.
fb_user_user_update in ./fb_user.module
Implements hook_user_update().
_fb_user_create_map in ./fb_user.module
Create a map linking the facebook account to the currently logged in local user account.

... See full list

File

./fb_user.module, line 972
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function _fb_user_set_map($account, $fbu) {
  if ($fbu && $account->uid != 0) {

    // Delete any pre-existing mapping that might exist for this local uid or fbu.
    db_query("DELETE FROM {fb_user} WHERE uid=:uid OR fbu=:fbu", array(
      ':uid' => $account->uid,
      ':fbu' => $fbu,
    ));

    // Create the new mapping.
    db_query("INSERT INTO {fb_user} (uid, fbu) VALUES (:uid, :fbu)", array(
      ':uid' => $account->uid,
      ':fbu' => $fbu,
    ));
    if (fb_verbose()) {
      watchdog('fb_user', 'Using fb_user to associate user !user with facebook user id %fbu.', array(
        '!user' => l($account->name, 'user/' . $account->uid),
        '%fbu' => $fbu,
      ));
    }
  }
}