Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.5
diff -u -p -r1.5 mollom.admin.inc
--- mollom.admin.inc	23 Dec 2009 15:21:29 -0000	1.5
+++ mollom.admin.inc	5 Jan 2010 18:45:09 -0000
@@ -354,11 +354,8 @@ function _mollom_verify_key() {
  * Form submit handler to mass-report and unpublish or delete comments.
  */
 function mollom_comment_admin_overview_submit($form, &$form_state) {
-  // The operation has the following format: <module>-<operation>,
-  // where '<operation>' can be 'unpublish' or 'delete'.
-  list($id, $operation) = explode('-', $form_state['values']['operation']);
-
-  if ($id == 'mollom') {
+  if (strpos($form_state['values']['operation'], 'mollom-') === 0) {
+    list($id, $operation) = explode('-', $form_state['values']['operation']);
     foreach ($form_state['values']['comments'] as $cid => $value) {
       if ($value) {
         // First, send the proper information to the XML-RPC server:
@@ -399,11 +396,8 @@ function mollom_comment_admin_overview_s
  * Form submit handler to mass-report and unpublish or delete nodes.
  */
 function mollom_node_admin_overview_submit($form, &$form_state) {
-  // The operation has the following format: <operation>,
-  // where '<operation>' can be 'unpublish' or 'delete'.
-  list($id, $operation) = explode('-', $form_state['values']['operation']);
-
-  if ($id == 'mollom') {
+  if (strpos($form_state['values']['operation'], 'mollom-') === 0) {
+    list($id, $operation) = explode('-', $form_state['values']['operation']);
     foreach ($form_state['values']['nodes'] as $nid => $value) {
       if ($value) {
         if ($data = mollom_data_load('node', $nid)) {
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.10
diff -u -p -r1.10 mollom.module
--- mollom.module	4 Jan 2010 01:05:31 -0000	1.10
+++ mollom.module	5 Jan 2010 18:53:59 -0000
@@ -328,6 +328,7 @@ function mollom_data_save($entity, $id) 
     return FALSE;
   }
   $data = $GLOBALS['mollom_response'];
+  $data['session'] = $data['session_id'];
   $data['entity'] = $entity;
   $data['did'] = $id;
 
@@ -721,12 +722,13 @@ function _mollom_fallback() {
     form_set_error('mollom', t("The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes."));
   }
 
+  $servers = variable_get('mollom_servers', array());
   $variables = array(
-    '%servers' => print_r(variable_get('mollom_servers', array()), TRUE),
+    '%servers' => $servers ? implode(', ', $servers) : '--',
     '@errno' => xmlrpc_errno(),
     '%error_msg' => xmlrpc_error_msg(),
   );
-  watchdog('mollom', 'All Mollom servers were unavailable: %servers, last error: @errno - %error_msg', $variables, WATCHDOG_ERROR);
+  watchdog('mollom', 'All servers unavailable: %servers, last error: @errno - %error_msg', $variables, WATCHDOG_ERROR);
 }
 
 /**
@@ -944,18 +946,18 @@ function mollom_validate_analysis(&$form
 
   switch ($result['spam']) {
     case MOLLOM_ANALYSIS_HAM:
-      watchdog('mollom', 'Ham: %message<br />Session: %session', array('%message' => $data['post_body'], '%session' => $result['session_id']));
+      watchdog('mollom', 'Ham: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
       break;
 
     case MOLLOM_ANALYSIS_SPAM:
       form_set_error('mollom', t('Your submission has triggered the spam filter and will not be accepted.'));
-      watchdog('mollom', 'Spam: %message<br />Session: %session', array('%message' => $data['post_body'], '%session' => $result['session_id']));
+      watchdog('mollom', 'Spam: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
       break;
 
     default:
       // Fall back to a CAPTCHA.
       form_set_error('mollom', t("We're sorry, but to submit this post, please complete the word verification below."));
-      watchdog('mollom', 'Unsure: %message<br />Session: %session', array('%message' => $data['post_body'], '%session' => $result['session_id']));
+      watchdog('mollom', 'Unsure: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
 
       $form_state['mollom']['require_captcha'] = TRUE;
       $form['mollom']['captcha']['#access'] = TRUE;
@@ -1027,7 +1029,7 @@ function mollom_validate_captcha(&$form,
     $form_state['mollom']['passed_captcha'] = TRUE;
     $form['mollom']['captcha']['#access'] = FALSE;
 
-    watchdog('mollom', 'The CAPTCHA response was correct. Form data: %data', array('%data' => print_r($form_state['values'], TRUE)));
+    watchdog('mollom', 'Correct CAPTCHA: <pre>@data<pre>', array('@data' => print_r($form_state['values'], TRUE)));
 
     // Cache the Mollom form state for mollom_process_mollom_session_id().
     cache_set($form_state['mollom']['session_id'], $form_state['mollom'], 'cache_mollom', REQUEST_TIME + 21600);
@@ -1037,7 +1039,7 @@ function mollom_validate_captcha(&$form,
     $form['mollom']['captcha']['#value'] = '';
 
     form_set_error('mollom][captcha', t('The CAPTCHA was not completed correctly. Please complete this new CAPTCHA and try again.'));
-    watchdog('mollom', 'The CAPTCHA response was incorrect. Form data: %data', array('%data' => print_r($form_state['values'], TRUE)));
+    watchdog('mollom', 'Invalid CAPTCHA: <pre>@data<pre>', array('@data' => print_r($form_state['values'], TRUE)));
   }
 }
 
@@ -1133,8 +1135,8 @@ function mollom($method, $data = array()
 
             // Log this for debugging purposes.
             $messages[] = array(
-              'text' => 'Mollom servers were refreshed: @servers',
-              'arguments' => array('@servers' => "\n" . implode(",\n", $servers)),
+              'text' => 'Refreshed servers: %servers',
+              'arguments' => array('%servers' => implode(', ', $servers)),
             );
 
             // Mark that we have refreshed the list.
@@ -1147,7 +1149,7 @@ function mollom($method, $data = array()
 
           // Do nothing, we automatically select the next server.
           $messages[] = array(
-            'text' => 'The Mollom server %server asked to use the next Mollom server in the list: %next.',
+            'text' => 'Server %server redirected to: %next.',
             'arguments' => array('%server' => $server, '%next' => $next),
           );
         }
@@ -1189,7 +1191,7 @@ function mollom($method, $data = array()
 
   // Report this error.
   $messages[] = array(
-    'text' => 'No Mollom servers could be reached or all servers returned an error -- the server list was emptied.',
+    'text' => 'All servers unreachable or returning errors. The server list was emptied.',
   );
   _mollom_watchdog($messages, WATCHDOG_ERROR);
 
@@ -1313,7 +1315,7 @@ function node_mollom_form_info() {
     // @see node_content_form()
     if ($type->has_title) {
       $forms[$form_id]['elements']['title'] = check_plain($type->title_label);
-      $forms[$form_id]['mapping']['title'] = 'title';
+      $forms[$form_id]['mapping']['post_title'] = 'title';
     }
     if ($type->has_body) {
       $forms[$form_id]['elements']['body'] = check_plain($type->body_label);
@@ -1515,6 +1517,7 @@ function user_mollom_form_info() {
   $forms['user_register_form'] = array(
     'title' => t('User registration form'),
     'mode' => MOLLOM_MODE_CAPTCHA,
+    'bypass access' => array('administer users'),
     'entity' => 'user',
     'mapping' => array(
       'post_id' => 'uid',
@@ -1525,6 +1528,7 @@ function user_mollom_form_info() {
   $forms['user_pass'] = array(
     'title' => t('User password request form'),
     'mode' => MOLLOM_MODE_CAPTCHA,
+    'bypass access' => array('administer users'),
     'entity' => 'user',
     'mapping' => array(
       'post_id' => 'uid',
@@ -1594,13 +1598,7 @@ function mollom_mail_alter(&$message) {
     $report_link = t('Report as inappropriate: @link', array(
       '@link' => url('mollom/report/session/' . $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)),
     ));
-    // Until D7, hook_mail_alter() accepts both arrays and strings.
-    if (is_array($message['body'])) {
-      $message['body'][] = $report_link;
-    }
-    else {
-      $message['body'] .= "\n\n" . $report_link;
-    }
+    $message['body'][] = $report_link;
   }
 }
 
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.6
diff -u -p -r1.6 mollom.test
--- tests/mollom.test	30 Dec 2009 21:55:44 -0000	1.6
+++ tests/mollom.test	5 Jan 2010 18:41:30 -0000
@@ -251,6 +251,22 @@ class MollomWebTestCase extends DrupalWe
   }
 
   /**
+   * Assert that Mollom session data was stored for a submission.
+   */
+  protected function assertData($entity, $id) {
+    $data = mollom_data_load($entity, $id);
+    $this->assertTrue($data->session, t('Mollom session data for %entity @id exists: %session', array('%entity' => $entity, '@id' => $id, '%session' => $data->session)));
+  }
+
+  /**
+   * Assert that no Mollom session data exists for a certain entity.
+   */
+  protected function assertNoData($entity, $id) {
+    $data = mollom_data_load($entity, $id);
+    $this->assertFalse($data, t('No Mollom session data exists for %entity @id.', array('%entity' => $entity, '@id' => $id)));
+  }
+
+  /**
    * Test that the CAPTCHA field is found on the current page.
    */
   protected function assertCaptchaField() {
@@ -1642,7 +1658,7 @@ class MollomReportTestCase extends Mollo
     $this->assertMollomWatchdogMessages();
     $this->comment = db_query('SELECT * FROM {comment} WHERE comment = :comment AND nid = :nid', array(':comment' => $edit['comment'], ':nid' => $this->node->nid))->fetchObject();
     $this->assertTrue($this->comment, t('Comment was found in the database.'));
-    $this->assertTrue(mollom_data_load('comment', $this->comment->cid), t('Mollom session data was recorded.'));
+    $this->assertData('comment', $this->comment->cid);
 
     // Log in comment administrator and verify that we can report to Mollom.
     $this->drupalLogin($this->admin_user);
@@ -1659,7 +1675,60 @@ class MollomReportTestCase extends Mollo
 
     // Verify that the comment and Mollom session data has been deleted.
     $this->assertFalse(comment_load($this->comment->cid), t('Comment was deleted.'));
-    $this->assertFalse(mollom_data_load('comment', $this->comment->cid), t('Mollom session data for comment was deleted.'));
+    $this->assertNoData('comment', $this->comment->cid);
+  }
+
+  /**
+   * Tests mass-reporting comments.
+   */
+  function testMassReportComments() {
+    $this->node = $this->drupalCreateNode(array('type' => 'story'));
+    variable_set('comment_preview_story', COMMENT_PREVIEW_OPTIONAL);
+
+    // Post 3 comments.
+    $this->drupalLogin($this->web_user);
+    $this->comments = array();
+    foreach (range(1, 3) as $num) {
+      $edit = array(
+        'subject' => $this->randomName(),
+        'comment' => 'ham',
+      );
+      $this->drupalPost('comment/reply/' . $this->node->nid, $edit, t('Save'));
+      $this->assertMollomWatchdogMessages();
+      $this->comments[$num] = db_query("SELECT * FROM {comment} WHERE subject = '%s' AND nid = %d", array($edit['subject'], $this->node->nid))->fetchObject();
+      $this->assertTrue($this->comments[$num], t('Comment was found in the database.'));
+      $this->assertData('comment', $this->comments[$num]->cid);
+    }
+
+    // Log in comment administrator and verify that we can mass-report all
+    // comments to Mollom.
+    $this->drupalLogin($this->admin_user);
+    $this->drupalGet('admin/content/comment');
+    $edit = array('operation' => 'mollom-unpublish');
+    foreach ($this->comments as $comment) {
+      $this->assertText($comment->subject, t('Comment found.'));
+      $edit["comments[{$comment->cid}]"] = TRUE;
+    }
+    $this->drupalPost(NULL, $edit, t('Update'));
+    $this->assertMollomWatchdogMessages();
+    $this->assertText(t('The selected comments have been reported as inappropriate and are unpublished.'));
+
+    // Verify that unpublished comments are found in approval queue and
+    // mass-report all comments again to delete them.
+    $this->drupalGet('admin/content/comment/approval');
+    $edit['operation'] = 'mollom-delete';
+    foreach ($this->comments as $comment) {
+      $this->assertText($comment->subject, t('Comment found.'));
+    }
+    $this->drupalPost(NULL, $edit, t('Update'));
+    $this->assertMollomWatchdogMessages();
+    $this->assertText(t('The selected comments have been reported as inappropriate and are deleted.'));
+
+    // Verify that the comments and Mollom session data has been deleted.
+    foreach ($this->comments as $comment) {
+      $this->assertFalse(comment_load($comment->cid), t('Comment was deleted.'));
+      $this->assertNoData('comment', $comment->cid);
+    }
   }
 }
 
