Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.2.2.32 diff -u -r1.2.2.32 mollom.module --- mollom.module 3 Nov 2008 16:38:37 -0000 1.2.2.32 +++ mollom.module 7 Jan 2009 13:42:58 -0000 @@ -1,5 +1,5 @@ MENU_CALLBACK, ); $items['admin/settings/mollom'] = array( - 'description' => 'Mollom is a web service that helps you manage your community.', + 'description' => 'Mollom is a webservice that helps you manage your community.', 'title' => 'Mollom', 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_admin_settings'), @@ -125,7 +125,10 @@ $response = mollom('mollom.getAudioCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); if ($response) { - $output = ''; + $output = ''; + $output .= ' '; + $output .= ' '; + $output .= ''; $output .= ' ('. t('use image CAPTCHA') .')'; } } @@ -177,7 +180,7 @@ 'unwanted' => t('Report as unwanted, taunting or off-topic content'), ), '#default_value' => 'none', - '#description' => t("Mollom is a web service that helps you moderate your site's content: see http://mollom.com for more information. By sending feedback to Mollom, you teach Mollom what content you like and what content you dislike. Like that, Mollom can do a better job helping you to moderate your site's content. If you want to report multiple posts at once, you can use Mollom's bulk operations on the content and comment administration pages."), + '#description' => t("Mollom is a webservice that helps you moderate your site's content: see http://mollom.com for more information. By sending feedback to Mollom, you teach Mollom what content you like and what content you dislike. Like that, Mollom can do a better job helping you to moderate your site's content."), ); } @@ -267,9 +270,15 @@ * by the contact module. */ function mollom_mail_alter(&$message) { - if (isset($GLOBALS['mollom_response']) && isset($GLOBALS['mollom_response']['session_id'])) { - $message['body'][] = t('Report as inappropriate: @link', array('@link' => url('mollom/contact/'. $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)))); + if ($message['id'] == 'webform_submission') { + $message['body'] .= t('Report as inappropriate: @link', array('@link' => url('mollom/contact/'. $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)))); } + else { + if (isset($GLOBALS['mollom_response']) && isset($GLOBALS['mollom_response']['session_id'])) { + $message['body'][] = t('Report as inappropriate: @link', array('@link' => url('mollom/contact/'. $GLOBALS['mollom_response']['session_id'], array('absolute' => TRUE)))); + } + } + } /** @@ -280,7 +289,7 @@ $form['feedback'] = _mollom_feedback_options(); return confirm_form($form, - t('Are you sure you want to report the e-mail message as inappropriate?'), + t('Are you sure you want to report the e-mail as inappropriate?'), isset($_GET['destination']) ? $_GET['destination'] : '', t('This action cannot be undone.'), t('Report as inappropriate'), t('Cancel')); @@ -292,7 +301,7 @@ function mollom_report_contact_submit($form, &$form_state) { if ($form_state['values']['feedback']) { mollom('mollom.sendFeedback', array('session_id' => $form_state['values']['session'], 'feedback' => $form_state['values']['feedback'])); - drupal_set_message(t('The e-mail has been reported as inappropriate.')); + drupal_set_message('The e-mail has been reported as inappropriate.'); } $form_state['redirect'] = ''; @@ -370,10 +379,9 @@ $form['#validate'][] = 'mollom_comment_admin_overview_submit'; } - // Hook into the mass comment administration page and add some // operations to communicate ham/spam to the XML-RPC server: - if ($form_id == 'node_admin_content') { + if ($form_id == 'node_admin_nodes') { $form['options']['operation']['#options']['mollom-unpublish'] = t('Report to Mollom as spam and unpublish'); $form['options']['operation']['#options']['mollom-delete'] = t('Report to Mollom as spam and delete'); $form['#validate'][] = 'mollom_node_admin_overview_submit'; @@ -579,7 +587,14 @@ 'mode' => MOLLOM_MODE_ANALYSIS, ); } - + if (module_exists('webform')) { + $webformids = db_query("SELECT title, nid FROM {node} WHERE type = '%s' and status = %d", 'webform', 1); + while ($webformid = db_fetch_object($webformids)) { + $forms['webform_client_form_'. $webformid->nid] = array( + 'name' => check_plain('Webform: '. $webformid->title), + 'mode' => MOLLOM_MODE_CAPTCHA); + } + } $forms['user_register'] = array( 'name' => 'user registration form', 'mode' => MOLLOM_MODE_CAPTCHA, @@ -653,10 +668,9 @@ '#type' => 'fieldset', '#title' => t('Spam protection settings'), '#description' => - '

'. t("Mollom can be used to block all sorts of spam received by your website. Your Drupal site will send data you want checked for spam to the Mollom servers, which will reply with either 'spam' or 'ham' (not spam). If Mollom is not fully confident in its decision, it will ask the user to fill out a CAPTCHA. On the rare occasion that Mollom asks the poster to fill out a CAPTCHA, Mollom assumes that all legitimate posters will take the extra time to fill out this CAPTCHA. Using the CAPTCHA, Mollom avoids legitimate messages being incorrectly classified as spam and it eliminates the need to moderate messages that Mollom decided to block.") .'

'. - '

'. t("Administrators can inspect the logs to see what Mollom has blocked. -If Mollom made a mistake and some spam slipped through, you can report it to Mollom when you delete the post or comment. By doing so, Mollom learns how it can do a better job protecting your site. If you want to report multiple posts at once, you can use Mollom's bulk operations on the content administration page or the comment administration page.", array('@logs' => url('admin/reports/dblog'), '@content-admin' => url('admin/content/node'), '@comment-admin' => url('admin/content/comment'))) .'

'. - '

'. t("To perform its service, Mollom processes, stores and compares the data submitted by your site's visitors as explained in our Web Service Privacy Policy. As the controller of the data being processed, it is your responsibility to inform your website's visitors, and to obtain appropriate consent from them to allow Mollom to process their data.") .'

', + '

'. t("Mollom can be used to block all sorts of spam received by your website. Your Drupal site will send data you want checked for spam to the Mollom servers, which will reply with either 'spam' or 'ham' (not spam). If Mollom is not fully confident in its decision, it will ask the user to fill out a CAPTCHA. On the rare occasion that Mollom asks the poster to fill out a CAPTCHA, Mollom assumes that all legitimate posters will take the extra time to fill out this CAPTCHA. Using the CAPTCHA, Mollom avoids legitimate messages being incorrectly classified as spam and it eliminates the need to moderate messages that Mollom decided to block. Administrators can still inspect the logs to see what Mollom has blocked.", array('@logs' => url('admin/reports/dblog'))) .'

'. + '

'. t("To perform its service, Mollom processes, stores and compares the data submitted by your site's visitors as explained in our Web Service Privacy Policy. As the controller of the data being processed, it is your responsibility to inform your website's visitors, and to obtain appropriate consent from them to allow Mollom to process their data.") .'

'. + '

'. t("More information about how Mollom works, is available on the \"How Mollom works\" page and the Mollom FAQ.", array('@mollom-workings' => 'http://mollom.com/how-mollom-works', '@mollom-faq' => 'http://mollom.com/faq')) .'

', '#collapsible' => TRUE, ); @@ -737,7 +751,7 @@ form_set_error('mollom', t("The spam filter that is installed on this site is currently not available. Per the site's policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple minutes.")); } - watchdog('mollom', 'All Mollom servers were unavailable: %servers, last error: @errno - %error_msg', array('%servers' => print_r(variable_get('mollom_servers', array()), TRUE), '@errno' => xmlrpc_errno(), '%error_msg' => xmlrpc_error_msg()), WATCHDOG_ERROR); + watchdog('mollom', 'Mollom was unavailable (servers: %servers, error: @errno - %error_msg)', array('%servers' => variable_get('mollom_servers', array()), '@errno' => xmlrpc_errno(), '%error_msg' => xmlrpc_error_msg()), WATCHDOG_ERROR); } /** @@ -989,11 +1003,11 @@ '#type' => 'textfield', '#name' => 'captcha', '#id' => 'edit-captcha', - '#title' => t('Word verification'), - '#field_prefix' => '
Mollom CAPTCHA ('. t('play audio CAPTCHA') .')
', + '#title' => t('CAPTCHA'), + '#prefix' => '
Mollom CAPTCHA (play audio CAPTCHA)
', '#required' => TRUE, '#size' => 10, - '#description' => t("Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated."), + '#description' => t("Type in the characters shown in the above; if you can't read them, submit the form and a new image will be generated."), '#weight' => $weight, ); @@ -1033,12 +1047,9 @@ } else { watchdog('mollom', 'Error @errno: %server - %message - mollom.getServerList', array('@errno' => xmlrpc_errno(), '%server' => $server, '%message' => xmlrpc_error_msg()), WATCHDOG_ERROR); - - // Reset the XMLRPC error: - xmlrpc_error(0); // FIXME: this is crazy. } } - + return array(); } @@ -1049,25 +1060,20 @@ */ function mollom($method, $data = array()) { - // Initialize refresh variable: - $refresh = FALSE; - // Retrieve the list of Mollom servers from the database: $servers = variable_get('mollom_servers', NULL); if ($servers == NULL) { // Retrieve a new list of servers: $servers = _mollom_retrieve_server_list(); - + // Store the list of servers in the database: variable_set('mollom_servers', $servers); } if (is_array($servers)) { // Send the request to the first server, if that fails, try the other servers in the list: - - reset($servers); - while ($server = current($servers)) { + foreach ($servers as $server) { $result = xmlrpc($server .'/'. MOLLOM_API_VERSION, $method, $data + _mollom_authentication()); // Debug output: @@ -1079,42 +1085,23 @@ } if ($errno = xmlrpc_errno()) { - if ($errno == MOLLOM_REFRESH) { - if (!$refresh) { // Safety pal to avoid endless loops - // Retrieve a list of valid Mollom servers from mollom.com: - $servers = _mollom_retrieve_server_list(); - - // Reset the list of servers so we start from the first server in the list: - reset($servers); + watchdog('mollom', 'Error @errno: %server - %message - %method -
@data
', array('@errno' => xmlrpc_errno(), '%server' => $server, '%message' => xmlrpc_error_msg(), '%method' => $method, '@data' => print_r($data, TRUE)), WATCHDOG_ERROR); - // Store the updated list of servers in the database: - variable_set('mollom_servers', $servers); + if ($errno == MOLLOM_REFRESH) { + // Retrieve a list of valid Mollom servers from mollom.com: + $servers = _mollom_retrieve_server_list(); - // Log this for debuging purposes: - watchdog('mollom', 'The list of available Mollom servers was refreshed: @servers.', array('@servers' => print_r($servers, TRUE))); + // Store the updated list of servers in the database: + variable_set('mollom_servers', $servers); - // Mark that we have refreshed the list: - $refresh = TRUE; - } + // Log this for debuging purposes:: + watchdog('mollom', 'The list of available Mollom servers was set to @servers.', array('@servers' => print_r($servers, TRUE))); } - elseif ($errno == MOLLOM_REDIRECT) { - // If this is a network error, we go to the next server in the list. - $next = next($servers); - - // Do nothing, we automatically select the next server. - watchdog('mollom', 'The Mollom server %server asked to use the next Mollom server in the list: %next.', array('%server' => $server, '%next' => $next)); + elseif ($errno == MOLLOM_ERROR) { + return $result; } - else { - watchdog('mollom', 'Error @errno from %server: %message - %method -
@data
', array('@errno' => xmlrpc_errno(), '%server' => $server, '%message' => xmlrpc_error_msg(), '%method' => $method, '@data' => print_r($data, TRUE)), WATCHDOG_ERROR); - - // If it is a 'clean' Mollom error we return instantly. - - if ($errno == MOLLOM_ERROR) { - return $result; - } - - // If this is a network error, we go to the next server in the list. - next($servers); + elseif ($errno == MOLLOM_REDIRECT) { + // Do nothing, we select the next client automatically. } // Reset the XMLRPC error: @@ -1189,4 +1176,4 @@ function _mollom_debug($message) { // print $message .'
'; // watchdog('mollom', $message); -} +} \ No newline at end of file