Index: bakery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bakery/bakery.module,v
retrieving revision 1.52.2.1
diff -u -p -r1.52.2.1 bakery.module
--- bakery.module	29 Apr 2010 23:52:19 -0000	1.52.2.1
+++ bakery.module	30 Apr 2010 22:35:48 -0000
@@ -99,6 +99,11 @@ function bakery_user($op, &$array, &$acc
     _bakery_eat_cookie(session_name());
   }
   else if ($op == 'update' && variable_get('bakery_is_master', 0)) {
+    // Invoke implementations of Bakery transmit hook for syncing arbitrary data.
+    $transmit = module_invoke_all('bakery_transmit', $edit, $account, $category);
+    if (!empty($transmit)) {
+      $_SESSION['bakery'] = $transmit;
+    }
     // We store email/name if they changed. We want to wait with doing
     // anything else until the changes are saved locally.
     foreach (variable_get('bakery_supported_fields', array('mail' => 'mail', 'name' => 'name')) as $type => $enabled) {
@@ -508,7 +513,7 @@ function bakery_taste_stroopwafel_cookie
 
     if ($signature == $cookie['signature'] && $cookie['timestamp'] + variable_get('bakery_freshness', '3600') >= $_SERVER['REQUEST_TIME']) {
       $valid = TRUE;
-      $_SESSION['bakery'] = unserialize($cookie['data']);
+      $_SESSION['bakery']['data'] = unserialize($cookie['data']);
       $_SESSION['bakery']['uid'] = $cookie['uid'];
       $_SESSION['bakery']['category'] = $cookie['category'];
     }
@@ -580,7 +585,9 @@ function bakery_eat_stroopwafel_cookie()
     $fields = array();
     foreach (variable_get('bakery_supported_fields', array('mail' => 'mail', 'name' => 'name')) as $type => $value) {
       if ($value) {
-        $fields[$type] = isset($stroopwafel[$type]) ? $stroopwafel[$type] : $account->$type;
+        $fields[$type] = isset($stroopwafel['data'][$type]) ? $stroopwafel['data'][$type] : $account->$type;
+        // Unset this value since we've put it into $fields.
+        unset($stroopwafel['data'][$type]);
       }
     }
     $status = user_save($account, $fields, $stroopwafel['category']);
@@ -593,6 +600,10 @@ function bakery_eat_stroopwafel_cookie()
       watchdog('bakery', 'user updated name %name_old to %name_new, mail %mail_old to %mail_new.', array('%name_old' => $account->name, '%name_new' => $stroopwafel['name'], '%mail_old' => $account->mail, '%mail_new' => $stroopwafel['mail']));
       $message = t('Successfully updated account on %slave.', array('%slave' => variable_get('site_name', '')));
     }
+    if (!empty($stroopwafel['data'])) {
+      // More data to sync, invoke Bakery receive hook.
+      module_invoke_all('bakery_receive', $account, $stroopwafel['data']);
+    }
   }
 
   module_invoke_all('exit');
