Index: mollom.admin.inc =================================================================== RCS file: mollom.admin.inc diff -N mollom.admin.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mollom.admin.inc 25 Mar 2009 22:00:06 -0000 @@ -0,0 +1,129 @@ + 'fieldset', + '#title' => t('Site usage statistics'), + '#collapsible' => TRUE, + ); + $form['statistics']['message'] = array( + '#value' => '
', + ); + + $form['spam'] = array( + '#type' => 'fieldset', + '#title' => t('Spam protection settings'), + '#description' => + '

'. t("Mollom can be used to block all types of spam received on your website's protected forms. Each form can be set to one of the following options:") .'

'. + ''. + '

'. t("Data is processsed and stored as explained in our Web Service Privacy Policy. It is your responsibility to provide any necessary notices and obtain the appropriate consent regarding Mollom's use of your data. For more information, see How Mollom Works and the Mollom FAQ.", array('@mollom-privacy' => 'http://mollom.com/service-agreement-free-subscriptions', '@mollom-works' => 'http://mollom.com/how-mollom-works', '@mollom-faq' => 'http://mollom.com/faq')) .'

', + '#collapsible' => TRUE, + ); + + $forms = _mollom_protectable_forms(); + foreach ($forms as $form_id => $details) { + $mode = _mollom_get_mode($form_id); + $name = 'mollom_'. $form_id; + + $options = array_slice(array( + MOLLOM_MODE_DISABLED => t('No protection'), + MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'), + MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'), + ), 0, $details['mode'] + 1); + + $form['spam'][$name] = array( + '#type' => 'select', + '#title' => t('Protect @name', array('@name' => $details['name'])), + '#options' => $options, + '#default_value' => $mode, + ); + } + + $form['server'] = array( + '#type' => 'fieldset', + '#title' => t('Server settings'), + '#collapsible' => TRUE, + '#collapsed' => $keys, + ); + $form['server']['mollom_fallback'] = array( + '#type' => 'radios', + '#title' => t('Fallback strategy'), + '#default_value' => variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK), // we default to treating everything as inappropriate + '#options' => array( + MOLLOM_FALLBACK_BLOCK => t('Block all submissions of protected forms until the server problems are resolved'), + MOLLOM_FALLBACK_ACCEPT => t('Leave all forms unprotected and accept all submissions'), + ), + '#description' => t('When the Mollom servers are down or otherwise unreachable, no text analysis is performed and no CAPTCHAs are generated. If this occurs, your Drupal site will use the configured fallback strategy, and will either accept all submissions without spam checking, or block all submissions until the server or connection problems are resolved. Subscribers to Mollom Plus receive access to Mollom\'s high-availability backend infrastructure, not available to free users, reducing potential downtime.', array('@pricing' => 'http://mollom.com/pricing', '@sla' => 'http://mollom.com/standard-service-level-agreement')), + ); + } + + $form['access-keys'] = array( + '#type' => 'fieldset', + '#title' => t('Mollom access keys'), + '#description' => t('In order to use Mollom, you need both a public and private key. To obtain your keys, simply create a user account on mollom.com, login to mollom.com, and create a subscription for your site. Once you created a subscription, your private and public access keys will be available from the site manager on mollom.com. Copy-paste them in the form below, and you are ready to go.', array('@mollom-user' => 'http://mollom.com/user', '@mollom-site-add' => 'http://mollom.com/site-manager/add', '@mollom-sites' => 'http://mollom.com/site-manager')), + '#collapsible' => TRUE, + '#collapsed' => $keys, + ); + $form['access-keys']['mollom_public_key'] = array( + '#type' => 'textfield', + '#title' => t('Public key'), + '#default_value' => variable_get('mollom_public_key', ''), + '#description' => t('The public key is used to uniquely identify you.'), + '#required' => TRUE, + ); + $form['access-keys']['mollom_private_key'] = array( + '#type' => 'textfield', + '#title' => t('Private key'), + '#default_value' => variable_get('mollom_private_key', ''), + '#description' => t('The private key is used to prevent someone from hijacking your requests. Similar to a password, it should never be shared with anyone.'), + '#required' => TRUE, + ); + + return system_settings_form($form); +} + +/** + * This function contacts Mollom to verify the configured key pair. + */ +function _mollom_verify_key() { + $status = mollom('mollom.verifyKey'); + + $message = t('We contacted the Mollom servers to verify your keys'); + + if ($status) { + drupal_set_message(t('@message: the Mollom services are operating correctly. We are now blocking spam.', array('@message' => $message))); + } + else { + drupal_set_message(t('@message: your keys do not exist or are no longer valid. Please visit the Manage sites page on the Mollom website again: @mollom-user.', array('@message' => $message, '@mollom-user' => 'http://mollom.com/user')), 'error'); + } +} Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.2.2.55 diff -u -p -r1.2.2.55 mollom.module --- mollom.module 25 Feb 2009 07:41:00 -0000 1.2.2.55 +++ mollom.module 25 Mar 2009 22:00:08 -0000 @@ -92,6 +92,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_admin_settings'), 'access arguments' => array('administer site configuration'), + 'file' => 'mollom.admin.inc', ); // Menu callback used for AJAX purposes: @@ -639,106 +640,6 @@ function _mollom_update_comments() { } } -function mollom_admin_settings() { - - // _mollom_update_comments(); - - $keys = variable_get('mollom_public_key', '') && variable_get('mollom_private_key', ''); - - if ($keys) { - // Print a status message about the key: - if (!$_POST) { - // When a user visits the Mollom administration page, automatically - // clear the server list. This causes the client to fetch a fresh - // server list from the server. - variable_del('mollom_servers'); - - // Verify the key: - _mollom_verify_key(); - } - - $form['statistics'] = array( - '#type' => 'fieldset', - '#title' => t('Site usage statistics'), - '#collapsible' => TRUE, - ); - $form['statistics']['message'] = array( - '#value' => '
', - ); - - $form['spam'] = array( - '#type' => 'fieldset', - '#title' => t('Spam protection settings'), - '#description' => - '

'. t("Mollom can be used to block all types of spam received on your website's protected forms. Each form can be set to one of the following options:") .'

'. - ''. - '

'. t("Data is processsed and stored as explained in our Web Service Privacy Policy. It is your responsibility to provide any necessary notices and obtain the appropriate consent regarding Mollom's use of your data. For more information, see How Mollom Works and the Mollom FAQ.") .'

', - '#collapsible' => TRUE, - ); - - $forms = _mollom_protectable_forms(); - foreach ($forms as $form_id => $details) { - $mode = _mollom_get_mode($form_id); - $name = 'mollom_'. $form_id; - - $options = array_slice(array( - MOLLOM_MODE_DISABLED => t('No protection'), - MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'), - MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'), - ), 0, $details['mode'] + 1); - - $form['spam'][$name] = array( - '#type' => 'select', - '#title' => t('Protect @name', array('@name' => $details['name'])), - '#options' => $options, - '#default_value' => $mode, - ); - } - - $form['server'] = array( - '#type' => 'fieldset', - '#title' => t('Server settings'), - '#collapsible' => TRUE, - '#collapsed' => $keys, - ); - $form['server']['mollom_fallback'] = array( - '#type' => 'radios', - '#title' => t('Fallback strategy'), - '#default_value' => variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK), // we default to treating everything as inappropriate - '#options' => array( - MOLLOM_FALLBACK_BLOCK => t('Block all submissions of protected forms until the server problems are resolved'), - MOLLOM_FALLBACK_ACCEPT => t('Leave all forms unprotected and accept all submissions'), - ), - '#description' => t('When the Mollom servers are down or otherwise unreachable, no text analysis is performed and no CAPTCHAs are generated. If this occurs, your Drupal site will use the configured fallback strategy, and will either accept all submissions without spam checking, or block all submissions until the server or connection problems are resolved. Subscribers to Mollom Plus receive access to Mollom\'s high-availability backend infrastructure, not available to free users, reducing potential downtime.', array('@pricing' => 'http://mollom.com/pricing', '@sla' => 'http://mollom.com/standard-service-level-agreement'))); - } - - $form['access-keys'] = array( - '#type' => 'fieldset', - '#title' => t('Mollom access keys'), - '#description' => t('In order to use Mollom, you need both a public and private key. To obtain your keys, simply create a user account on mollom.com, login to mollom.com, and create a subscription for your site. Once you created a subscription, your private and public access keys will be available from the site manager on mollom.com. Copy-paste them in the form below, and you are ready to go.'), - '#collapsible' => TRUE, - '#collapsed' => $keys, - ); - $form['access-keys']['mollom_public_key'] = array( - '#type' => 'textfield', - '#title' => t('Public key'), - '#default_value' => variable_get('mollom_public_key', ''), - '#description' => t('The public key is used to uniquely identify you.'), - '#required' => TRUE, - ); - $form['access-keys']['mollom_private_key'] = array( - '#type' => 'textfield', - '#title' => t('Private key'), - '#default_value' => variable_get('mollom_private_key', ''), - '#description' => t('The private key is used to prevent someone from hijacking your requests. Similar to a password, it should never be shared with anyone.'), - '#required' => TRUE, - ); - - return system_settings_form($form); -} - /** * A helper function that returns the OpenID identifiers associated with the specified user account. */ @@ -1031,22 +932,6 @@ function _mollom_insert_captcha(&$mollom } /** - * This function contacts Mollom to verify the configured key pair. - */ -function _mollom_verify_key() { - $status = mollom('mollom.verifyKey'); - - $message = t('We contacted the Mollom servers to verify your keys'); - - if ($status) { - drupal_set_message(t('@message: the Mollom services are operating correctly. We are now blocking spam.', array('@message' => $message))); - } - else { - drupal_set_message(t('@message: your keys do not exist or are no longer valid. Please visit the Manage sites page on the Mollom website again: @mollom-user.', array('@message' => $message, '@mollom-user' => 'http://mollom.com/user')), 'error'); - } -} - -/** * This function refreshes the list of servers that can be used to contact Mollom. */ function _mollom_retrieve_server_list() {