Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.25
diff -u -p -r1.70.2.30.2.91.2.25 privatemsg.module
--- privatemsg.module	22 Feb 2009 21:21:08 -0000	1.70.2.30.2.91.2.25
+++ privatemsg.module	5 Mar 2009 23:27:42 -0000
@@ -1044,19 +1044,20 @@ function privatemsg_form_alter(&$form, $
             // Skip putting author in the recipients list for now.
             continue;
           }
-          // Check if another module is blocking the sending of messages to the recipient by current user.
-          $recipient = user_load(array('uid' => $result->uid));
-          $user_blocked = module_invoke_all('privatemsg_block_message', $user, $recipient);
-          if (!count($user_blocked) <> 0 && $recipient->uid) {
-            $to[] = $recipient->name;
-          }
+          $to[$result->uid] = user_load($result->uid);
         }
         if (empty($to) && $usercount >= 1) {
           // Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self.
-          $to[] = $user->name;
+          $to[$user->uid] = $user->name;
         }
+        // Check if another module is blocking the sending of messages to the recipient by current user.
+        foreach(module_invoke_all('privatemsg_block_message', $user, $to) as $blocked) {
+          unset($to[$blocked['uid']]);
+        }
+
+        $recipients = '';
         if ($to) {
-          $recipients = implode(', ', $to);
+          $recipients = _privatemsg_format_participants($to, 20, TRUE);
         }
 
         $form['privatemsg']['thread_id'] = array(
@@ -1071,7 +1072,7 @@ function privatemsg_form_alter(&$form, $
           '#type' => 'value',
           '#default_value' => $recipients,
         );
-        $form['privatemsg']['body']['#title'] = t('Send reply to %recipient', array('%recipient' => $recipients));
+        $form['privatemsg']['body']['#title'] = t('Send reply to !recipient', array('!recipient' => $recipients));
         $form['privatemsg']['body']['#required'] = TRUE;
 
         if (empty($to)) {
@@ -1231,15 +1232,10 @@ function _privatemsg_validate_message(&$
   }
 
   if (!empty($message['recipients']) && is_array($message['recipients'])) {
-    foreach ($message['recipients'] as $uid => $recipient) {
-      $block_results = module_invoke_all('privatemsg_block_message', $author, $recipient);
-      if (count($block_results) > 0) {
-        unset($message['recipients'][$uid]);
-        if ($show_warnings) {
-          foreach ($block_results as $block_result) {
-            drupal_set_message($block_result);
-          }
-        }
+    foreach(module_invoke_all('privatemsg_block_message', $author, $message['recipients']) as $blocked) {
+      unset($message['recipients'][$blocked['uid']]);
+      if ($show_warnings) {
+        drupal_set_message($blocked['message']);
       }
     }
   }
@@ -1312,7 +1308,7 @@ function privatemsg_get_link($recipient,
     return FALSE;
   }
 
-  if (count(module_invoke_all('privatemsg_block_message', $account, $recipient)) > 0) {
+  if (count(module_invoke_all('privatemsg_block_message', $account, array($recipient))) > 0) {
     return FALSE;
   }
 
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.3
diff -u -p -r1.1.2.3 pm_block_user.module
--- pm_block_user/pm_block_user.module	20 Feb 2009 00:34:27 -0000	1.1.2.3
+++ pm_block_user/pm_block_user.module	5 Mar 2009 23:27:42 -0000
@@ -89,12 +89,14 @@ function pm_block_user_form_submit($form
 /**
  * Implementation of hook_privatemsg_block_message.
  */
- function pm_block_user_privatemsg_block_message($author, $recipient) {
+ function pm_block_user_privatemsg_block_message($author, $recipients) {
   global $user;
-  $result = db_result(db_query('SELECT COUNT(*) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $recipient->uid));
-  if ($result <> 0) {
-    return t('!name has chosen to not recieve any more messages from you.', array('!name' => $recipient->name));
+  $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $author->uid, array_keys($recipients));
+  $blocked = array();
+  while ($row = db_fetch_array($result)) {
+    $blocked[] = array('uid' => $row['recipient'], 'message' => t('!name has chosen to not recieve any more messages from you.', array('!name' => $recipients[$row['recipient']]->name)));
   }
+  return $blocked;
 }
 
 function pm_block_user_privatemsg_sql_load_alter(&$fragments, $pmid, $uid) {
