Index: userreference.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/userreference.module,v
retrieving revision 1.21
diff -u -r1.21 userreference.module
--- userreference.module	20 Apr 2006 17:55:19 -0000	1.21
+++ userreference.module	27 Apr 2006 19:19:01 -0000
@@ -63,6 +63,50 @@
   }
 }
 
+/**
+ * Implementation of hook_user().
+ */
+function userreference_user($op, &$edit, &$account, $category = NULL) {
+    
+  // add stubs for other user operations in case needed in the future
+  switch ($op) {
+  case ("categories"): 
+  case ("delete"): 
+  case ("form"): 
+  case ("insert"): 
+  case ("login"): 
+  case ("logout"): 
+  case ("register"): 
+  case ("update"): 
+  case ("validate"): 
+    break;
+  
+  case ("load"): 
+    // find cck userreference field tables
+    // search through them for matching user ids and load those nodes
+    $result = db_query("SELECT * FROM {node_field} nf INNER JOIN {node_field_instance} ni ON nf.field_name = ni.field_name WHERE nf.type='userreference'");
+    while ($field = db_fetch_array($result)) {
+       $db_info = content_database_info($field);
+       $ids = db_query("SELECT vid FROM {". $db_info['table'] ."} WHERE ". $db_info['columns']['uid']['column'] ."=". $account->uid);
+       while ($data = db_fetch_object($ids)) {
+         $additions[] = node_load($data->vid);
+       }
+    }
+    $account->content = $additions;
+    return;
+    break;
+
+  case("view"):
+    $node_types = (array) _content_types();
+    foreach ($account->content as $node) {
+      $links[] = array('title' => $node_types[$node->type]->label, 'value' => l($node->title, 'node/'. $node->nid));
+    }
+    return array(t('Related Content') => $links);
+    break;
+  }
+}
+
+
 
 /**
  * Implementation of hook_widget_info().
