From 01a196feba6a680a60c9fdfc586e52c85ae55bf8 Mon Sep 17 00:00:00 2001
From: sun <sun@unleashedmind.com>
Date: Thu, 29 Sep 2011 18:30:59 +0200
Subject: [PATCH] Added "unsure" parameter for text analysis.

---
 mollom.admin.inc |   12 ++++++++++++
 mollom.install   |   23 +++++++++++++++++++++++
 mollom.module    |    2 ++
 3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/mollom.admin.inc b/mollom.admin.inc
index b0e96be..b7bd8bb 100644
--- a/mollom.admin.inc
+++ b/mollom.admin.inc
@@ -244,6 +244,18 @@ function mollom_admin_configure_form($form, &$form_state, $mollom_form = NULL) {
           ),
         );
 
+        // Spam check CAPTCHA mode.
+        $form['mollom']['unsure'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Require to solve a CAPTCHA if text analysis is unsure'),
+          '#default_value' => $mollom_form['unsure'],
+          '#states' => array(
+            'visible' => array(
+              ':input[name="mollom[checks][spam]"]' => array('checked' => TRUE),
+            ),
+          ),
+        );
+
         // Form elements defined by hook_mollom_form_info() use the
         // 'parent][child' syntax, which Form API also uses internally for
         // form_set_error(), and which allows us to recurse into nested fields
diff --git a/mollom.install b/mollom.install
index 86200cc..c0ce730 100644
--- a/mollom.install
+++ b/mollom.install
@@ -180,6 +180,13 @@ function mollom_schema() {
         'not null' => FALSE,
         'serialize' => TRUE,
       ),
+      'unsure' => array(
+        'description' => 'Whether to allow (1) or disallow (0) "unsure" text analysis results.',
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 1,
+      ),
       'discard' => array(
         'description' => 'Whether to discard (1) or retain (0) bad posts.',
         'type' => 'int',
@@ -834,3 +841,19 @@ function mollom_update_7011() {
     ->fields(array('strictness' => 'normal'))
     ->execute();
 }
+
+/**
+ * Add {mollom_form}.unsure.
+ */
+function mollom_update_7012() {
+  if (!db_field_exists('mollom_form', 'unsure')) {
+    db_add_field('mollom_form', 'unsure', array(
+      'description' => 'Whether to allow (1) or disallow (0) "unsure" text analysis results.',
+      'type' => 'int',
+      'size' => 'tiny',
+      'not null' => TRUE,
+      'default' => 1,
+    ));
+  }
+}
+
diff --git a/mollom.module b/mollom.module
index 98f09c5..21567b9 100644
--- a/mollom.module
+++ b/mollom.module
@@ -888,6 +888,7 @@ function mollom_form_new($form_id = NULL) {
     'title' => $form_id,
     'mode' => NULL,
     'checks' => array(),
+    'unsure' => 1,
     'enabled_fields' => array(),
     'strictness' => 'normal',
   );
@@ -1520,6 +1521,7 @@ function mollom_validate_analysis(&$form, &$form_state) {
   }
   $data['session_id'] = $form_state['mollom']['response']['session_id'];
   $data['checks'] = implode(',', $form_state['mollom']['checks']);
+  $data['unsure'] = ($form_state['mollom']['unsure'] ? 'true' : 'false');
   $data['strictness'] = $form_state['mollom']['strictness'];
   $result = mollom('mollom.checkContent', $data);
 
-- 
1.7.4.msysgit.0

