function janrain_capture_sync_account in Janrain Registration 7
Same name and namespace in other branches
- 7.4 janrain_capture.module \janrain_capture_sync_account()
- 7.2 janrain_capture.module \janrain_capture_sync_account()
- 7.3 janrain_capture.module \janrain_capture_sync_account()
Modifies the user account with values from the Janrain Capture profile array.
Invokes a hook to allow other modules to modify the account as well.
Parameters
$account: The account object to modify with values from the Janrain Capture profile
array $profile: The Janrain Capture profile array.
4 calls to janrain_capture_sync_account()
- JanrainCaptureMappingTestCase::testFieldApiMapping in janrain_capture_mapping/
tests/ janrain_capture_mapping.test - JanrainCaptureMappingTestCase::testPropertyMapping in janrain_capture_mapping/
tests/ janrain_capture_mapping.test - Create some field mappings through the UI and ensure that they work.
- janrain_capture_oauth in ./
janrain_capture.pages.inc - Callback for the janrain_capture/oauth menu item. This serves as the redirect_uri Capture redirects the user to and performs the authentication.
- janrain_capture_profile_sync in ./
janrain_capture.pages.inc - Callback for the janrain_capture/profile_sync menu item. Retrieves the most recent data from Capture and stores values locally.
File
- ./
janrain_capture.module, line 419 - This module implements authentication endpoints for Janrain Capture.
Code
function janrain_capture_sync_account($account, $profile) {
$account->mail = $profile['email'];
// Set the profile email address as the default username - this can be overridden
// either by implementing the janrain_capture_profile_sync hook or using the mapping
// submodule.
$account->name = $profile['email'];
// Set the uuid field value from the Capture uuid. Hardcoding LANGUAGE_NONE here
// should be ok as the field is not translatable.
$account->field_janrain_capture_uuid[LANGUAGE_NONE][0]['value'] = $profile['uuid'];
// Map the profile pic if configured to do so. This requires special handling.
$janrain_capture_fields = variable_get('janrain_capture_fields', array());
if (isset($janrain_capture_fields['capture_map_profile_pic']) && $janrain_capture_fields['capture_map_profile_pic']) {
if (!empty($profile['photos'])) {
$preferred = isset($janrain_capture_fields['capture_preferred_photo_variant']) ? $janrain_capture_fields['capture_preferred_photo_variant'] : 'small';
foreach ($profile['photos'] as $variant) {
if ($variant['type'] == $preferred) {
_janrain_capture_update_picture($account, $variant);
break;
}
}
}
elseif (!empty($account->picture)) {
// We have a local picture, but picture was removed on server. Delete!
$account->picture = new stdClass();
db_delete('janrain_capture_photos')
->condition('uid', $account->uid)
->execute();
}
}
module_invoke_all('janrain_capture_profile_sync', $account, $profile);
}