? 429502.theming_doc2.patch
? 429734.apidoc.patch
? 441042
? privatemsg.change_status.patch
? privatemsg.filter_autocomplete3.patch
? privatemsg.filter_autocomplete4.patch
? privatemsg.return_value_0.patch
? privatemsg.thread_static.patch
? privatemsg.thread_static2.patch
? privatemsg_new_thread_example.patch
Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.49
diff -u -r1.70.2.30.2.91.2.49 privatemsg.module
--- privatemsg.module	8 Jun 2009 11:50:32 -0000	1.70.2.30.2.91.2.49
+++ privatemsg.module	8 Jun 2009 11:54:42 -0000
@@ -254,6 +254,8 @@
  * @ingroup api
  */
 function privatemsg_thread_load($thread_id, $account = NULL) {
+  static $threads = array();
+
   if ((int)$thread_id > 0) {
     $thread = array('thread_id' => $thread_id);
 
@@ -261,31 +263,35 @@
       global $user;
       $account = drupal_clone($user);
     }
-    // load messages returned by the messages query with _privatemsg_load().
-    $query = _privatemsg_assemble_query('messages', array($thread_id), $account);
-    $conversation = db_query($query['query']);
-    while ($result = db_fetch_array($conversation)) {
-      if ($message = _privatemsg_load($result['mid'], $account)) {
-        $thread['messages'][$result['mid']] = $message;
+
+    if (!isset($threads[$account->uid][$thread_id])) {
+      // load messages returned by the messages query with _privatemsg_load().
+      $query = _privatemsg_assemble_query('messages', array($thread_id), $account);
+      $conversation = db_query($query['query']);
+      while ($result = db_fetch_array($conversation)) {
+        if ($message = _privatemsg_load($result['mid'], $account)) {
+          $thread['messages'][$result['mid']] = $message;
+        }
       }
+      // if there are no messages, don't allow access to the thread.
+      if (empty($thread['messages'])) {
+        return FALSE;
+      }
+
+      // general data, assume subject is the same for all messages of that thread.
+      $thread['user'] = $account;
+      $message = current($thread['messages']);
+      $thread['subject'] = $message['subject'];
+
+      // Load the list of participants.
+      $query = _privatemsg_assemble_query('participants', $thread_id);
+      $participants = db_query($query['query']);
+      while ($result = db_fetch_array($participants)) {
+        $thread['participants'][$result['uid']] = user_load($result['uid']);
+      }
+      $threads[$account->uid][$thread_id] = $thread;
     }
-    // if there are no messages, don't allow access to the thread.
-    if (empty($thread['messages'])) {
-      return FALSE;
-    }
-
-    // general data, assume subject is the same for all messages of that thread.
-    $thread['user'] = $account;
-    $message = current($thread['messages']);
-    $thread['subject'] = $message['subject'];
-
-    // Load the list of participants.
-    $query = _privatemsg_assemble_query('participants', $thread_id);
-    $participants = db_query($query['query']);
-    while ($result = db_fetch_array($participants)) {
-      $thread['participants'][$result['uid']] = user_load($result['uid']);
-    }
-    return $thread;
+    return isset($threads[$account->uid][$thread_id])? $threads[$account->uid][$thread_id] : FALSE;
   }
   return FALSE;
 }
