Index: privatemsg.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.install,v
retrieving revision 1.5.2.4.2.11.2.11.2.2
diff -u -p -r1.5.2.4.2.11.2.11.2.2 privatemsg.install
--- privatemsg.install	17 Sep 2009 17:14:05 -0000	1.5.2.4.2.11.2.11.2.2
+++ privatemsg.install	9 Oct 2009 11:51:17 -0000
@@ -81,6 +81,13 @@ function privatemsg_schema() {
         'not null'      => TRUE,
         'size'          => 'big',
       ),
+      'format'        => array(
+        'type'          => 'int',
+        'size'          => 'small',
+        'not null'      => TRUE,
+        'default'       => 0,
+        'description'   => 'The {filter_formats}.format of the message text.',
+      ),
       'timestamp'     => array(
         'description'   => 'Time when the message was sent',
         'type'          => 'int',
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.9
diff -u -p -r1.70.2.30.2.91.2.64.2.9 privatemsg.module
--- privatemsg.module	8 Oct 2009 22:34:56 -0000	1.70.2.30.2.91.2.64.2.9
+++ privatemsg.module	9 Oct 2009 11:51:18 -0000
@@ -478,7 +478,7 @@ function privatemsg_preprocess_privatems
    * @todo perhaps make this timestamp configurable via admin UI?
    */
   $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
-  $vars['message_body'] = check_markup($message['body']);
+  $vars['message_body'] = check_markup($message['body'], $message['format']);
   if (isset($vars['mid']) && privatemsg_user_access('delete privatemsg')) {
     $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['mid']);
   }
@@ -743,7 +743,7 @@ function privatemsg_new($form, &$form_st
     '#value' => $user,
   );
   if (is_null($thread_id)) {
-    $form['privatemsg']['recipient']  = array(
+    $form['privatemsg']['recipient'] = array(
       '#type'               => 'textfield',
       '#title'              => t('To'),
       '#description'        => t('Separate multiple names with commas.'),
@@ -755,7 +755,7 @@ function privatemsg_new($form, &$form_st
       // Do not hardcode #maxlength, make it configurable by number of recipients, not their name length.
     );
   }
-  $form['privatemsg']['subject']    = array(
+  $form['privatemsg']['subject'] = array(
     '#type'               => 'textfield',
     '#title'              => t('Subject'),
     '#size'               => 50,
@@ -763,13 +763,20 @@ function privatemsg_new($form, &$form_st
     '#default_value'      => $subject,
     '#weight'             => -5,
   );
-  $form['privatemsg']['body']       = array(
+
+  // The input filter widget looses the format during preview, specify it
+  // explicitly.
+  if (isset($form_state['values']) && array_key_exists('body_format', $form_state['values'])) {
+    $format = $form_state['values']['body_format'];
+  }
+  $form['privatemsg']['body'] = array(
     '#type'               => 'textarea',
     '#title'              => t('Message'),
-    '#cols'               => 10,
     '#rows'               => 6,
     '#weight'             => 0,
     '#default_value'      => $body,
+    '#resizable'          => TRUE,
+    '#text_format'        => isset($format) ? $format : filter_default_format(),
   );
   $form['privatemsg']['preview'] = array(
     '#type'               => 'submit',
@@ -832,6 +839,7 @@ function pm_send_validate($form, &$form_
   $message['body']      = $form_state['values']['body'];
   $message['subject']   = $form_state['values']['subject'];
   $message['author']    = $form_state['values']['author'];
+  $message['format']    = $form_state['values']['body_format'];
   $message['read_all']  = $form_state['values']['read_all'];
   $message['timestamp'] = time();
   if (isset($form_state['values']['thread_id']) && $form_state['values']['thread_id']) {
@@ -961,6 +969,14 @@ function pm_preview($form, &$form_state)
  * @{
  */
 
+/**
+ * Query definition to load a list of threads.
+ *
+ * @param $account
+ *  User object for which the messages are being loaded.
+ * @param $argument
+ *  string argument which can be used in the query builder to modify the thread listing.
+ */
 function privatemsg_sql_list($account, $argument = 'list') {
   $query = db_select('pm_message', 'pm')->extend('TableSort')->extend('PagerDefault');
   $query->join('pm_index', 'pmi', 'pm.mid = pmi.mid');
@@ -1023,7 +1039,7 @@ function privatemsg_sql_list($account, $
  */
 function privatemsg_sql_load($pmid, $account = NULL) {
   $query = db_select('pm_message', 'pm')
-    ->fields('pm', array('mid', 'author', 'subject', 'body', 'timestamp'))
+    ->fields('pm', array('mid', 'author', 'subject', 'body', 'timestamp', 'format'))
     ->fields('pmi', array('is_new'))
     ->condition('pmi.mid', $pmid);
   if($account) {
@@ -1362,6 +1378,7 @@ function privatemsg_new_thread($recipien
   $message += array(
     'author' => $author,
     'timestamp' => time(),
+    'format' => filter_default_format($author),
   );
 
   $validated = _privatemsg_validate_message($message);
@@ -1371,6 +1388,7 @@ function privatemsg_new_thread($recipien
 
   return $validated;
 }
+
 /**
  * Send a reply message
  *
@@ -1419,6 +1437,7 @@ function privatemsg_reply($thread_id, $b
   $message += array(
     'author' => $author,
     'timestamp' => time(),
+    'format' => filter_default_format($author),
   );
 
   // We don't know the subject and the recipients, so we need to load them..
@@ -1531,6 +1550,7 @@ function _privatemsg_send($message) {
   $args['subject'] = $message['subject'];
   $args['author'] = $message['author']->uid;
   $args['body'] = $message['body'];
+  $args['format'] = $message['format'];
   $args['timestamp'] = $message['timestamp'];
   $mid = db_insert('pm_message')
     ->fields($args)
