Skip to content

Instantly share code, notes, and snippets.

@tloudon
Created February 14, 2013 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tloudon/4954427 to your computer and use it in GitHub Desktop.
Save tloudon/4954427 to your computer and use it in GitHub Desktop.
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