From 407d5291afd3832ea45e2cfd5e67624c102fe1b6 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 +----
 privatemsg_forward/privatemsg_forward.module       |    6 +++---
 3 files changed, 7 insertions(+), 10 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';
     }
diff --git a/privatemsg_forward/privatemsg_forward.module b/privatemsg_forward/privatemsg_forward.module
index 45dc077..c3629e4 100644
--- a/privatemsg_forward/privatemsg_forward.module
+++ b/privatemsg_forward/privatemsg_forward.module
@@ -57,13 +57,13 @@ function privatemsg_forward_form_privatemsg_form_reply_alter(&$form, &$form_stat
 
     // Also add submit and validate function to the global ones so that the
     // Send message button can be used.
-    $form['submit']['#validate'][] = 'privatemsg_forward_form_validate';
+    $form['#validate'][] = 'privatemsg_forward_form_validate';
     // Add forward submit callback before default so that the message is sent
     // to the new recipients too.
-    array_unshift($form['submit']['#submit'], 'privatemsg_forward_form_submit');
+    array_unshift($form['#submit'], 'privatemsg_forward_form_submit');
     // Add delete submit function at the end so that it also removes the current
     // user from the new reply.
-    $form['submit']['#submit'][] = 'privatemsg_forward_form_delete_submit';
+    $form['#submit'][] = 'privatemsg_forward_form_delete_submit';
   }
 }
 
-- 
1.7.4.1

