? .cvsignore
? pm_email_notify.module_0.patch
? user_delete_stuff.patch
? user_delete_stuff2.patch
Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.86
diff -u -p -r1.70.2.30.2.91.2.86 privatemsg.module
--- privatemsg.module	1 Nov 2009 23:07:32 -0000	1.70.2.30.2.91.2.86
+++ privatemsg.module	1 Nov 2009 23:29:33 -0000
@@ -1215,7 +1215,6 @@ function privatemsg_user_name_autocomple
 function privatemsg_user($op, &$edit, &$account, $category = NULL) {
   global $user;
 
-
   switch ($op) {
     case 'view':
       if ($url = privatemsg_get_link(array($account))) {
@@ -1234,6 +1233,24 @@ function privatemsg_user($op, &$edit, &$
         }
       }
       break;
+    case 'delete':
+
+      // Load all mids of the messages the user wrote.
+      $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid);
+      $mids = array();
+      while ($row = db_fetch_array($result)) {
+        $mids[] = $row['mid'];
+      }
+
+      // Delete messages the user wrote.
+      db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid);
+
+      // Delete recipient entries in {pm_index} of the messages the user wrote.
+      db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);
+
+      // Delete recipient entries of that user.
+      db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid);
+      break;
   }
 }
 
Index: privatemsg.test
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.test,v
retrieving revision 1.2.2.6
diff -u -p -r1.2.2.6 privatemsg.test
--- privatemsg.test	27 Oct 2009 11:31:35 -0000	1.2.2.6
+++ privatemsg.test	1 Nov 2009 23:29:35 -0000
@@ -400,6 +400,17 @@ class PrivatemsgTestCase extends DrupalW
     $this->assertText($body1, 'First message is still displayed');
     $this->assertNoText($body2, 'Second message has been deleted for all users');
 
+    // Check that messages of deleted users are hidden.
+    $edit = array('body' => $this->randomName(100));
+    $this->drupalPost(NULL, $edit, t('Send message'));
+
+    $this->drupalLogin($admin);
+    $this->drupalGet('messages/view/' . $return['message']['thread_id']);
+    $this->assertText($edit['body'], t('New reply is displayed'));
+    user_delete(array(), $recipient2->uid);
+    $this->drupalGet('messages/view/' . $return['message']['thread_id']);
+    $this->assertText($body1, 'First message is still displayed');
+    $this->assertNoText($edit['body'], t('Reply of deleted user is not displayed anymore'));
   }
 
   /**
Index: pm_block_user/pm_block_user.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_block_user/pm_block_user.module,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 pm_block_user.module
--- pm_block_user/pm_block_user.module	27 Oct 2009 11:31:35 -0000	1.1.2.11
+++ pm_block_user/pm_block_user.module	1 Nov 2009 23:29:37 -0000
@@ -571,3 +571,15 @@ function pm_block_user_privatemsg_messag
     }
   }
 }
+
+/**
+ * Implement hook_user().
+ */
+function pm_block_user_user($op, &$edit, &$account, $category = NULL) {
+  switch ($op) {
+      case 'delete':
+      // Delete blocking rules which involve this user.
+      db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid);
+      break;
+  }
+}
Index: pm_email_notify/pm_email_notify.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/pm_email_notify/Attic/pm_email_notify.module,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 pm_email_notify.module
--- pm_email_notify/pm_email_notify.module	21 Oct 2009 18:56:51 -0000	1.1.2.7
+++ pm_email_notify/pm_email_notify.module	1 Nov 2009 23:29:38 -0000
@@ -151,9 +151,9 @@ function _pm_email_notify_default_body()
  * Display settings form and store its information.
  */
 function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
-  if ($category == 'account') {
-    switch ($op) {
-      case 'form':
+  switch ($op) {
+    case 'form':
+      if ($category == 'account') {
         $form['enable_pm_mail'] = array(
           '#type' => 'fieldset',
           '#title' => t('Privatemsg e-mail notification'),
@@ -166,9 +166,11 @@ function pm_email_notify_user($op, &$edi
           '#title' => t('Receive email notification for incoming private messages'),
           '#default_value' => _pm_email_notify_is_enabled($account->uid),
         );
-        return $form;
+      }
+      return $form;
 
-      case 'submit':
+     case 'submit':
+      if ($category == 'account') {
         $pm_email_enabled = $edit['pm_send_notifications'];
         unset($edit['pm_send_notifications']);
         // Update database entry with user preference.
@@ -178,8 +180,11 @@ function pm_email_notify_user($op, &$edi
           // user preference in the database.
           db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
         }
-        break;
+      }
+      break;
 
-    }
+     case 'delete':
+      db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid);
+      break;
   }
 }
Index: privatemsg_filter/privatemsg_filter.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.module,v
retrieving revision 1.1.2.24
diff -u -p -r1.1.2.24 privatemsg_filter.module
--- privatemsg_filter/privatemsg_filter.module	29 Oct 2009 15:33:18 -0000	1.1.2.24
+++ privatemsg_filter/privatemsg_filter.module	1 Nov 2009 23:29:40 -0000
@@ -780,4 +780,16 @@ function privatemsg_filter_sql_tags_auto
   $fragments['query_args']['join'][] = $user->uid;
   $fragments['where'][] = '(pmti.uid IS NOT NULL OR pmt.public = 1)';
   $fragments['order_by'][] = 'pmt.tag ASC';
+}
+
+/**
+ * Implement hook_user().
+ */
+function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) {
+  switch ($op) {
+      case 'delete':
+      // Delete tag information of that user.
+      db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid);
+      break;
+  }
 }
\ No newline at end of file
