Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.1.2.33
diff -u -p -r1.1.2.33 mollom.admin.inc
--- mollom.admin.inc	11 Aug 2010 00:47:10 -0000	1.1.2.33
+++ mollom.admin.inc	3 Sep 2010 00:48:11 -0000
@@ -236,8 +236,6 @@ function mollom_admin_configure_form_sub
   $mollom_form = $form_state['values']['mollom'];
   // Merge in form information from $form_state.
   $mollom_form += $form_state['storage']['mollom_form'];
-  // Update form information in $form_state for potential rebuilds.
-  $form_state['storage']['mollom_form'] = $mollom_form;
 
   // Prepare selected fields for storage.
   $enabled_fields = array();
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2.2.156
diff -u -p -r1.2.2.156 mollom.module
--- mollom.module	7 Aug 2010 02:49:44 -0000	1.2.2.156
+++ mollom.module	3 Sep 2010 00:49:13 -0000
@@ -400,7 +400,6 @@ function mollom_data_load($entity, $id) 
  * - session: The session ID returned by the Mollom server.
  * - quality: A quality rating assigned to the content to tell whether or not
  *   it's spam.
- * - reputation: The reputation of the author.
  * - languages: An array containing language codes the content might be
  *   written in.
  *
@@ -414,14 +413,14 @@ function mollom_data_load($entity, $id) 
  * @param $id
  *   The entity id the data belongs to.
  *
- * @todo Remove usage of global $mollom_response variable.
+ * @todo Remove usage of global $mollom variable.
  */
 function mollom_data_save($entity, $id) {
   // Nothing to do, if we do not have a valid Mollom response.
-  if (!isset($GLOBALS['mollom_response']['session_id'])) {
+  if (empty($GLOBALS['mollom']['response']['session_id'])) {
     return FALSE;
   }
-  $data = $GLOBALS['mollom_response'];
+  $data = $GLOBALS['mollom']['response'];
   $data['session'] = $data['session_id'];
   $data['entity'] = $entity;
   $data['did'] = $id;
@@ -1226,18 +1225,15 @@ function mollom_process_mollom($element,
   // Setup initial Mollom session and form information.
   if (empty($form_state['mollom'])) {
     $form_state['mollom'] = array(
-      'form_id' => $element['#mollom_form']['form_id'],
       'require_analysis' => $element['#mollom_form']['mode'] == MOLLOM_MODE_ANALYSIS,
       'require_captcha' => $element['#mollom_form']['mode'] == MOLLOM_MODE_CAPTCHA,
       'passed_captcha' => FALSE,
-      'entity' => $element['#mollom_form']['entity'],
-      'enabled_fields' => $element['#mollom_form']['enabled_fields'],
-      'mapping' => $element['#mollom_form']['mapping'],
       'response' => array(
         'session_id' => '',
       ),
     );
   }
+  $form_state['mollom'] += $element['#mollom_form'];
 
   // Add the Mollom session element.
   $element['session_id'] = array(
@@ -1265,6 +1261,10 @@ function mollom_process_mollom($element,
   // $form_state['mollom'] will be carried over to the element for rendering.
   $element['#mollom'] = &$form_state['mollom'];
 
+  // Make Mollom form and session information available to entirely different
+  // functions.
+  $GLOBALS['mollom'] = &$form_state['mollom'];
+
   return $element;
 }
 
@@ -1343,26 +1343,23 @@ function mollom_validate_analysis(&$form
   }
   // Store the response returned by Mollom.
   $form_state['mollom']['response'] = $result;
-  // @todo Only used for Contact module and mail integration in general.
-  $GLOBALS['mollom_response'] = $form_state['mollom']['response'];
-  $GLOBALS['mollom_form'] = $form['mollom']['#mollom_form'];
 
   switch ($result['spam']) {
     case MOLLOM_ANALYSIS_HAM:
+      $form_state['mollom']['require_captcha'] = FALSE;
       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_state['mollom']['require_captcha'] = FALSE;
       form_set_error('mollom', t('Your submission has triggered the spam filter and will not be accepted.'));
       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("To complete this form, please complete the word verification below."));
-      watchdog('mollom', 'Unsure: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
-
+    case MOLLOM_ANALYSIS_UNSURE:
       $form_state['mollom']['require_captcha'] = TRUE;
+      form_set_error('mollom][captcha', t('To complete this form, please complete the word verification below.'));
+      watchdog('mollom', 'Unsure: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
       break;
   }
 }
@@ -1378,11 +1375,10 @@ function mollom_validate_captcha(&$form,
   // When re-validating a form that already passed a CAPTCHA in a previous
   // request, we need to re-populate our global variable for mollom_data_save().
   if ($form_state['mollom']['passed_captcha']) {
-    $GLOBALS['mollom_response'] = $form_state['mollom']['response'];
     return;
   }
 
-  // Bail out if no value was provided.
+  // Nothing to validate if there is no value.
   if (empty($form_state['values']['mollom']['captcha'])) {
     form_set_error('mollom][captcha', t('The word verification field is required.'));
     return;
@@ -1400,9 +1396,7 @@ function mollom_validate_captcha(&$form,
     'author_id' => isset($data['author_id']) ? $data['author_id'] : NULL,
   ));
   // Store the response for #submit handlers.
-  $form_state['mollom']['response']['spam'] = (int) $result;
-  $GLOBALS['mollom_response'] = $form_state['mollom']['response'];
-  $GLOBALS['mollom_form'] = $form['mollom']['#mollom_form'];
+  $form_state['mollom']['response']['captcha'] = $result;
 
   // Explictly check for TRUE, since mollom.checkCaptcha() can also return an
   // error message (e.g. expired or invalid session_id).
@@ -1841,7 +1835,7 @@ function mollom_mail_alter(&$message) {
   // submitted form's hook_mollom_form_info(). This should ensure that the
   // report link is added to mails sent by actual users and not any mails sent
   // by Drupal since they should never be reported as spam.
-  if (!empty($GLOBALS['mollom_form']['mail ids']) && in_array($message['id'], $GLOBALS['mollom_form']['mail ids'])) {
+  if (!empty($GLOBALS['mollom']['mail ids']) && in_array($message['id'], $GLOBALS['mollom']['mail ids'])) {
     mollom_mail_add_report_link($message);
   }
 }
@@ -1850,10 +1844,10 @@ function mollom_mail_alter(&$message) {
  * Add the 'Report as innapropriate' link to an e-mail message.
  */
 function mollom_mail_add_report_link(&$message) {
-  if (!empty($GLOBALS['mollom_response']['session_id'])) {
-    mollom_data_save('session', $GLOBALS['mollom_response']['session_id']);
+  if (!empty($GLOBALS['mollom']['response']['session_id'])) {
+    mollom_data_save('session', $GLOBALS['mollom']['response']['session_id']);
     $report_link = t('Report as inappropriate: @link', array(
-      '@link' => url('mollom/report/session/' . $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)),
+      '@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'])) {
