? cvs-release-notes.php
Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.64.2.104
diff -u -p -r1.70.2.30.2.91.2.64.2.104 privatemsg.module
--- privatemsg.module	20 Feb 2011 11:47:21 -0000	1.70.2.30.2.91.2.64.2.104
+++ privatemsg.module	20 Feb 2011 12:28:55 -0000
@@ -86,14 +86,14 @@ function _privatemsg_generate_user_array
   $participants = array();
   foreach ($users as $uid) {
     // If it is an integer, it is a user id.
-   if ((int)$uid > 0 && ($account = _privatemsg_user_load($uid))) {
+   if ((int)$uid > 0 && ($account = array_shift(privatemsg_user_load_multiple(array($uid))))) {
       $participants[privatemsg_recipient_key($account)] = $account;
     }
    elseif (strpos($uid, '_') !== FALSE) {
       list($type, $id) = explode('_', $uid);
       $type_info = privatemsg_recipient_get_type($type);
       if ($type_info && isset($type_info['load']) && is_callable($type_info['load'])) {
-        if ($participant = reset($type_info['load'](array($id)))) {
+        if ($participant = array_shift($type_info['load'](array($id)))) {
           $participants[privatemsg_recipient_key($participant)] = $participant;
         }
       }
@@ -822,11 +822,6 @@ function _privatemsg_load_thread_partici
     if ($ignore_hidden && $participant->type == 'hidden') {
       continue;
     }
-    if ($participant->type == 'user' || $participant->type == 'hidden') {
-      if ($participant = _privatemsg_user_load($participant->recipient)) {
-        $participants[privatemsg_recipient_key($participant)] = $participant;
-      }
-    }
     elseif (privatemsg_recipient_access($participant->type, $access, $participant)) {
       $to_load[$participant->type][] = $participant->recipient;
     }
@@ -1018,14 +1013,14 @@ function privatemsg_sql_list($account, $
   if (in_array('participants', $fields)) {
     // Query for a string with uid's, for example "1,6,7". This needs a subquery on PostgreSQL.
     if (db_driver() == 'pgsql') {
-      $query->addExpression("array_to_string(array(SELECT DISTINCT pmia.recipient
+      $query->addExpression("array_to_string(array(SELECT DISTINCT pmia.type || '_' || textin(int4out(pmia.recipient))
                                                           FROM {pm_index} pmia
-                                                          WHERE pmia.type = 'user' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> :current), ',')", 'participants', array(':current' => $account->uid));
+                                                          WHERE pmia.type <> 'hidden' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> :current), ',')", 'participants', array(':current' => $account->uid));
     }
     else {
-      $query->addExpression("(SELECT GROUP_CONCAT(DISTINCT pmia.recipient SEPARATOR ',')
+      $query->addExpression("(SELECT GROUP_CONCAT(DISTINCT CONCAT(pmia.type, '_', pmia.recipient) SEPARATOR ',')
                                      FROM {pm_index} pmia
-                                     WHERE pmia.type = 'user' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> :current)", 'participants', array(':current' => $account->uid));
+                                     WHERE pmia.type <> 'hidden' AND pmia.thread_id = pmi.thread_id AND pmia.recipient <> :current)", 'participants', array(':current' => $account->uid));
     }
   }
   if (in_array('thread_started', $fields)) {
@@ -2282,7 +2277,7 @@ function privatemsg_build_modes($obj_typ
  */
 function privatemsg_node_view($node, $view_mode) {
   $types = array_filter(variable_get('privatemsg_link_node_types', array()));
-  $url = privatemsg_get_link(_privatemsg_user_load($node->uid));
+  $url = privatemsg_get_link(user_load($node->uid));
   if (in_array($node->type, $types) && !empty($url) && ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) && $view_mode == 'teaser'))) {
     $node->content['links']['#links']['privatemsg_link'] = array(
       'title' => t('Send author a message'),
@@ -2298,7 +2293,7 @@ function privatemsg_node_view($node, $vi
  */
 function privatemsg_comment_view($comment) {
   $types = array_filter(variable_get('privatemsg_link_node_types', array()));
-  $url = privatemsg_get_link(_privatemsg_user_load($comment->uid));
+  $url = privatemsg_get_link(user_load($comment->uid));
   if (in_array(node_load($comment->nid)->type, $types) && !empty($url) && variable_get('privatemsg_display_on_comments', 0)) {
     $links['privatemsg_link'] = array(
       'title' => t('Send author a message'),
@@ -2323,23 +2318,25 @@ function privatemsg_views_api() {
 }
 
 /**
- * Privatemsg wrapper function for user_load() with a static cache.
+ * Privatemsg wrapper function for user_load_multiple().
  *
- * The function additionaly also adds the privatemsg specific recipient id (uid)
+ * The function adds the privatemsg specific recipient id (uid)
  * and recipient type to the user object.
  *
  * @param $uid
- *   Which uid to load.
+ *   Which uid to load. Can either be a single id or an array of uid's.
  * @return
  *   If existing for the passed in uid, the user object with the recipient
  *   and type properties.
  */
-function _privatemsg_user_load($uid) {
-  if ($account = user_load($uid)) {
+function privatemsg_user_load_multiple($uids) {
+  $accounts = array();
+  foreach (user_load_multiple($uids) as $account) {
     $account->recipient = $account->uid;
     $account->type = 'user';
+    $accounts[privatemsg_recipient_key($account)] = $account;
   }
-  return $account;
+  return $accounts;
 }
 
 /**
@@ -2417,8 +2414,8 @@ function privatemsg_message_change_recip
   if ($add) {
     // Only add the recipient if he does not block the author.
     $author_uid = db_query('SELECT author FROM {pm_message} WHERE mid = :mid', array(':mid' => $mid))->fetchField();
-    $recipient = _privatemsg_user_load($uid);
-    $user_blocked = module_invoke_all('privatemsg_block_message', _privatemsg_user_load($author_uid), array(privatemsg_recipient_key($recipient) => $recipient));
+    $recipient = array_shift(privatemsg_user_load_multiple(array($uid)));
+    $user_blocked = module_invoke_all('privatemsg_block_message', user_load($author_uid), array(privatemsg_recipient_key($recipient) => $recipient));
     if (count($user_blocked) <> 0) {
       return;
     }
@@ -2599,7 +2596,7 @@ function privatemsg_privatemsg_recipient
     'user' => array(
       'name' => t('User'),
       'description' => t('Enter a user name to write a message to a user.'),
-      'load' => '_privatemsg_user_load',
+      'load' => 'privatemsg_user_load_multiple',
       'format' => 'privatemsg_username',
       'autocomplete' => 'privatemsg_user_autocomplete',
       // Make sure this comes always last.
@@ -2972,9 +2969,9 @@ class PrivatemsgMessageController extend
     foreach ($messages as $message) {
       $message->user = $this->account ? $this->account : $user;
       // Load author of message.
-      if (!($message->author = _privatemsg_user_load($message->author))) {
+      if (!($message->author = user_load($message->author))) {
         // If user does not exist, load anonymous user.
-        $message->author = _privatemsg_user_load(0);
+        $message->author = user_load(0);
       }
     }
     parent::attachLoad($messages, $revision_id);
Index: privatemsg.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.pages.inc,v
retrieving revision 1.1.2.41
diff -u -p -r1.1.2.41 privatemsg.pages.inc
--- privatemsg.pages.inc	20 Feb 2011 11:47:21 -0000	1.1.2.41
+++ privatemsg.pages.inc	20 Feb 2011 12:28:55 -0000
@@ -142,7 +142,7 @@ function privatemsg_list_page($argument 
   // Because uid is submitted by the menu system, it's a string not a integer.
   if ((int)$uid > 0 && $uid != $user->uid) {
     // Trying to view someone else's messages...
-    if (!$account_check = _privatemsg_user_load($uid)) {
+    if (!$account_check = user_load($uid)) {
       return MENU_NOT_FOUND;
     }
     if (!privatemsg_user_access('read all private messages')) {
@@ -659,7 +659,7 @@ function privatemsg_undo_action() {
     if (isset($undo['function']) && isset($undo['args'])) {
       // Load the user object.
       if (isset($undo['args']['account']) && $undo['args']['account'] > 0) {
-        $undo['args']['account'] = _privatemsg_user_load((int)$undo['args']['account']);
+        $undo['args']['account'] = user_load((int)$undo['args']['account']);
       }
       call_user_func_array($undo['function'], $undo['args']);
     }
Index: pm_block_user/pm_block_user.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/pm_block_user/pm_block_user.module,v
retrieving revision 1.1.2.8.2.24
diff -u -p -r1.1.2.8.2.24 pm_block_user.module
--- pm_block_user/pm_block_user.module	10 Dec 2010 09:53:15 -0000	1.1.2.8.2.24
+++ pm_block_user/pm_block_user.module	20 Feb 2011 12:28:55 -0000
@@ -255,8 +255,8 @@ function pm_block_user_privatemsg_block_
   $blocked = array();
   // Loop through each recipient and ensure there is no rule blocking this
   // author from sending them private messages. Use a reference, so when
-  // _privatemsg_user_load() is needed here the array is updated, negating the
-  // need for further calls to _privatemsg_user_load() later in the code.
+  // privatemsg_user_load_multiple() is needed here the array is updated, to
+  // avoid additional checks.
   foreach (array_keys($recipients) as $id) {
     // Only recipients of type user are currently supported.
     if (isset($recipients[$id]->type) && $recipients[$id]->type != 'user') {
@@ -265,7 +265,7 @@ function pm_block_user_privatemsg_block_
     // Ensure we have a recipient user object which includes roles.
     if (!isset($recipients[$id]->roles)) {
       $uid = str_replace('user_', '', $id);
-      $recipients[$id] = _privatemsg_user_load($uid);
+      $recipients[$id] = array_shift(privatemsg_user_load_multiple($uid));
     }
     // Note: this is checks whether the author may send the message (see third
     // parameter). Further below is a check whether the recipient may block it.
Index: pm_block_user/pm_block_user.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/pm_block_user/pm_block_user.pages.inc,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 pm_block_user.pages.inc
--- pm_block_user/pm_block_user.pages.inc	30 Nov 2010 07:45:08 -0000	1.1.2.8
+++ pm_block_user/pm_block_user.pages.inc	20 Feb 2011 12:28:55 -0000
@@ -123,7 +123,7 @@ function pm_block_user_list() {
   $rows = array();
   foreach ($select->execute() as $row) {
     $rows[] = array(
-      theme('username', array('account' => _privatemsg_user_load($row->author))),
+      theme('username', array('account' => user_load($row->author))),
       l(t('unblock'), 'messages/block/' . $row->author, array('query' => drupal_get_destination())),
     );
   }
Index: privatemsg_filter/privatemsg_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.module,v
retrieving revision 1.1.2.17.2.35
diff -u -p -r1.1.2.17.2.35 privatemsg_filter.module
--- privatemsg_filter/privatemsg_filter.module	5 Jan 2011 21:47:27 -0000	1.1.2.17.2.35
+++ privatemsg_filter/privatemsg_filter.module	20 Feb 2011 12:28:56 -0000
@@ -484,7 +484,7 @@ function privatemsg_filter_create_get_qu
       if (is_object($author) && isset($author->uid) && isset($author->name)) {
         $query['author'][] = privatemsg_recipient_format($author, array('plain' => TRUE));
       }
-      elseif (is_int($author) && $author_obj = _privatemsg_user_load($author)) {
+      elseif (is_int($author) && $author_obj = array_shift(privatemsg_user_load_multiple(array($author)))) {
         $query['author'][] = privatemsg_recipient_format($author, array('plain' => TRUE));
       }
     }
Index: views/views_handler_field_privatemsg_link.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/views/views_handler_field_privatemsg_link.inc,v
retrieving revision 1.1.4.6
diff -u -p -r1.1.4.6 views_handler_field_privatemsg_link.inc
--- views/views_handler_field_privatemsg_link.inc	20 Jan 2011 12:47:31 -0000	1.1.4.6
+++ views/views_handler_field_privatemsg_link.inc	20 Feb 2011 12:28:56 -0000
@@ -158,7 +158,7 @@ class views_handler_field_privatemsg_lin
     }
 
     $data = '';
-    if (($recipient = _privatemsg_user_load($uid)) && ($url = privatemsg_get_link(array($recipient), NULL, $subject))) {
+    if (($recipient = user_load($uid)) && ($url = privatemsg_get_link(array($recipient), NULL, $subject))) {
       $data = l($text, $url, $options);
     }
     return $data;
