Index: bio.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/bio/bio.install,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 bio.install
--- bio.install	20 May 2007 18:42:29 -0000	1.1.2.1
+++ bio.install	3 Jan 2008 08:22:15 -0000
@@ -1,11 +1,37 @@
-<?php // $Id: bio.install,v 1.1.2.1 2007/05/20 18:42:29 jjeff Exp $
+<?php
+// $Id: bio.install,v 1.1.2.1 2007/05/20 18:42:29 jjeff Exp $
 
+/**
+ * Implementation of hook_install().
+ */
+function bio_install() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_query("CREATE TABLE {bio} (
+        nid int unsigned NOT NULL default '0',
+        uid int unsigned NOT NULL default '0',
+        PRIMARY KEY (nid, uid),
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+    case 'pgsql':
+      db_query("CREATE TABLE {bio} (
+        nid int_unsigned NOT NULL default '0',
+        uid int_unsigned NOT NULL default '0',
+        PRIMARY KEY (nid, uid)
+      )");
+      break;
+  }
+}
+
+/**
+ * Copy per-nodetype link settings into different format.
+ */
 function bio_update_1() {
   $ret = array();
 
-  // copy per-nodetype link settings into different format
   $bio_link = array();
-  foreach(node_get_types() as $key => $type) {
+  foreach (node_get_types() as $key => $type) {
     $bio_link[$key] = variable_get('bio_'.$key, 0) ? $key : 0;
   }
   variable_set('bio_link', $bio_link);
@@ -18,3 +44,42 @@ function bio_update_1() {
 
   return $ret;
 }
+
+/*
+ * 5.x-1.x specific updates.
+ */
+
+/**
+ * Creates and populates a table to hold uid/nid combination.
+ *
+ * Workaround for node_user's annoying behaviour of anonymizing bio nodes
+ * which prevents us from deleting them. 
+ */
+function bio_update_5100() {
+  $ret = array();
+
+  // Create bio table.
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("CREATE TABLE {bio} (
+        nid int unsigned NOT NULL default '0',
+        uid int unsigned NOT NULL default '0',
+        PRIMARY KEY (nid, uid)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+    case 'pgsql':
+      $ret[] = update_sql("CREATE TABLE {bio} (
+        nid int_unsigned NOT NULL default '0',
+        uid int_unsigned NOT NULL default '0',
+        PRIMARY KEY (nid, uid)
+      )");
+      break;
+  }
+
+  // Populate table.
+  $type = db_escape_string(variable_get('bio_nodetype', 'bio'));
+  $ret[] = update_sql("INSERT INTO {bio} SELECT nid, uid FROM {node} WHERE type = '$type' AND uid <> 0");
+
+  return $ret;
+}
Index: bio.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/bio/bio.module,v
retrieving revision 1.2.2.17
diff -u -p -r1.2.2.17 bio.module
--- bio.module	17 Dec 2007 02:04:58 -0000	1.2.2.17
+++ bio.module	3 Jan 2008 08:22:16 -0000
@@ -217,6 +217,10 @@ function bio_nodeapi(&$node, $op, $a3 = 
         form_set_error('name', t('This user already has a @bio. Edit it <a href="@link">here</a> or assign this entry to another user.', array('@bio' => node_get_types('name', $node), '@link' => url('node/'.$nid.'/edit'))));
       } 
       break;
+    case 'insert':
+      // Record user's bio in bio table.
+      db_query('INSERT INTO {bio} (nid, uid) VALUES (%d, %d)', $node->nid, $node->uid);
+
   }
 }
 
@@ -225,14 +229,17 @@ function bio_nodeapi(&$node, $op, $a3 = 
  * 
  * - add bio to main user profile page
  */
-function bio_user($op, &$edit, &$user, $category = NULL) {
+function bio_user($op, &$edit, &$account, $category = NULL) {
   if (!variable_get('bio_profile', 0)) return;
 
   switch ($op) {
     case 'view':
-      if (!$nid = bio_for_user($user->uid)) return;
+      if (!$nid = bio_for_user($account->uid)) return;
       if (!node_access('view', $node = node_load($nid))) return;
       return array(node_get_types('name', variable_get('bio_nodetype', 'bio')) => array('bio' => array('value' => node_view($node, FALSE, TRUE, FALSE))));
+      break;
+    case 'delete':
+      node_delete(bio_for_user($account->uid));
   }
 }
 
@@ -260,11 +267,11 @@ function bio_link($type, $node = NULL, $
  * FALSE if user has no bio node
  */
 function bio_for_user($uid = NULL){
-  if (is_null($uid)){
+  if (is_null($uid)) {
     global $user;
     $uid = $user->uid;
   }
-  return db_result(db_query("SELECT nid FROM {node} WHERE uid = %d AND type = '%s'", $uid, variable_get('bio_nodetype', 'bio')));
+  return db_result(db_query('SELECT nid FROM {bio} WHERE uid = %d', $uid));
 }
 
 /**
