You are here

function _fb_user_set_map in Drupal for Facebook 7.4

Same name and namespace in other branches
  1. 6.3 fb_user.module \_fb_user_set_map()
  2. 7.3 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.

2 calls to _fb_user_set_map()
_fb_user_create_local_account in ./fb_user.module
_fb_user_process_new_token in ./fb_user.module

File

./fb_user.module, line 264
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,
      ));
    }
  }
}