? mollom.temp.inc 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 29 Mar 2009 06:25:56 -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.57 diff -u -p -r1.2.2.57 mollom.module --- mollom.module 29 Mar 2009 04:47:05 -0000 1.2.2.57 +++ mollom.module 29 Mar 2009 06:25:56 -0000 @@ -70,6 +70,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_comment'), 'access arguments' => array('administer comments'), + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['mollom/node'] = array( @@ -77,6 +78,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_node'), 'access arguments' => array('administer nodes'), + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['mollom/contact'] = array( @@ -84,6 +86,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_contact'), 'access arguments' => array(TRUE), // Everyone can report contact form feedback. + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['admin/settings/mollom'] = array( @@ -92,6 +95,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_admin_settings'), 'access arguments' => array('administer mollom'), + 'file' => 'mollom.admin.inc', ); // Menu callback used for AJAX purposes: @@ -100,6 +104,7 @@ function mollom_menu() { 'page callback' => 'mollom_captcha_js', 'page arguments' => array(2, 3), 'access callback' => TRUE, + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); @@ -117,36 +122,6 @@ function mollom_perm() { } /** - * AJAX callback to retrieve a CAPTCHA. - */ -function mollom_captcha_js($type, $session_id) { - - // TODO: add error handling. - $output = ''; - - if ($type == 'audio') { - $response = mollom('mollom.getAudioCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); - - if ($response) { - $output = ''; - $output .= ' ('. t('use image CAPTCHA') .')'; - } - } - - if ($type == 'image') { - $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); - - if ($response) { - $output = 'Mollom CAPTCHA'; - $output .= ' ('. t('play audio CAPTCHA') .')'; - } - } - - print $output; - exit(); -} - -/** * Helper function to load a Mollom session ID from the database. */ function mollom_get_data($did) { @@ -166,106 +141,6 @@ function mollom_set_data($session, $qual } /** - * Return a list of the possible feedback options for content. - */ -function _mollom_feedback_options() { - return array( - '#type' => 'radios', - '#title' => t('Optionally report this to Mollom'), - '#options' => array( - 'none' => t("Don't send feedback to Mollom"), - 'spam' => t('Report as spam or unsolicited advertising'), - 'profanity' => t('Report as obscene, violent or profane content'), - 'low-quality' => t('Report as low-quality content or writing'), - '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 about the content you like and dislike, allowing Mollom to do a better job helping you 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."), - ); -} - -/** - * This function reports a comment as feedback and deletes it. - */ -function mollom_report_comment($form_state, $cid) { - if ($comment = _comment_load($cid)) { - $form['cid'] = array('#type' => 'value', '#value' => $cid); - $form['feedback'] = _mollom_feedback_options(); - - return confirm_form($form, - t('Are you sure you want to delete the comment and report it?'), - isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $comment->nid, - t('This action cannot be undone.'), - t('Delete'), t('Cancel')); - } -} - -/** - * This function deletes a comment and optionally sends feedback to Mollom. - */ -function mollom_report_comment_submit($form, &$form_state) { - if ($form_state['values']['confirm']) { - if ($comment = _comment_load($form_state['values']['cid'])) { - // Load the Mollom session data: - $data = mollom_get_data('comment-'. $comment->cid); - - // Provide feedback to Mollom if available: - if (isset($data) && isset($data->session) && isset($form_state['values']['feedback'])) { - mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => $form_state['values']['feedback'])); - } - - // Delete a comment and its replies: - include_once drupal_get_path('module', 'comment') .'/comment.admin.inc'; - _comment_delete_thread($comment); - _comment_update_node_statistics($comment->nid); - cache_clear_all(); - - drupal_set_message(t('The comment has been deleted.')); - } - } - $form_state['redirect'] = "node/$comment->nid"; -} - -/** - * This function deletes a node and optionally sends feedback to Mollom. - */ -function mollom_report_node($form_state, $nid) { - if ($node = node_load($nid)) { - $form['nid'] = array('#type' => 'value', '#value' => $node->nid); - $form['feedback'] = _mollom_feedback_options(); - - return confirm_form($form, - t('Are you sure you want to delete %title and report it?', array('%title' => $node->title)), - isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid, - t('This action cannot be undone.'), - t('Delete'), t('Cancel')); - } -} - -/** - * This function deletes a node and optionally sends feedback to Mollom. - */ -function mollom_report_node_submit($form, &$form_state) { - if ($form_state['values']['confirm']) { - if ($node = node_load($form_state['values']['nid'])) { - // Load the Mollom session data: - $data = mollom_get_data('node-'. $node->nid); - - // Provide feedback to Mollom if available: - if ($data->session && $form_state['values']['feedback']) { - mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => $form_state['values']['feedback'])); - } - - // Delete the node. Calling this function will delete any comments, - // clear the cache and print a status message. - node_delete($node->nid); - } - } - - $form_state['redirect'] = ''; -} - -/** * This function adds a 'report as inappropriate' link to the e-mails sent * by the contact module. */ @@ -276,32 +151,6 @@ function mollom_mail_alter(&$message) { } /** - * This function reports a contact form message as inappropriate. - */ -function mollom_report_contact($form_state, $session) { - $form['session'] = array('#type' => 'value', '#value' => $session); - $form['feedback'] = _mollom_feedback_options(); - - return confirm_form($form, - t('Are you sure you want to report the e-mail message as inappropriate?'), - isset($_GET['destination']) ? $_GET['destination'] : '', - t('This action cannot be undone.'), - t('Report as inappropriate'), t('Cancel')); -} - -/** - * This function reports a contact form message as inappropriate. - */ -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.')); - } - - $form_state['redirect'] = ''; -} - -/** * This function implements the _nodeapi hook and is called when a node is inserted. */ function mollom_nodeapi($node, $op) { @@ -642,107 +491,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. */ @@ -1035,22 +783,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() { Index: mollom.pages.inc =================================================================== RCS file: mollom.pages.inc diff -N mollom.pages.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mollom.pages.inc 29 Mar 2009 06:25:57 -0000 @@ -0,0 +1,163 @@ + ip_address(), 'session_id' => $session_id)); + + if ($response) { + $output = ''; + $output .= ' ('. t('use image CAPTCHA') .')'; + } + } + + if ($type == 'image') { + $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); + + if ($response) { + $output = 'Mollom CAPTCHA'; + $output .= ' ('. t('play audio CAPTCHA') .')'; + } + } + + print $output; + exit(); +} + +/** + * This function reports a comment as feedback and deletes it. + */ +function mollom_report_comment($form_state, $cid) { + if ($comment = _comment_load($cid)) { + $form['cid'] = array('#type' => 'value', '#value' => $cid); + $form['feedback'] = _mollom_feedback_options(); + + return confirm_form($form, + t('Are you sure you want to delete the comment and report it?'), + isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $comment->nid, + t('This action cannot be undone.'), + t('Delete'), t('Cancel')); + } +} + +/** + * This function deletes a comment and optionally sends feedback to Mollom. + */ +function mollom_report_comment_submit($form, &$form_state) { + if ($form_state['values']['confirm']) { + if ($comment = _comment_load($form_state['values']['cid'])) { + // Load the Mollom session data: + $data = mollom_get_data('comment-'. $comment->cid); + + // Provide feedback to Mollom if available: + if (isset($data) && isset($data->session) && isset($form_state['values']['feedback'])) { + mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => $form_state['values']['feedback'])); + } + + // Delete a comment and its replies: + include_once drupal_get_path('module', 'comment') .'/comment.admin.inc'; + _comment_delete_thread($comment); + _comment_update_node_statistics($comment->nid); + cache_clear_all(); + + drupal_set_message(t('The comment has been deleted.')); + } + } + $form_state['redirect'] = "node/$comment->nid"; +} + +/** + * This function deletes a node and optionally sends feedback to Mollom. + */ +function mollom_report_node($form_state, $nid) { + if ($node = node_load($nid)) { + $form['nid'] = array('#type' => 'value', '#value' => $node->nid); + $form['feedback'] = _mollom_feedback_options(); + + return confirm_form($form, + t('Are you sure you want to delete %title and report it?', array('%title' => $node->title)), + isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid, + t('This action cannot be undone.'), + t('Delete'), t('Cancel')); + } +} + +/** + * This function deletes a node and optionally sends feedback to Mollom. + */ +function mollom_report_node_submit($form, &$form_state) { + if ($form_state['values']['confirm']) { + if ($node = node_load($form_state['values']['nid'])) { + // Load the Mollom session data: + $data = mollom_get_data('node-'. $node->nid); + + // Provide feedback to Mollom if available: + if ($data->session && $form_state['values']['feedback']) { + mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => $form_state['values']['feedback'])); + } + + // Delete the node. Calling this function will delete any comments, + // clear the cache and print a status message. + node_delete($node->nid); + } + } + + $form_state['redirect'] = ''; +} + +/** + * This function reports a contact form message as inappropriate. + */ +function mollom_report_contact($form_state, $session) { + $form['session'] = array('#type' => 'value', '#value' => $session); + $form['feedback'] = _mollom_feedback_options(); + + return confirm_form($form, + t('Are you sure you want to report the e-mail message as inappropriate?'), + isset($_GET['destination']) ? $_GET['destination'] : '', + t('This action cannot be undone.'), + t('Report as inappropriate'), t('Cancel')); +} + +/** + * This function reports a contact form message as inappropriate. + */ +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.')); + } + + $form_state['redirect'] = ''; +} + +/** + * Return a list of the possible feedback options for content. + */ +function _mollom_feedback_options() { + return array( + '#type' => 'radios', + '#title' => t('Optionally report this to Mollom'), + '#options' => array( + 'none' => t("Don't send feedback to Mollom"), + 'spam' => t('Report as spam or unsolicited advertising'), + 'profanity' => t('Report as obscene, violent or profane content'), + 'low-quality' => t('Report as low-quality content or writing'), + '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 about the content you like and dislike, allowing Mollom to do a better job helping you 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."), + ); +}