Index: mollom.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v retrieving revision 1.48 diff -u -p -r1.48 mollom.admin.inc --- mollom.admin.inc 7 Nov 2010 18:55:32 -0000 1.48 +++ mollom.admin.inc 10 Feb 2011 19:39:33 -0000 @@ -245,6 +245,20 @@ function mollom_admin_configure_form($fo ), ); + $form['mollom']['unsure'] = array( + '#type' => 'checkbox', + '#title' => t('Show a CAPTCHA when Mollom is unsure'), + #'#default_value' => $mollom_form['unsure'], + '#description' => t('Mollom CAPTCHAs are intelligent.', array( + '@help-url' => url('admin/help/mollom'), + )), + '#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 @@ -295,6 +309,40 @@ function mollom_admin_configure_form($fo ), ); } + $form['mollom']['rate_limit'] = array( + '#type' => 'select', + '#title' => t('Minimum interval between posts of same author'), + '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 30, 40, 50, 60, 90, 120, 150, 180), 'format_interval'), + '#empty_value' => '', + '#empty_option' => t('- Default -'), + '#default_value' => isset($mollom_form['rate_limit']) ? $mollom_form['rate_limit'] : NULL, + /* + '#attached' => array( + 'library' => array(array('system', 'ui.slider')), + 'js' => array(array( + 'data' => 'jQuery(function( jQuery("#edit-mollom-rate-limit").slider(); ));', + 'type' => 'inline', + 'scope' => 'footer', + )), + ), + */ + ); + $form['mollom']['strictness'] = array( + '#type' => 'radios', + '#title' => t('Strictness'), + '#options' => array( + 'low' => t('Relaxed'), + 'medium' => t('Normal'), + 'high' => t('Strict'), + ), + '#default_value' => $mollom_form['strictness'], + '#access' => $modes[MOLLOM_MODE_ANALYSIS], + '#states' => array( + 'visible' => array( + ':input[name="mollom[mode]"]' => array('value' => (string) MOLLOM_MODE_ANALYSIS), + ), + ), + ); $form['actions']['submit'] = array( '#type' => 'submit', @@ -361,6 +409,10 @@ function mollom_admin_configure_form_sub } $mollom_form['enabled_fields'] = $enabled_fields; + if ($mollom_form['rate_limit'] === '') { + $mollom_form['rate_limit'] = NULL; + } + $status = mollom_form_save($mollom_form); if ($status === SAVED_NEW) { drupal_set_message(t('The form protection has been added.')); Index: mollom.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v retrieving revision 1.34 diff -u -p -r1.34 mollom.install --- mollom.install 16 Dec 2010 14:50:04 -0000 1.34 +++ mollom.install 10 Feb 2011 19:28:17 -0000 @@ -194,6 +194,18 @@ function mollom_schema() { 'not null' => FALSE, 'serialize' => TRUE, ), + 'rate_limit' => array( + 'description' => 'Rate limit for form submissions.', + 'type' => 'int', + 'not null' => FALSE, + ), + 'strictness' => array( + 'description' => 'Strictness of Mollom checks.', + 'type' => 'varchar', + 'length' => 8, + 'not null' => TRUE, + 'default' => 'medium', + ), 'module' => array( 'description' => 'Module name owning the form.', 'type' => 'varchar', @@ -791,3 +803,26 @@ function mollom_update_7009() { )); } } + +/** + * Add {mollom_form}.rate_limit and {mollom_form}.strictness columns. + */ +function mollom_update_7010() { + if (!db_field_exists('mollom_form', 'rate_limit')) { + db_add_field('mollom_form', 'rate_limit', array( + 'description' => 'Rate limit for form submissions.', + 'type' => 'int', + 'not null' => FALSE, + )); + } + if (!db_field_exists('mollom_form', 'strictness')) { + db_add_field('mollom_form', 'strictness', array( + 'description' => 'Strictness of Mollom checks.', + 'type' => 'varchar', + 'length' => 8, + 'not null' => TRUE, + 'default' => 'medium', + )); + } + // @todo Update 'checks' column; add 'captcha' to all 'spam' checks. +} Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.104 diff -u -p -r1.104 mollom.module --- mollom.module 5 Feb 2011 01:07:06 -0000 1.104 +++ mollom.module 10 Feb 2011 19:29:49 -0000 @@ -851,6 +851,8 @@ function mollom_form_new($form_id = NULL 'mode' => NULL, 'checks' => array(), 'enabled_fields' => array(), + 'rate_limit' => NULL, + 'strictness' => 'medium', ); // Enable all fields for textual analysis by default. if (!empty($mollom_form['elements'])) { @@ -1438,6 +1440,13 @@ function mollom_validate_analysis(&$form } $data['session_id'] = $form_state['mollom']['response']['session_id']; $data['checks'] = implode(',', $form_state['mollom']['checks']); + $data['unsure'] = isset($form_state['mollom']['captcha']) ? 'yes' : 'no'; + + if (isset($form_state['mollom']['rate_limit'])) { + $data['rate_limit'] = $form_state['mollom']['rate_limit']; + } + $data['strictness'] = $form_state['mollom']['strictness']; + $result = mollom('mollom.checkContent', $data); // Use all available data properties for log messages below. $data += $all_data; @@ -1585,6 +1594,9 @@ function mollom_validate_captcha(&$form, 'captcha_result' => $form_state['values']['mollom']['captcha'], 'author_ip' => $all_data['author_ip'], ); + if (isset($form_state['mollom']['rate_limit'])) { + $data['rate_limit'] = $form_state['mollom']['rate_limit']; + } if (isset($all_data['author_id'])) { $data['author_id'] = $all_data['author_id']; }