summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fb_user.module20
1 files changed, 4 insertions, 16 deletions
diff --git a/fb_user.module b/fb_user.module
index cf32a0a..852abf5 100644
--- a/fb_user.module
+++ b/fb_user.module
@@ -768,24 +768,12 @@ function fb_user_user($op, &$edit, &$account, $category = NULL) {
function _fb_user_set_map($account, $fbu) {
if ($fbu &&
$account->uid != 0) {
- $an_fb_user = array(
- 'uid' => $account->uid,
- 'fbu' => $fbu,
- );
- // test if record exists
- // @TODO - should this be DELETE FROM {fb_user} WHERE uid=%d OR fbu=%d?
- $sql = "SELECT count(*) AS c FROM {fb_user} WHERE uid = %d";
- $result = db_query($sql, $account->uid);
+ // Delete any pre-existing mapping that might exist for this local uid or fbu.
+ db_query("DELETE FROM {fb_user} WHERE uid=%d OR fbu=%d", $account->uid, $fbu);
- $rec = db_fetch_object($result);
- if ($rec->c > 0) {
- // exists so send along keys for drupal_write_record to update record
- $result = drupal_write_record('fb_user', $an_fb_user, "uid");
- }
- else {
- $result = drupal_write_record('fb_user', $an_fb_user);
- }
+ // Create the new mapping.
+ db_query("INSERT INTO {fb_user} (uid, fbu) VALUES (%d, %d)", $account->uid, $fbu);
if (fb_verbose()) {
watchdog('fb_user', 'Using fb_user to associate user !user with facebook user id %fbu.',