? .bakery.install.swp
? .bakery.module.swp
Index: bakery.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bakery/Attic/bakery.install,v
retrieving revision 1.1.4.3
diff -u -F '^f' -r1.1.4.3 bakery.install
--- bakery.install	28 Oct 2010 20:40:20 -0000	1.1.4.3
+++ bakery.install	4 Nov 2010 00:09:51 -0000
@@ -1,6 +1,43 @@
 <?php
 // $Id: bakery.install,v 1.1.4.3 2010/10/28 20:40:20 greggles Exp $
 
+function bakery_schema() {
+  return array(
+    'bakery_user' => array(
+      'description' => 'Keep track of UID on subsites, master only.',
+      'fields' => array(
+        'uid' => array(
+          'description' => 'User ID on master site.',
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+        ),
+        'slave' => array(
+          'description' => 'Slave site.',
+          'type' => 'varchar',
+          'length' => 128,
+          'not null' => TRUE,
+        ),
+        'slave_uid' => array(
+          'description' => 'User ID on slave site.',
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+        ),
+      ),
+      'primary key' => array('uid', 'slave'),
+    ),
+  );
+}
+
+function bakery_install() {
+  drupal_install_schema('bakery');
+}
+
+function bakery_uninstall() {
+  drupal_uninstall_schema('bakery');
+}
+
 /**
  * Delete aliases we no longer needed.
  */
@@ -26,3 +63,37 @@ function bakery_update_6002() {
 
   return $ret;
 }
+
+/**
+ * Add {bakery_user}.
+ */
+function bakery_update_6003() {
+  $return = array();
+
+  db_create_table($return, 'bakery_user', array(
+    'description' => 'Keep track of UID on subsites, master only.',
+    'fields' => array(
+      'uid' => array(
+        'description' => 'User ID on master site.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'slave' => array(
+        'description' => 'Slave site.',
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+      ),
+      'slave_uid' => array(
+        'description' => 'User ID on slave site.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('uid', 'slave'),
+  ));
+
+  return $return;
+}
Index: bakery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bakery/bakery.module,v
retrieving revision 1.52.4.9
diff -u -F '^f' -r1.52.4.9 bakery.module
--- bakery.module	1 Nov 2010 22:31:41 -0000	1.52.4.9
+++ bakery.module	4 Nov 2010 00:09:51 -0000
@@ -150,6 +150,16 @@ function bakery_user($op, &$array, &$acc
           drupal_set_message($message);
         }
         watchdog('bakery', $message);
+
+        // Save UID provided by slave site.
+        if (isset($result->headers['X-Drupal-bakery-UID']) && !db_result(db_query_range("SELECT 1 FROM {bakery_user} WHERE uid = %d AND slave = '%s'", $account->uid, $slave, 0, 1))) {
+          $row = array(
+            'uid' => $account->uid,
+            'slave' => $slave,
+            'slave_uid' => $result->headers['X-Drupal-bakery-UID'],
+          );
+          drupal_write_record('bakery_user', $row);
+        }
       }
     }
   }
@@ -970,6 +980,8 @@ function bakery_eat_stroopwafel_cookie()
     $message = t('Account not found on %slave.', array('%slave' => variable_get('site_name', '')));
   }
   else {
+    drupal_set_header('X-Drupal-bakery-UID: ' . $account->uid);
+
     $fields = array();
     foreach (variable_get('bakery_supported_fields', array('mail' => 'mail', 'name' => 'name')) as $type => $value) {
       if ($value) {
