From ec506bb137cfb4696bdb266728ed7adc061568ff Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher <saschagros@gmail.com>
Date: Mon, 6 Jun 2011 23:31:46 +0200
Subject: [PATCH] Issue #1178796 by Berdir: Fixed mollom integration is broken because form callbacks are on the submit buttons.

---
 privatemsg.pages.inc                               |    6 +++---
 .../privatemsg_attachments.module                  |    5 +----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/privatemsg.pages.inc b/privatemsg.pages.inc
index efd47f1..e6835f8 100644
--- a/privatemsg.pages.inc
+++ b/privatemsg.pages.inc
@@ -393,7 +393,6 @@ function _privatemsg_form_base_fields(&$form_state) {
     $form['preview'] = array(
       '#type'     => 'submit',
       '#value'    => t('Preview message'),
-      '#validate' => array('privatemsg_new_validate'),
       '#submit'   => array('privatemsg_new_preview'),
       '#weight'   => 10,
     );
@@ -403,10 +402,11 @@ function _privatemsg_form_base_fields(&$form_state) {
     '#type'     => 'submit',
     '#value'    => t('Send message'),
     '#weight'   => 15,
-    '#validate' => array('privatemsg_new_validate'),
-    '#submit'   => array('privatemsg_new_submit'),
   );
 
+  $form['#validate'] = array('privatemsg_new_validate');
+  $form['#submit'] = array('privatemsg_new_submit');
+
   return $form;
 }
 
diff --git a/privatemsg_attachments/privatemsg_attachments.module b/privatemsg_attachments/privatemsg_attachments.module
index f732674..54d4cac 100644
--- a/privatemsg_attachments/privatemsg_attachments.module
+++ b/privatemsg_attachments/privatemsg_attachments.module
@@ -79,10 +79,7 @@ function privatemsg_attachments_form_privatemsg_new_alter(&$form, &$form_state)
       $form['attachments']['wrapper'] += _privatemsg_attachments_form($files);
       // Execute submit function as validate, to have it executed before
       // $form_state['validate_built_message'] is created.
-      array_unshift($form['submit']['#validate'], '_privatemsg_attachments_upload_submit');
-      if (isset($form['preview'])) {
-        array_unshift($form['preview']['#validate'], '_privatemsg_attachments_upload_submit');
-      }
+      array_unshift($form['#validate'], '_privatemsg_attachments_upload_submit');
 
       $form['#attributes']['enctype'] = 'multipart/form-data';
     }
-- 
1.7.4.1

