Common subdirectories: ../../../../drupal-4.7/modules/contrib/usernode/CVS and usernode/CVS
diff -uN ../../../../drupal-4.7/modules/contrib/usernode/usernode.info usernode/usernode.info
--- ../../../../drupal-4.7/modules/contrib/usernode/usernode.info	1970-01-01 01:00:00.000000000 +0100
+++ usernode/usernode.info	2007-01-08 21:59:53.000000000 +0100
@@ -0,0 +1,4 @@
+; $Id$
+
+name = "Usernode"
+description = "Automatic creation of usernodes"
diff -uN ../../../../drupal-4.7/modules/contrib/usernode/usernode.install usernode/usernode.install
--- ../../../../drupal-4.7/modules/contrib/usernode/usernode.install	2006-11-03 00:29:18.000000000 +0100
+++ usernode/usernode.install	2007-01-08 21:59:53.000000000 +0100
@@ -2,10 +2,9 @@
 // $Id: usernode.install,v 1.2.2.1 2006/11/02 23:29:18 fago Exp $
 
 function usernode_install() {
-
   switch ($GLOBALS['db_type']) {
     case 'mysqli':
-    case 'mysql':     
+    case 'mysql':
       db_query("CREATE TABLE if not exists {usernode} (
         nid int(10) unsigned NOT NULL,
         uid int(10) unsigned NOT NULL,
@@ -17,10 +16,25 @@
         nid integer NOT NULL,
         uid integer NOT NULL,
         PRIMARY KEY(uid,nid)
-      )");   
+      )");
+      break;
     default:
       break;
   }
-  
-  usernode_check_all();
+}
+
+function usernode_uninstall() {
+  include_once('usernode.module');
+
+  // We can't call node_type_delete() because usernode_delete() forbids that,
+  // so let's find and delete the usernodes manually
+  $result = db_query("SELECT u.* FROM {users} u ".
+                     "JOIN {node} n ON u.uid = n.uid ".
+                     "WHERE n.type = '". USERNODE_CONTENT_TYPE ."'");
+
+  while ($user = db_fetch_object($result)) {
+    usernode_delete_node($user);
+  }
+
+  db_query('DROP TABLE {usernode}');
 }
diff -uN ../../../../drupal-4.7/modules/contrib/usernode/usernode.module usernode/usernode.module
--- ../../../../drupal-4.7/modules/contrib/usernode/usernode.module	2007-01-08 21:56:56.000000000 +0100
+++ usernode/usernode.module	2007-01-08 22:04:19.000000000 +0100
@@ -18,7 +18,12 @@
  * Usernode custom nodetype
  */
 function usernode_node_info() {
-  return array('usernode' => array('name' => t('Usernode'), 'base' => 'usernode'));
+  return array(
+    'usernode' => array(
+      'name' => t('Usernode'),
+      'module' => 'usernode'),
+      'description' => t('A page which is automatically generated for each user.'),
+    );
 }
 
 /**
@@ -71,25 +76,37 @@
 /**
  * Implementation of hook_view().
  */
-function usernode_view(&$node, $teaser = FALSE, $page = FALSE) {
+function usernode_view($node, $teaser = FALSE, $page = FALSE) {
+  $node = node_prepare($node, $teaser);
+
   $node->user = usernode_get_user($node);
 
-  $node->body = '<dl><dt class="user-member">';
-  $node->body .= t('Member for') . '</dt><dd class="user-member">';
-  $node->body .= format_interval(time() - $node->user->created) . '</dl>';
+  $member = '<dl><dt class="user-member">';
+  $member .= t('Member for') . '</dt><dd class="user-member">';
+  $member .= format_interval(time() - $node->user->created) . '</dl>';
 
-  if (module_exist('nodefamily')) {
+  $node->content['user_member'] = array(
+    '#value' => theme('usernode_member', $member),
+    '#weight' => -9,
+  );
+
+  if (module_exists('nodefamily')) {
     nodefamily_relation_load($node);
     if ($node->children) {
-      $node->body .= '<ul>';
+      $children = '<ul>';
       foreach ($node->children as $profile) {
-        $node->body .= '<li>'. l($profile->title, 'node/'. $profile->nid) .'</li>';
+        $children .= '<li>'. l($profile->title, 'node/'. $profile->nid) .'</li>';
       }
-      $node->body .= '</ul>';
+      $children .= '</ul>';
+
+      $node->content['child_nodes'] = array(
+        '#value' => theme('usernode_child_nodes', $children),
+        '#weight' => 1,
+      );
     }
   }
 
-  $node->teaser = $node->body;
+  return $node;
 }
 
 /**
@@ -102,20 +119,20 @@
 
   $user = usernode_get_user($node);
 
-  //the node has already been deleted, so save it again
+  // the node has already been deleted, so save it again
   $nid = $node->nid;
   unset($node->nid);
 
   node_save($node);
 
-  //change to old nid
+  // change to old nid
   db_query("UPDATE {node} SET nid = %d WHERE nid = %d", $nid, $node->nid);
   db_query("UPDATE {node_revisions} SET nid = %d WHERE nid = %d", $nid, $node->nid);
 
-  //simulate deleting of new nid
+  // simulate deleting of new nid
   node_invoke_nodeapi($node, 'delete');
 
-  //prevent other modules from reacting on old node deletion through nodeapi
+  // prevent other modules from reacting on old node deletion through nodeapi
   // TODO: redirect to the referrer, not to the homepage.
   drupal_goto('');
 }
@@ -125,16 +142,6 @@
  */
 
 /**
- * Implementation of hook_help().
- */
-function usernode_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Automatically creation of usernodes.');
-  }
-}
-
-/**
  * Implementation of hook_user().
  */
 function usernode_user($type, &$edit, &$user, $category = NULL) {
@@ -206,19 +213,18 @@
  * Create an associated node. Called by hook_user();
  */
 function usernode_create_node(&$user) {
-  $node = (object)array();
-  $node->type = USERNODE_CONTENT_TYPE;
-  node_object_prepare($node);
-
-  $node->name = $user->name;
-  $node->uid = $user->uid;
-  $node->type = USERNODE_CONTENT_TYPE;
-  $node->title = check_plain($user->name);
-  $node = node_submit($node);
-  $node->status = $node->status && $user->status;
-  node_save($node);
+  $node = array('type' => USERNODE_CONTENT_TYPE);
 
-  db_query("INSERT INTO {usernode} (nid,uid) VALUES(%d,%d)",$node->nid, $user->uid);
+  $values = array();
+  $values['name'] = $user->name;
+  $values['title'] = check_plain($user->name);
+
+  drupal_execute(USERNODE_CONTENT_TYPE .'_node_form', $values, $node);
+
+  $nid = db_result(db_query("SELECT nid FROM {node} ".
+                            "WHERE uid = %d AND type = '". USERNODE_CONTENT_TYPE ."'",
+                            $user->uid));
+  db_query("INSERT INTO {usernode} (nid,uid) VALUES(%d,%d)", $nid, $user->uid);
 }
 
 /**
@@ -319,7 +325,7 @@
  * one if necessary.
  */
 function usernode_check_all() {
-  //find usernodes that have been deleted while the module was deactivated
+  // find usernodes that have been deleted while the module was deactivated
   $result = db_query("SELECT un.* FROM {usernode} un ".
                      "LEFT JOIN {node} n ON un.nid = n.nid ".
                      "WHERE n.nid IS NULL");
@@ -328,7 +334,7 @@
     db_query("DELETE FROM {usernode} WHERE nid = %d", $row->nid);
   }
 
-  //create usernodes for all existing users without a usernode
+  // create usernodes for all existing users without a usernode
   $result = db_query("SELECT u.* FROM {users} u ".
                      "LEFT JOIN {usernode} un ON u.uid = un.uid ".
                      "WHERE un.nid IS NULL AND u.uid != 0");
@@ -339,26 +345,29 @@
 }
 
 /*
+ * Implementation of hook_enable().
+ */
+function usernode_enable() {
+  // if the module is activated, we recheck the usernodes
+  usernode_check_all();
+}
+
+/*
  * Implementation of hook_form_alter().
  */
 function usernode_form_alter($form_id, &$form) {
-  //if the module is activated, we recheck the usernodes
-  if ($form_id == 'system_modules' && !$_POST) {
-    usernode_check_all();
-  }
-
   if ($form_id == USERNODE_CONTENT_TYPE .'_node_form' && !$_POST) {
     unset($form['delete']);
   }
 }
 
 /*
- * Implementation of hook_nodeapi
+ * Implementation of hook_validate
  */
-function usernode_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
-  if($op == 'validate' && $node->type == USERNODE_CONTENT_TYPE) {
-    $user = usernode_get_user($node);
-    if ($user->name != $node->title) {
+function usernode_validate($node) {
+  $user = usernode_get_user($node);
+  if (!empty($user)) { // on node creation, there is no user/node relationship yet
+    if (check_plain($user->name) != $node->title) {
       form_set_error('title', t('You mustn\'t change the title. '.
         'Change the name of the user and the title is going to be updated.'));
     }
@@ -368,7 +377,7 @@
 /*
  * Implementation of hook_link
  */
-function usernode_link($type, &$node, $teaser) {
+function usernode_link($type, &$node = NULL, $teaser = FALSE) {
   if ($type == 'node' && $node->type == USERNODE_CONTENT_TYPE && !$teaser) {
     $node->user = usernode_get_user($node);
     if ($node->user->uid && $node->user->name && user_access('access user profiles')) {
