You are here

function fbconnect_profile_insert_user_info in Facebook Connect 5

Enregistre les informations du profile facebook.

Parameters

Array $fields_setting:

3 calls to fbconnect_profile_insert_user_info()
fbconnect_profile_check_profile_cache in modules/fbconnect_profile/fbconnect_profile.module
fbconnect_profile_user_settings_submit in modules/fbconnect_profile/fbconnect_profile.module
fbconnect_register_form_submit in ./fbconnect.module
Handle post-validation register form submission.

File

modules/fbconnect_profile/fbconnect_profile.module, line 270
This module allows users to import their personal information from Facebook.

Code

function fbconnect_profile_insert_user_info($uid, $fields_setting) {
  $fbuid = fbconnect_get_fbuid();
  $fb_user_profile = fbconnect_get_info_from_fb($fbuid, implode(',', $fields_setting));
  if (count($fields_setting) != count($fb_user_profile)) {
    watchdog('fbconnect', 'Error importing from facebook for fbuid : %fbuid', array(
      '%fbuid' => $fbuid,
    ));
    drupal_set_message(t('Error importing from facebook'), 'error');
    return FALSE;
  }

  // Drupal uid
  $fields[] = 'uid';
  $values[] = $uid;
  $s[] = "%d";
  foreach ($fb_user_profile as $key => $value) {
    $fields[] = $key;
    $values[] = is_array($value) ? serialize($value) : $value;
    $s[] = "'%s'";
  }

  // Save user information imported from Facebook
  db_query('REPLACE INTO {fbconnect_profile} (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $s) . ')', $values);

  // Update the 24h cache timer and save fields settings.
  db_query("UPDATE {fbconnect_users} SET timestamp = %d, import_setting = '%s' WHERE uid = %d", time(), serialize($fields_setting), $uid);
  return TRUE;
}