Created
February 14, 2013 17:22
-
-
Save tloudon/4954427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 function mongodb_session_user_update($edit, $account) { | |
21 // Update field values for changed values of the user. | |
22 $roles = _mongodb_session_get_roles($account); | |
23 // If mongodb_field_storage is enabled it will take care of creating | |
24 // initial user entry just add roles to it. | |
25 if (module_exists('mongodb_field_storage')) { | |
26 $wrote = &drupal_static('mongodb_field_storage_field_storage_write', array()); | |
27 $wrote['user'][$account->uid] = TRUE; | |
28 $save = array( | |
29 '$set' => array('roles' => $roles) | |
30 ); | |
31 } | |
32 else { | |
33 $save = array( | |
34 '$set' => (array) $account + array( | |
35 '_id' => (int) $account->uid, | |
36 '_bundle' => 'user', | |
37 'roles' => $roles, | |
38 ), | |
39 ); | |
40 foreach (array('uid', 'created', 'access', 'login', 'status', 'picture') as $key) { | |
41 $save['$set'][$key] = (int) $save['$set'][$key]; | |
42 } | |
43 } | |
44 mongodb_collection('fields_current', 'user')->update(array('_id' => (int) $account->uid), $save, array('upsert' => TRUE)); | |
45 return $roles; | |
46 } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment