Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

mollom.module

<?php
// $Id: mollom.module,v 1.2.2.11 2008/05/09 18:55:21 dries Exp $

define('MOLLOM_API_VERSION', '1.0');

define('MOLLOM_ANALYSIS_UNKNOWN' , 0);
define('MOLLOM_ANALYSIS_HAM'     , 1);
define('MOLLOM_ANALYSIS_SPAM'    , 2);
define('MOLLOM_ANALYSIS_UNSURE'  , 3);

define('MOLLOM_MODE_DISABLED', 0);
define('MOLLOM_MODE_CAPTCHA' , 1);
define('MOLLOM_MODE_ANALYSIS', 2);

define('MOLLOM_FALLBACK_BLOCK' , 0);
define('MOLLOM_FALLBACK_ACCEPT', 1);

define('MOLLOM_ERROR'   , 1000);
define('MOLLOM_REFRESH' , 1100);
define('MOLLOM_REDIRECT', 1200);

/**
 * Implementation of hook_help().
 */
function mollom_help($path, $arg) {
  if ($path == 'admin/settings/mollom') {
    return t("Allowing users to react, participate and contribute while still keeping your site's content under control can be a huge challenge. Mollom is a web service that helps you identify content quality and, more importantly, helps you stop spam. When content moderation becomes easier, you have more time and energy to interact with your web community. More information about Mollom is available on the <a href=\"@mollom-website\">Mollom website</a> or in the <a href=\"@mollom-faq\">Mollom FAQ</a>. For support, please consult the <a href=\"@mollom-support\">Mollom support page</a>.", 
        array('@mollom-website' => 'http://mollom.com', 
              '@mollom-faq' => 'http://mollom.com/faq', 
              '@mollom-support' => 'http://mollom.com/support'));
  }
}

/**
 * Implementation of hook_link().
 */
function mollom_link($type, $object = NULL) {
  // We extend the comment links so people can send feedback:
  if ($type == 'comment' && user_access('administer comments') && _mollom_get_mode('comment_form')) {
    $links['comment_spam'] = array(
        'title' => t('mark as abuse'),
        'href' => "mollom/comment/$object->cid"
    );

    return $links;
  }

  if ($type == 'node' && user_access('administer nodes') && _mollom_get_mode($object->type .'_node_form')) {
    $links['node_spam'] = array(
        'title' => t('Delete post'),
        'href' => "mollom/node/$object->nid"
    );

    return $links;
  }
}

/**
 * Implementation of hook_menu().
 */
function mollom_menu() {
  $items['mollom/comment'] = array(
    'title' => 'Report and delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mollom_report_comment'),
    'access arguments' => array('administer comments'),
    'type' => MENU_CALLBACK,
  );
  $items['mollom/node'] = array(
    'title' => 'Report and delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mollom_report_node'),
    'access arguments' => array('administer nodes'),
    'type' => MENU_CALLBACK,
  );
  $items['mollom/contact'] = array(
    'title' => 'Report and delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mollom_report_contact'),
    'access arguments' => array(TRUE), // Everyone can report contact form feedback
    'type' => MENU_CALLBACK,
  );
  $items['admin/settings/mollom'] = array(
    'description' => 'Mollom is a webservice that helps you manage your community.',
    'title' => 'Mollom',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mollom_admin_settings'),
    'access arguments' => array('administer site configuration'),
  );

  // A menu callback that is used for AJAX purposes:
  $items['mollom/captcha/%/%'] = array(
    'title' => 'Request CAPTCHA',
    'page callback' => 'mollom_captcha',
    'page arguments' => array(2, 3),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

/**
 * Implementation of hook_perm().
 */
function mollom_perm() {
  return array('post with no checking');
}

/**
 * An AJAX callback to retrieve a CAPTCHA.
 */
function mollom_captcha($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  = '<object type="audio/mpeg" data="'. check_plain($response['url']) .'" width="50" height="16">';
      $output .= ' <param name="autoplay" value="false" />';
      $output .= ' <param name="controller" value="true" />';
      $output .= '</object>';
      $output .= ' (<a href="#" id="image-captcha">'. t('use image CAPTCHA') .'</a>)';
    }
  }
  
  if ($type == 'image') {
    $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id));

    if ($response) {
      $output = '<a href="http://mollom.com"><img src="'. check_plain(url($response['url'])) .'" alt="Mollom CAPTCHA" /></a>';
      $output .= ' (<a href="#" id="audio-captcha">'. t('play audio CAPTCHA') .'</a>)';
    }
  }
    
  print $output;
  exit();
}

/**
 * Helper function used to load a Mollom session ID from the database.
 */
function mollom_get_data($did) {
  return db_fetch_object(db_query("SELECT * FROM {mollom} WHERE did = '%s'", $did));
}

/**
 * Helper function used to store a Mollom session ID into the database.
 */
function mollom_set_data($session, $quality, $did) {
  if (db_result(db_query("SELECT session FROM {mollom} WHERE did = '%s'", $did))) {
    db_query("UPDATE {mollom} SET session = '%s', quality = '%s' WHERE did = '%s'", $session, $quality, $did);
  }
  else {
    db_query("INSERT INTO {mollom} (session, quality, did) VALUES ('%s', '%s', '%s')", $session, $quality, $did);
  }
}

/**
 * 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 webservice that helps you moderate your site's content: see <a href=\"http://mollom.com\">http://mollom.com</a> 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."),
  );

}

/**
 * This function is used to report a comment as feedback and to delete 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 is used to delete a comment and to optionally send 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 ($data->session && $form_state['values']['feedback']) {
        mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => $form_state['values']['feedback']));
      }

      // Delete 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 is used to delete a node and to optionally send 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 is used to delete a node and to optionally send 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'] = '<front>';
}

/**
 * This function adds a 'report as inappropriate' link to the e-mails that are sent
 * 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))));
  }
}

/**
 * This function is used to report 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 as inappropriate?'),
  isset($_GET['destination']) ? $_GET['destination'] : '',
  t('This action cannot be undone.'),
  t('Report as inappropriate'), t('Cancel'));
}

/**
 * This function is used to report 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('The e-mail has been reported as inappropriate.');
  }

  $form_state['redirect'] = '<front>';
}

/**
 * This function implements the _nodeapi hook and is called when a node is inserted.
 */
function mollom_nodeapi($node, $op) {
  if ($op == 'insert' && isset($GLOBALS['mollom_response']) && isset($GLOBALS['mollom_response']['session_id'])) {
    mollom_set_data($GLOBALS['mollom_response']['session_id'], $GLOBALS['mollom_response']['quality'], 'node-'. $node->nid);
  }
}

/**
 * This function implements the _comment hook and is called when a comment is inserted.
 */
function mollom_comment($comment, $op) {
  if ($op == 'insert' && isset($GLOBALS['mollom_response']) && isset($GLOBALS['mollom_response']['session_id'])) {
    mollom_set_data($GLOBALS['mollom_response']['session_id'], $GLOBALS['mollom_response']['quality'], 'comment-'. $comment['cid']);
  }
}

/**
 * This is a helper function to help insert the CAPTCHA into the form.
 * It's quite an ugly hack due to Drupal 6's inability to handle 
 * dynamic forms.  Let's try to fix this in Drupal 7 and beyond.
 */
function mollom_form_value() {
  return '';
}

/**
 * This function intercepts all forms in Drupal and Mollom-enables them if
 * necessary.
 */
function mollom_form_alter(&$form, $form_state, $form_id) {
     
  // Catch all handlers -- this makes it easy to protect all forms
  // with Mollom.  Site administrators don't have their content
  // checked with Mollom.
  if (!user_access('post with no checking')) {
    // Retrieve the mode of protection that is required for this form:
    $mode = _mollom_get_mode($form_id);
    
    // Some special code that enables to /hack/ the session ID and 
    // the CAPTCHA into the form:
    if (isset($form_state['mollom'])) {
      if (isset($form_state['mollom']['captcha']) && $form_state['mollom']['captcha'] == TRUE) {
        $mode = MOLLOM_MODE_CAPTCHA;
      }
      
      $form['#input'] = TRUE;
      $form['#process'][] = 'mollom_form_process';
    }
    
    if ($mode == MOLLOM_MODE_ANALYSIS) {
      _mollom_debug("mollom_form_alter registered mollom_validate_analysis handler");
      $form['#validate'][] = 'mollom_validate_analysis';
      _mollom_insert_session_id($form, $form_state);
    }
    else if ($mode == MOLLOM_MODE_CAPTCHA) {
      _mollom_debug("mollom_form_alter registered mollom_validate_captcha handler");
      $form['#validate'][] = 'mollom_validate_captcha';
      _mollom_insert_captcha($form, $form_state);
    }
  }
  
  // Hook into the mass comment administration page and add some
  // operations to communicate ham/spam to the XML-RPC server:
  if ($form_id == 'comment_admin_overview') {
    $form['options']['operation']['#options']['mollom-unpublish'] = t('Report the selected comments as spam and unpublish them');
    $form['options']['operation']['#options']['mollom-delete'] = t('Report the selected comments as spam and delete them');
    $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_nodes') {
    $form['options']['operation']['#options']['mollom-unpublish'] = t('Report as spam and unpublish');
    $form['options']['operation']['#options']['mollom-delete'] = t('Report as spam and delete');
    $form['#validate'][] = 'mollom_node_admin_overview_submit';
  }
}

function mollom_comment_admin_overview_submit($form, &$form_state) {
  // The operation has the following format: <operation>,
  // where '<operation>' can be 'unpublish' or 'delete'.
  list($id, $operation) = explode('-', $form_state['values']['operation']);

  if ($id == 'mollom') {
    foreach ($form_state['values']['comments'] as $cid => $value) {
      if ($value) {
        // First, send the proper information to the XML-RPC server:
        if ($data = mollom_get_data('comment-'. $cid)) {
          mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => 'spam'));
        }

        // Second, perform the proper operation on the comments:
        if ($comment = _comment_load($cid)) {
          if ($operation == 'unpublish') {
            db_query("UPDATE {comments} SET status = %d WHERE cid = %d", COMMENT_NOT_PUBLISHED, $cid);
            _comment_update_node_statistics($comment->nid);
          }
          else if ($operation == 'delete') {
            _comment_delete_thread($comment);
            _comment_update_node_statistics($comment->nid);
          }
        }
      }
    }

    // Clear the cache:
    cache_clear_all();

    if ($operation == 'delete') {
      drupal_set_message(t('The selected comments have been reported as inappropriate and are deleted.'));
    }
    else {
      drupal_set_message(t('The selected comments have been reported as inappropriate and are unpublished.'));
    }
  }
}

function mollom_node_admin_overview_submit($form, &$form_state) {
  // The operation has the following format: <operation>,
  // where '<operation>' can be 'unpublish' or 'delete'.
  list($id, $operation) = explode('-', $form_state['values']['operation']);

  if ($id == 'mollom') {
    foreach ($form_state['values']['nodes'] as $nid => $value) {
      if ($value) {
        if ($data = mollom_get_data('node-'. $nid)) {
          mollom('mollom.sendFeedback', array('session_id' => $data->session, 'feedback' => 'spam'));
        }

        if ($node = node_load($nid)) {
          if ($operation == 'unpublish') {
            db_query("UPDATE {node} SET status = 0 WHERE nid = %d", $nid);
          }
          else if ($operation == 'delete') {
            node_delete($nid);
          }
        }
      }
    }

    // Clear the cache:
    cache_clear_all();

    if ($operation == 'delete') {
      drupal_set_message(t('The selected posts have been reported as inappropriate and are deleted.'));
    }
    else {
      drupal_set_message(t('The selected posts have been reported as inappropriate and are unpublished.'));
    }
  }
}

/**
 * This function will be called by mollom_validate to prepare the
 * XML-RPC data from the comment submission form's $form_state['values'] ...
 */
function _mollom_data_contact_mail($form_state) {
  global $user;
  
  $data = array(
      'post_title'     => isset($form_state['subject']) ? $form_state['subject'] : NULL,
      'post_body'      => isset($form_state['message']) ? $form_state['message'] : NULL,
      'author_name'    => isset($form_state['name']) ? $form_state['name'] : (isset($user->name) ? $user->name : NULL),
      'author_mail'    => isset($form_state['mail']) ? $form_state['mail'] : (isset($user->mail) ? $user->mail : NULL),
      'author_openid' => isset($user->uid) ? _mollom_get_openid($user) : NULL,
      'author_id'      => $user->uid > 0 ? $user->uid : NULL,
      'author_ip'      => ip_address(),
  );

  return $data;
}

/**
 * This function will be called by mollom_validate to prepare the
 * XML-RPC data from the comment submission form's $form_state['values'] ...
 */
function mollom_data_contact_mail_page($form_state) {
  return _mollom_data_contact_mail($form_state);
}

/**
 * This function will be called by mollom_validate to prepare the
 * XML-RPC data from the comment submission form's $form_state['values'] ...
 */
function mollom_data_contact_mail_user($form_state) {
  return _mollom_data_contact_mail($form_state);
}

/**
 * This function will be called by mollom_validate to prepare the
 * XML-RPC data from the comment submission form's $form_state['values'] ...
 */
function mollom_data_comment_form($form_state) {
  global $user;
  
  $data = array(
      'post_title'     => isset($form_state['subject']) ? $form_state['subject'] : NULL,
      'post_body'      => isset($form_state['comment']) ? $form_state['comment'] : NULL,
      'author_name'    => isset($form_state['name']) ? $form_state['name'] : (isset($user->name) ? $user->name : NULL),
      'author_mail'    => isset($form_state['mail']) ? $form_state['mail'] : (isset($user->mail) ? $user->mail : NULL),
      'author_url'     => isset($form_state['homepage']) ? $form_state['homepage'] : NULL,
      'author_openid' => isset($user->uid) ? _mollom_get_openid($user) : NULL,
      'author_id'      => $user->uid > 0 ? $user->uid : NULL,
      'author_ip'      => isset($form_state['cid']) ? NULL : ip_address(),
  );
  
  return $data;
}

/**
 * This function will be called by mollom_validate to prepare the
 * XML-RPC data from the comment submission form's $form_state['values'] ...
 */
function mollom_data_node_form($form_state) {
  global $user;

  // Render the node so that all visible fields are prepared and
  // concatenated:
  $data = node_build_content((object)$form_state, FALSE, FALSE);
  $content = drupal_render($data->content);

  $data = array(
      'post_title'    => isset($form_state['title']) ? $form_state['title'] : NULL,
      'post_body'     => $content,
      'author_name'   => isset($form_state['name']) ? $form_state['name'] : (isset($user->name) ? $user->name : NULL),
      'author_mail'   => isset($form_state['mail']) ? $form_state['mail'] : (isset($user->mail) ? $user->mail : NULL),
      'author_url'    => isset($form_state['homepage']) ? $form_state['homepage'] : NULL,
      'author_openid' => isset($user->uid) ? _mollom_get_openid($user) : NULL,
      'author_id'      => $user->uid > 0 ? $user->uid : NULL,
      'author_ip'     => isset($form_state['nid']) ? '' : ip_address(),
  );

  return $data;
}

/**
 * Given a form ID, this function will return the strategy that is used
 * to protect this form.  Could be MOLLOM_MODE_DISABLED (none),
 * MOLLOM_MODE_CAPTCHA (CAPTCHAs only) or MOLLOM_MODE_ANALYSIS (text
 * analysis with smart CAPTCHA support).
 */
function _mollom_get_mode($form_id) {
  if (variable_get('mollom_'. $form_id, MOLLOM_MODE_DISABLED)) {
    $forms = _mollom_protectable_forms();
    return $forms[$form_id]['mode'];
  }

  return MOLLOM_MODE_DISABLED;
}

/**
 * This function lists all the forms that you can protect with Mollom.
 * If you want to protect additional forms with Mollom add the form ID
 * to this list.
 */
function _mollom_protectable_forms() {
  static $forms = NULL;

  if (!$forms) {
    if (module_exists('comment')) {
      $forms['comment_form'] = array(
          'name' => 'comment form',
          'mode' => MOLLOM_MODE_ANALYSIS);
    }

    if (module_exists('contact')) {
      $forms['contact_mail_page'] = array(
          'name' => 'site-wide contact form',
          'mode' => MOLLOM_MODE_ANALYSIS);

      $forms['contact_mail_user'] = array(
          'name' => 'per-user contact forms',
          'mode' => MOLLOM_MODE_ANALYSIS);
    }

    $forms['user_register'] = array(
        'name' => 'user registration form',
        'mode' => MOLLOM_MODE_CAPTCHA);

    $forms['user_pass'] = array(
        'name' => 'user password request form',
        'mode' => MOLLOM_MODE_CAPTCHA);

    // Add all the node types:
    $types = node_get_types('names');
    foreach ($types as $type => $name) {
      $forms[$type .'_node_form'] = array(
          'name' => strtolower($name) ." form",
          'mode' => MOLLOM_MODE_ANALYSIS);
    }
  }

  return $forms;
}

// Temporary test code
function _mollom_update_comments() {
  $result = db_query('SELECT * FROM {comments} LIMIT 1000');
  while ($comment = db_fetch_object($result)) {

    $data = array(
      'post_title'  => $comment->subject,
      'post_body'   => $comment->comment,
    );

    $response = mollom('mollom.checkContent', $data);
    if ($response['spam'] == MOLLOM_ANALYSIS_SPAM) {
      print "$comment->subject<br />$comment->comment<hr />";
    }
    else {
      print $response['spam'];
    }

    //mollom_set_data($response['session_id'], $response['quality'], 'comment-'. $comment->cid);
  }
}

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, we automatically
      // clear the server list.  This will cause 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' => '<div><embed src="http://mollom.com/statistics.swf?key='. check_plain(variable_get('mollom_public_key', '')) .'" quality="high" width="100%" height="430" name="Mollom" align="sessiondle" play="true" loop="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed></div>'
        );

    $form['spam'] = array(
        '#type'=> 'fieldset',
        '#title' => t('Spam protection settings'),
        '#description' => 
          '<p>'. 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 <a href=\"@logs\">logs</a> to see what Mollom has blocked.", array('@logs' => url('admin/reports/dblog'))) .'</p>'.
          '<p>'. t("To perform its service, Mollom processes, stores and compares the data submitted by your site's visitors as explained in our <a href=\"http://mollom.com/service-agreement-free-subscriptions\">Web Service Privacy Policy</a>. 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.") .'</p>'.
          '<p>'. t("More information about how Mollom works, is available on the <a href=\"@mollom-workings\">\"How Mollom works\" page</a> and the <a href=\"@mollom-faq\">Mollom FAQ</a>.", array('@mollom-workings' => 'http://mollom.com/how-mollom-works', '@mollom-faq' => 'http://mollom.com/faq')) .'</p>',
        '#collapsible' => TRUE,
        );

    $forms = _mollom_protectable_forms();
    foreach ($forms as $formid => $details) {
          $name = 'mollom_'. $formid;
          $form['spam'][$name] = array(
          '#type' => 'checkbox',
          '#title' => t('Protect @name', array('@name' => $details['name'])),
          '#default_value' => variable_get($name, MOLLOM_MODE_DISABLED),
          );
    }

    $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 on the protected forms until the server problems are resolved'),
          MOLLOM_FALLBACK_ACCEPT => t('Leave all forms unprotected and accept all submissions')
        ),
        '#description' => t('In the very unlikely event that the Mollom servers are down or otherwise unreachable, no text analysis can be performed and no CAPTCHAs can be generated. At that point, your Drupal site will use the configured fallback strategy. You can choose to blindly accept all submissions without spam checking, or you can choose to block all submissions until the server or connection problems are resolved.'),
      );
  }

  $form['access-keys'] = array(
      '#type'=> 'fieldset',
      '#title' => t('Mollom access keys'),
      '#description' => t('In order to use Mollom, you need a public and a private key. Visit <a href="http://mollom.com/user">http://mollom.com/user</a> and create a user account to obtain a private and a public access key.'),
      '#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. It is like a password and 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.
 */
function