Index: content_profile.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_profile/Attic/content_profile.module,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 content_profile.module
--- content_profile.module	5 Feb 2008 19:35:52 -0000	1.1.2.4
+++ content_profile.module	5 Feb 2008 19:57:18 -0000
@@ -181,42 +181,20 @@
  * Implementation of hook_user():
  */
 function content_profile_user($op, &$edit, &$account, $category = NULL) {
-  global $user;
-
   switch ($op) {
     case 'view':
       $account->content['content_profile'] = content_profile_show_profiles($account->uid);
       break;
 
     case 'delete':
-      // retrieve profile node types to be deleted
-      $typenames = array();
-      foreach (node_get_types('names') as $typename => $visiblename) {
-        if (is_content_profile($typename)) {
-          $typenames[] = $typename;
-          //$typenames = array_merge($typenames, nodefamily_get_descendant_types($typename));
-        }
-      }
-
-      // Retrieve the matching profile nodes for this user by issueing an SQL
-      // query. node_load() doesn't work, because its own query still requires
-      // the user to be in the {user} table, which is not the case anymore.
-      // That node_load() doesn't work also means that node_delete() doesn't
-      // work, which is why we have to use _content_profile_node_delete() instead.
-      $cond = array();
-      $arguments = array();
-
-      foreach (content_profile_get_types() as $type => $type_info) {
-        $cond[] = "type = '%s'";
-        $arguments[] = $type;
-      }
-      $cond = implode(' OR ', $cond);
-      $arguments[] = $account->uid;
-
-      if ($cond) {
-        $result = db_query("SELECT * FROM {node} WHERE (". $cond .") AND uid = %d", $arguments);
-        while ($node = db_fetch_object($result)) {
-          _content_profile_node_delete($node);
+      // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
+      if ($types = content_profile_get_types()) {
+        $condition = array_fill(0, count($types), "type = '%s'");
+        $arguments = array_merge(array_keys($types), array($account->uid));
+
+        $result = db_query("SELECT * FROM {node} WHERE (". implode(', ', $condition) .") AND uid = %d", $arguments);
+        while ($row = db_fetch_object($result)) {
+          node_delete($row->nid);
         }
       }
       break;
@@ -224,56 +202,6 @@
 }
 
 /**
- * The original node_delete() function uses node_load() to get the $node object.
- * Unfortunately, when a hook_user('delete') is called, node_load() doesn't
- * work anymore because the user has already been deleted, and node_load()
- * still expects the user to exist in the {user} table.
- *
- * So this is a modified copy of node_delete() that deletes a node without
- * calling node_load(), taking the full $node object (as retrieved by a simple
- * "SELECT * FROM {node}" query) instead of just the $nid.
- */
-function _content_profile_node_delete($node) {
-
-  // Copied over from node_load(), so that node_invoke('delete') gets
-  // the fully extended node object, like modules would expect:
-
-  if ($node->nid) {
-    // Call the node specific callback (if any) and piggy-back the
-    // results to the node or overwrite some values.
-    if ($extra = node_invoke($node, 'load')) {
-      foreach ($extra as $key => $value) {
-        $node->$key = $value;
-      }
-    }
-    if ($extra = node_invoke_nodeapi($node, 'load')) {
-      foreach ($extra as $key => $value) {
-        $node->$key = $value;
-      }
-    }
-  }
-
-  // Copied over from node_delete():
-
-  db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
-  db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
-
-  // Call the node-specific callback (if any):
-  node_invoke($node, 'delete');
-  node_invoke_nodeapi($node, 'delete');
-
-  // Clear the cache so an anonymous poster can see the node being deleted.
-  cache_clear_all();
-
-  // Remove this node from the search index if needed.
-  if (function_exists('search_wipe')) {
-    search_wipe($node->nid, 'node');
-  }
-  drupal_set_message(t('%title has been deleted.', array('%title' => $node->title)));
-  watchdog('content', '@type: deleted %title.', array('@type' => node_get_types('name', $node->type), '%title' => $node->title));
-}
-
-/**
  * Implementation of hook_nodeapi().
  */
 function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
