Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/Attic/mollom.admin.inc,v
retrieving revision 1.1.2.12
diff -u -p -r1.1.2.12 mollom.admin.inc
--- mollom.admin.inc	14 Dec 2009 12:47:16 -0000	1.1.2.12
+++ mollom.admin.inc	19 Dec 2009 21:49:52 -0000
@@ -22,23 +22,29 @@ function mollom_admin_form_list() {
     array('data' => t('Operations'), 'colspan' => 2),
   );
   $rows = array();
-  $result = db_query("SELECT form_id FROM {mollom_form}");
-  while ($form_id = db_result($result)) {
+  $result = db_query('SELECT form_id FROM {mollom_form}')->fetchCol();
+  foreach ($result as $form_id) {
     $mollom_form = mollom_form_load($form_id);
     $rows[] = array(
       $mollom_form['title'],
       $modes[$mollom_form['mode']],
-      l(t('Configure'), 'admin/settings/mollom/manage/' . $form_id),
-      l(t('Unprotect'), 'admin/settings/mollom/unprotect/' . $form_id),
+      l(t('Configure'), 'admin/config/content/mollom/manage/' . $form_id),
+      l(t('Unprotect'), 'admin/config/content/mollom/unprotect/' . $form_id),
     );
   }
 
   // Add a row to add a form.
   if (empty($rows)) {
-    $rows[] = array(array('data' => l(t('Add form'), 'admin/settings/mollom/add'), 'colspan' => 4));
+    $rows[] = array(array('data' => l(t('Add form'), 'admin/config/content/mollom/add'), 'colspan' => 4));
   }
 
-  return theme('table', $header, $rows);
+  $build['forms'] = array(
+    '#theme' => 'table',
+    '#header' => $header,
+    '#rows' => $rows,
+  );
+
+  return $build;
 }
 
 /**
@@ -49,25 +55,23 @@ function mollom_admin_form_options() {
   $form_info = mollom_get_form_info();
 
   // Remove already configured form ids.
-  $result = db_query("SELECT form_id FROM {mollom_form}");
-  while ($form_id = db_result($result)) {
+  $result = db_query('SELECT form_id FROM {mollom_form}')->fetchCol();
+  foreach ($result as $form_id) {
     unset($form_info[$form_id]);
   }
   // If all registered forms are configured already, output a message, and
   // redirect the user back to overview.
   if (empty($form_info)) {
     drupal_set_message(t('All available forms are protected already.'));
-    drupal_goto('admin/settings/mollom');
+    drupal_goto('admin/config/content/mollom');
   }
 
   // Load module information.
   $modules = module_implements('mollom_form_info');
-  $placeholders = db_placeholders($modules, 'varchar');
-  $result = db_query("SELECT name, info FROM {system} WHERE type = 'module' AND name IN ($placeholders)", $modules);
-  $modules = array();
-  while ($row = db_fetch_object($result)) {
-    $module_info = unserialize($row->info);
-    $modules[$row->name] = t($module_info['name']);
+  $modules = db_query("SELECT name, info FROM {system} WHERE type = :type AND name IN (:name)", array(':type' => 'module', ':name' => $modules))->fetchAllKeyed();
+  foreach ($modules as $name => $info) {
+    $module_info = unserialize($info);
+    $modules[$name] = t($module_info['name']);
   }
 
   // Transform form information into an associative array suitable for #options.
@@ -83,7 +87,7 @@ function mollom_admin_form_options() {
 /**
  * Form builder; Configure Mollom protection for a form.
  */
-function mollom_admin_configure_form(&$form_state, $mollom_form = NULL) {
+function mollom_admin_configure_form($form, &$form_state, $mollom_form = NULL) {
   // If no $mollom_form was passed, then we are adding a new form configuration.
   if (!isset($mollom_form)) {
     if (!isset($form_state['storage']['mollom_form'])) {
@@ -101,6 +105,11 @@ function mollom_admin_configure_form(&$f
   }
 
   $form['#tree'] = TRUE;
+  $form['actions'] = array(
+    '#type' => 'container',
+    '#attributes' => array('class' => array('form-actions')),
+    '#weight' => 100,
+  );
 
   switch ($form_state['storage']['step']) {
     case 'select':
@@ -128,7 +137,7 @@ function mollom_admin_configure_form(&$f
       $form['mollom']['form_title'] = array(
         '#type' => 'item',
         '#title' => t('Form'),
-        '#value' => $mollom_form['title'],
+        '#markup' => $mollom_form['title'],
       );
       // Form elements defined by hook_mollom_form_info() use the
       // 'parent][child' syntax, which Form API also uses internally for
@@ -168,7 +177,7 @@ function mollom_admin_configure_form(&$f
   }
 
   $form['actions']['cancel'] = array(
-    '#value' => l(t('Cancel'), 'admin/settings/mollom'),
+    '#markup' => l(t('Cancel'), 'admin/config/content/mollom'),
   );
 
   return $form;
@@ -192,6 +201,7 @@ function mollom_admin_configure_form_nex
   $form_state['storage']['mollom_form'] = $mollom_form;
 
   $form_state['storage']['step'] = 'configure';
+  $form_state['rebuild'] = TRUE;
 }
 
 /**
@@ -222,19 +232,18 @@ function mollom_admin_configure_form_sub
     drupal_set_message('The form protection has been updated.');
   }
 
-  unset($form_state['storage']);
-  $form_state['redirect'] = 'admin/settings/mollom';
+  $form_state['redirect'] = 'admin/config/content/mollom';
 }
 
 /**
  * Form builder; Remove Mollom protection from a form.
  */
-function mollom_admin_unprotect_form(&$form_state, $mollom_form) {
+function mollom_admin_unprotect_form($form, &$form_state, $mollom_form) {
   $form['#tree'] = TRUE;
   $form['form'] = array(
     '#type' => 'item',
     '#title' => t('Form'),
-    '#value' => $mollom_form['title'],
+    '#markup' => $mollom_form['title'],
   );
   $form['mollom']['form_id'] = array(
     '#type' => 'value',
@@ -243,7 +252,7 @@ function mollom_admin_unprotect_form(&$f
 
   return confirm_form($form,
     t('Are you sure you want to unprotect this form?'),
-    'admin/settings/mollom',
+    'admin/config/content/mollom',
     t('Mollom will no longer protect this form from spam.')
   );
 }
@@ -252,15 +261,15 @@ function mollom_admin_unprotect_form(&$f
  * Form submit handler for mollom_admin_unprotect_form().
  */
 function mollom_admin_unprotect_form_submit($form, &$form_state) {
-  db_query("DELETE FROM {mollom_form} WHERE form_id = '%s'", $form_state['values']['mollom']['form_id']);
+  db_delete('mollom_form')->condition('form_id', $form_state['values']['mollom']['form_id'])->execute();
 
-  $form_state['redirect'] = 'admin/settings/mollom';
+  $form_state['redirect'] = 'admin/config/content/mollom';
 }
 
 /**
  * Form builder; Global Mollom settings form.
  */
-function mollom_admin_settings() {
+function mollom_admin_settings($form, &$form_state) {
   $keys = _mollom_access();
   // Since keys are not verified in HTTP POST requests, we need to default to
   // a successful key status. Otherwise, the fallback form elements would not
@@ -286,7 +295,6 @@ function mollom_admin_settings() {
   $form['server'] = array(
     '#type' => 'fieldset',
     '#title' => t('Server settings'),
-    '#access' => $status,
   );
   $form['server']['mollom_fallback'] = array(
     '#type' => 'radios',
@@ -320,14 +328,12 @@ function mollom_admin_settings() {
     '#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);
@@ -370,13 +376,16 @@ function mollom_comment_admin_overview_s
         }
 
         // Second, perform the proper operation on the comments:
-        if ($comment = _comment_load($cid)) {
+        if ($comment = comment_load($cid)) {
           if ($operation == 'unpublish') {
-            db_query("UPDATE {comments} SET status = %d WHERE cid = %d", COMMENT_NOT_PUBLISHED, $cid);
+            db_update('comment')
+              ->fields(array('status' => COMMENT_NOT_PUBLISHED))
+              ->condition('cid', $cid)
+              ->execute();
             _comment_update_node_statistics($comment->nid);
           }
           elseif ($operation == 'delete') {
-            _comment_delete_thread($comment);
+            comment_delete($comment);
             _comment_update_node_statistics($comment->nid);
           }
         }
@@ -412,7 +421,10 @@ function mollom_node_admin_overview_subm
 
         if ($node = node_load($nid)) {
           if ($operation == 'unpublish') {
-            db_query("UPDATE {node} SET status = 0 WHERE nid = %d", $nid);
+            db_update('node')
+              ->fields(array('status' => NODE_NOT_PUBLISHED))
+              ->condition('nid', $nid)
+              ->execute();
           }
           elseif ($operation == 'delete') {
             node_delete($nid);
@@ -436,7 +448,7 @@ function mollom_node_admin_overview_subm
 /**
  * Menu callback; Displays the administrative reports page.
  */
-function mollom_reports_page() {
+function mollom_reports_page($form, &$form_state) {
   $embed_attributes = array(
     'src' => 'http://mollom.com/statistics.swf?key=' . check_plain(variable_get('mollom_public_key', '')),
     'quality' => 'high',
@@ -453,20 +465,21 @@ function mollom_reports_page() {
   $form['chart'] = array(
     '#type' => 'item',
     '#title' => t('Statistics'),
-    '#value' => '<embed' . drupal_attributes($embed_attributes) . '></embed>',
+    '#markup' => '<embed' . drupal_attributes($embed_attributes) . '></embed>',
   );
   if (module_exists('dblog')) {
     $logs = array();
-    $query = db_query_range("SELECT message, variables FROM {watchdog} WHERE type = 'mollom' AND severity <= %d ORDER BY wid DESC", WATCHDOG_WARNING, 0, 10);
-    while ($log = db_fetch_object($query)) {
-      $logs[] = t($log->message, unserialize($log->variables));
+    $result = db_query_range('SELECT message, variables FROM {watchdog} WHERE type = :type AND severity <= :severity ORDER BY wid DESC', 0, 10, array(':type' => 'mollom', ':severity' => WATCHDOG_WARNING));
+    foreach ($result as $log) {
+      $t_args = unserialize($log->variables);
+      $logs[] = t($log->message, ($t_args ? $t_args : array()));
     }
     $form['watchdog'] = array(
       '#type' => 'item',
       '#title' => t('Recent Mollom messages'),
-      '#value' => $logs ? theme('item_list', $logs) : t('None'),
+      '#markup' => $logs ? theme('item_list', array('items' => $logs)) : t('None'),
     );
   }
-  return drupal_render($form);
+  return $form;
 }
 
Index: mollom.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/Attic/mollom.inc,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 mollom.inc
--- mollom.inc	17 Nov 2009 17:01:49 -0000	1.1.2.2
+++ mollom.inc	19 Dec 2009 21:51:27 -0000
@@ -31,7 +31,7 @@ function _mollom_authentication() {
   $private_key = variable_get('mollom_private_key', '');
 
   // Generate a timestamp according to the dateTime format (http://www.w3.org/TR/xmlschema-2/#dateTime):
-  $time = gmdate("Y-m-d\TH:i:s.\\0\\0\\0O", time());
+  $time = gmdate("Y-m-d\TH:i:s.\\0\\0\\0O", REQUEST_TIME);
 
   // Generate a random number:
   $nonce = md5(mt_rand());
Index: mollom.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.info,v
retrieving revision 1.2.2.2
diff -u -p -r1.2.2.2 mollom.info
--- mollom.info	17 Nov 2009 17:01:49 -0000	1.2.2.2
+++ mollom.info	17 Dec 2009 17:42:34 -0000
@@ -1,4 +1,9 @@
 ; $Id: mollom.info,v 1.2.2.2 2009/11/17 17:01:49 dries Exp $
 name = Mollom
 description = Protects forms against spam.
-core = 6.x
+core = 7.x
+files[] = mollom.module
+files[] = mollom.admin.inc
+files[] = mollom.pages.inc
+files[] = mollom.install
+files[] = tests/mollom.test
Index: mollom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v
retrieving revision 1.2.2.14
diff -u -p -r1.2.2.14 mollom.install
--- mollom.install	7 Dec 2009 00:09:59 -0000	1.2.2.14
+++ mollom.install	19 Dec 2009 21:28:23 -0000
@@ -7,7 +7,7 @@
  */
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function mollom_schema() {
   $schema['mollom'] = array(
@@ -78,7 +78,9 @@ function mollom_schema() {
         'default' => 0,
       ),
       'fields' => array(
+        'description' => 'The module name the $form_id belongs to.',
         'type' => 'text',
+        'not null' => FALSE,
         'serialize' => TRUE,
       ),
       'module' => array(
@@ -99,11 +101,9 @@ function mollom_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function mollom_install() {
-  drupal_install_schema('mollom');
-
   // Install default form configuration for enabled, supported modules.
   foreach (module_list(FALSE, FALSE) as $module) {
     drupal_load('module', $module);
@@ -111,12 +111,14 @@ function mollom_install() {
   drupal_load('module', 'mollom');
 
   $form_info = mollom_get_form_info();
+  $query = db_insert('mollom_form')
+    ->fields(array('form_id', 'mode', 'fields', 'module'));
   foreach ($form_info as $form_id => $info) {
     if (!empty($info['mode'])) {
       $info['fields'] = array_keys($info['elements']);
       // Upon installation, our own schema is not available yet, so we cannot
       // use mollom_form_save(), resp. drupal_write_record().
-      db_query("INSERT INTO {mollom_form} (form_id, mode, fields, module) VALUES ('%s', %d, '%s', '%s')", array(
+      $query->values(array(
         $info['form_id'],
         $info['mode'],
         serialize($info['fields']),
@@ -124,33 +126,29 @@ function mollom_install() {
       ));
     }
   }
+  $query->execute();
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function mollom_uninstall() {
-  db_query("DELETE FROM {variable} WHERE name LIKE 'mollom_%'");
-  drupal_uninstall_schema('mollom');
+  db_delete('variable')->condition('name', 'mollom_%', 'LIKE')->execute();
 }
 
 /**
  * An update function to add the language field.
  */
 function mollom_update_1() {
-  $ret = array();
-  db_add_field($ret, 'mollom', 'languages', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
-  return $ret;
+  db_add_field('mollom', 'languages', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
 }
 
 /**
  * Create the cache_mollom table.
  */
 function mollom_update_2() {
-  $ret = array();
   $schema = drupal_get_schema_unprocessed('system', 'cache');
-  db_create_table($ret, 'cache_mollom', $schema);
-  return $ret;
+  db_create_table('cache_mollom', $schema);
 }
 
 /**
@@ -172,23 +170,22 @@ function mollom_update_3() {
       variable_set($name, MOLLOM_MODE_ANALYSIS);
     }
   }
-  return array(array('success' => TRUE, 'query' => 'Updated Mollom form protection settings.'));
 }
 
 /**
  * Add a reputation field to the mollom table.
  */
 function mollom_update_4() {
-  $ret = array();
-  db_add_field($ret, 'mollom', 'reputation', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
-  return $ret;
+  db_add_field('mollom', 'reputation', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
 }
 
 /**
  * Add the {mollom_form} table.
  */
 function mollom_update_6105() {
-  $ret = array();
+  if (db_table_exists('mollom_form')) {
+    return;
+  }
   $schema = array(
     'fields' => array(
       'form_id' => array(
@@ -218,7 +215,7 @@ function mollom_update_6105() {
     ),
     'primary key' => array('form_id'),
   );
-  db_create_table($ret, 'mollom_form', $schema);
+  db_create_table('mollom_form', $schema);
 
   // Migrate form configuration for enabled, supported modules.
   foreach (module_list(FALSE, FALSE) as $module) {
@@ -228,7 +225,7 @@ function mollom_update_6105() {
 
   $form_info = mollom_get_form_info();
   $result = db_query("SELECT name, value FROM {variable} WHERE name LIKE 'mollom_%%' AND name NOT IN ('mollom_servers', 'mollom_fallback', 'mollom_public_key', 'mollom_private_key')");
-  while ($row = db_fetch_object($result)) {
+  foreach ($result as $row) {
     $form_id = substr($row->name, 7);
     $mode = unserialize($row->value);
     if (!empty($mode) && isset($form_info[$form_id])) {
@@ -239,7 +236,6 @@ function mollom_update_6105() {
     }
     variable_del($row->name);
   }
-  return $ret;
 }
 
 /**
@@ -249,9 +245,11 @@ function mollom_update_6105() {
  *   been removed.
  */
 function mollom_update_6106() {
-  $ret = array();
+  if (db_column_exists('mollom', 'entity')) {
+    return;
+  }
   // Add the 'entity' column.
-  db_add_field($ret, 'mollom', 'entity', array(
+  db_add_field('mollom', 'entity', array(
     'description' => 'The entity type of the content.',
     'type' => 'varchar',
     'length' => 32,
@@ -260,16 +258,28 @@ function mollom_update_6106() {
   ));
 
   // Migrate existing node data.
-  $ret[] = update_sql("UPDATE {mollom} SET entity = 'node' WHERE did LIKE 'node-%'");
-  $ret[] = update_sql("UPDATE {mollom} SET did = SUBSTR(did, 6) WHERE entity = 'node'");
+  db_update('mollom')
+    ->fields(array('entity' => 'node'))
+    ->condition('did', 'node-%', 'LIKE')
+    ->execute();
+  db_update('mollom')
+    ->fields(array('did' => 'SUBSTR(did, 6)')) // @todo Expressions in UPDATE?
+    ->condition('entity', 'node')
+    ->execute();
   // Migrate existing comment data.
-  $ret[] = update_sql("UPDATE {mollom} SET entity = 'comment' WHERE did LIKE 'comment-%'");
-  $ret[] = update_sql("UPDATE {mollom} SET did = SUBSTR(did, 9) WHERE entity = 'comment'");
+  db_update('mollom')
+    ->fields(array('entity' => 'comment'))
+    ->condition('did', 'comment-%', 'LIKE')
+    ->execute();
+  db_update('mollom')
+    ->fields(array('did' => 'SUBSTR(did, 9)')) // @todo Expressions in UPDATE?
+    ->condition('entity', 'comment')
+    ->execute();
 
   // Decrease the size of the 'did' column.
   // @todo We do not change the type to 'int' here to still support named
   //   identifiers. Reconsider this.
-  db_change_field($ret, 'mollom', 'did', 'did', array(
+  db_change_field('mollom', 'did', 'did', array(
     'description' => 'Unique data ID of the content.',
     'type' => 'varchar',
     'length' => 32,
@@ -277,8 +287,28 @@ function mollom_update_6106() {
     'default' => '',
   ));
 
-  db_drop_primary_key($ret, 'mollom');
-  db_add_primary_key($ret, 'mollom', array('entity', 'did'));
-  return $ret;
+  db_drop_primary_key('mollom');
+  db_add_primary_key('mollom', array('entity', 'did'));
+}
+
+/**
+ * Migrate form configuration for changed form ids in Drupal 7.
+ */
+function mollom_update_7000() {
+  // 'user_register' became 'user_register_form'.
+  db_update('mollom_form')
+    ->fields(array('form_id' => 'user_register_form'))
+    ->condition('form_id', 'user_register')
+    ->execute();
+  // 'contact_mail_page' became 'contact_site_form'.
+  db_update('mollom_form')
+    ->fields(array('form_id' => 'contact_site_form'))
+    ->condition('form_id', 'contact_mail_page')
+    ->execute();
+  // 'contact_mail_user' became 'contact_personal_form'.
+  db_update('mollom_form')
+    ->fields(array('form_id' => 'contact_personal_form'))
+    ->condition('form_id', 'contact_mail_user')
+    ->execute();
 }
 
Index: mollom.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.js,v
retrieving revision 1.2.2.7
diff -u -p -r1.2.2.7 mollom.js
--- mollom.js	17 Nov 2009 17:01:49 -0000	1.2.2.7
+++ mollom.js	17 Dec 2009 18:45:10 -0000
@@ -1,12 +1,16 @@
 // $Id: mollom.js,v 1.2.2.7 2009/11/17 17:01:49 dries Exp $
 
+(function ($) {
+
 /**
  * Attach click event handlers for CAPTCHA links.
  */
-Drupal.behaviors.mollom = function(context) {
-  $('a.mollom-audio-captcha', context).click(getAudioCaptcha);
-  $('a.mollom-image-captcha', context).click(getImageCaptcha);
-}
+Drupal.behaviors.mollom = {
+  attach: function (context) {
+    $('a.mollom-audio-captcha', context).click(getAudioCaptcha);
+    $('a.mollom-image-captcha', context).click(getImageCaptcha);
+  }
+};
 
 function getAudioCaptcha() {
   var context = $(this).parents('.form-item').parent();
@@ -45,3 +49,5 @@ function getImageCaptcha() {
    });
    return false;
 }
+
+})(jQuery);
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2.2.106
diff -u -p -r1.2.2.106 mollom.module
--- mollom.module	14 Dec 2009 12:47:16 -0000	1.2.2.106
+++ mollom.module	19 Dec 2009 21:51:45 -0000
@@ -92,9 +92,9 @@ define('MOLLOM_REDIRECT', 1200);
  * Implements hook_help().
  */
 function mollom_help($path, $arg) {
-  if ($path == 'admin/settings/mollom') {
+  if ($path == 'admin/config/content/mollom') {
     return t('All listed forms below are protected by Mollom. You can <a href="@add-form-url">add a form</a> to protect, configure already protected forms, or remove the protection.', array(
-      '@add-form-url' => url('admin/settings/mollom/add'),
+      '@add-form-url' => url('admin/config/content/mollom/add'),
     ));
   }
   if ($path == 'admin/help#mollom') {
@@ -125,28 +125,22 @@ function mollom_help($path, $arg) {
 }
 
 /**
- * Implements hook_link().
+ * Implements hook_init().
  */
-function mollom_link($type, $object, $teaser = FALSE) {
-  $links = array();
-
-  // Only show the links if the module is configured.
-  if (_mollom_access()) {
-    if ($type == 'comment' && user_access('administer comments') && mollom_get_mode('comment_form')) {
-      $links['mollom_report'] = array(
-        'title' => t('report to Mollom'),
-        'href' => 'mollom/report/comment/' . $object->cid,
-      );
-    }
-    elseif ($type == 'node' && user_access('administer nodes') && mollom_get_mode($object->type . '_node_form')) {
-      $links['mollom_report'] = array(
-        'title' => t('report to Mollom'),
-        'href' => 'mollom/report/node/' . $object->nid,
-      );
+function mollom_init() {
+  // Expire all mollom session IDs as soon as possible.
+  $now = REQUEST_TIME;
+  if (isset($_SESSION['mollom_sessions'])) {
+    foreach ($_SESSION['mollom_sessions'] as $id => $timestamp) {
+      if ($now - $timestamp > 30 * 60) {
+        unset($_SESSION['mollom_sessions'][$id]);
+      }
     }
   }
-
-  return $links;
+  // If all sessions were removed, also remove our storage key.
+  if (isset($_SESSION) && empty($_SESSION['mollom_sessions'])) {
+    unset($_SESSION['mollom_sessions']);
+  }
 }
 
 /**
@@ -163,42 +157,42 @@ function mollom_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['admin/settings/mollom'] = array(
+  $items['admin/config/content/mollom'] = array(
     'title' => 'Mollom',
     'description' => 'Mollom is a web service that helps you manage your community.',
     'page callback' => 'mollom_admin_form_list',
     'access arguments' => array('administer mollom'),
     'file' => 'mollom.admin.inc',
   );
-  $items['admin/settings/mollom/list'] = array(
+  $items['admin/config/content/mollom/list'] = array(
     'title' => 'List',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
-  $items['admin/settings/mollom/add'] = array(
+  $items['admin/config/content/mollom/add'] = array(
     'title' => 'Add form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('mollom_admin_configure_form'),
     'access arguments' => array('administer mollom'),
-    'type' => MENU_LOCAL_TASK,
+    'type' => MENU_LOCAL_ACTION,
     'file' => 'mollom.admin.inc',
   );
-  $items['admin/settings/mollom/manage/%mollom_form'] = array(
+  $items['admin/config/content/mollom/manage/%mollom_form'] = array(
     'title' => 'Configure',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('mollom_admin_configure_form', 4),
+    'page arguments' => array('mollom_admin_configure_form', 5),
     'access arguments' => array('administer mollom'),
     'file' => 'mollom.admin.inc',
   );
-  $items['admin/settings/mollom/unprotect/%mollom_form'] = array(
+  $items['admin/config/content/mollom/unprotect/%mollom_form'] = array(
     'title' => 'Unprotect form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('mollom_admin_unprotect_form', 4),
+    'page arguments' => array('mollom_admin_unprotect_form', 5),
     'access arguments' => array('administer mollom'),
     'type' => MENU_CALLBACK,
     'file' => 'mollom.admin.inc',
   );
-  $items['admin/settings/mollom/settings'] = array(
+  $items['admin/config/content/mollom/settings'] = array(
     'title' => 'Settings',
     'description' => 'Configure Mollom keys and global settings.',
     'page callback' => 'drupal_get_form',
@@ -211,9 +205,10 @@ function mollom_menu() {
   $items['admin/reports/mollom'] = array(
     'title' => 'Mollom statistics',
     'description' => 'Reports and usage statistics for the Mollom module.',
-    'page callback' => 'mollom_reports_page',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('mollom_reports_page'),
     'access callback' => '_mollom_access',
-    'access arguments' => array('administer mollom'),
+    'access arguments' => array('access mollom reports'),
     'file' => 'mollom.admin.inc',
   );
 
@@ -288,12 +283,19 @@ function mollom_report_access($entity, $
 }
 
 /**
- * Implements hook_perm().
+ * Implements hook_permission().
  */
-function mollom_perm() {
+function mollom_permission() {
   return array(
-    'administer mollom',
-    'post with no checking',
+    'administer mollom' => array(
+      'title' => t('Administer Mollom-protected forms and Mollom settings'),
+    ),
+    'access mollom reports' => array(
+      'title' => t('Access Mollom reports'),
+    ),
+    'post with no checking' => array(
+      'title' => t('Post content without checking'),
+    ),
   );
 }
 
@@ -313,7 +315,7 @@ function mollom_flush_caches() {
  *   The entity id to retrieve data for.
  */
 function mollom_data_load($entity, $id) {
-  return db_fetch_object(db_query_range("SELECT * FROM {mollom} WHERE entity = '%s' AND did = '%s'", array($entity, $id), 0, 1));
+  return db_query_range('SELECT * FROM {mollom} WHERE entity = :entity AND did = :did', 0, 1, array(':entity' => $entity, ':did' => $id))->fetchObject();
 }
 
 /**
@@ -357,7 +359,7 @@ function mollom_data_save($entity, $id) 
     'reputation' => '',
   );
 
-  $update = db_result(db_query_range("SELECT 'did' FROM {mollom} WHERE entity = '%s' AND did = '%s'", $entity, $id, 0, 1));
+  $update = db_query_range("SELECT 'did' FROM {mollom} WHERE entity = :entity AND did = :did", 0, 1, array(':entity' => $entity, ':did' => $id))->fetchField();
   drupal_write_record('mollom', $data, $update ? $update : array());
   return $data;
 }
@@ -371,7 +373,7 @@ function mollom_data_save($entity, $id) 
  *   The entity id to retrieve data for.
  */
 function mollom_data_delete($entity, $id) {
-  return db_query("DELETE FROM {mollom} WHERE entity = '%s' AND did = '%s'", array($entity, $id));
+  return db_delete('mollom')->condition('entity', $entity)->condition('did', $id)->execute();
 }
 
 /**
@@ -498,9 +500,13 @@ function mollom_get_form_info($form_id =
  * Menu argument loader; Loads Mollom configuration and form information for a given form id.
  */
 function mollom_form_load($form_id) {
-  $mollom_form = db_fetch_array(db_query_range("SELECT * FROM {mollom_form} WHERE form_id = '%s'", $form_id, 0, 1));
+  $mollom_form = db_query_range('SELECT * FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $form_id))->fetchAssoc();
   if ($mollom_form) {
     $mollom_form['fields'] = unserialize($mollom_form['fields']);
+    // @todo Is this a bug in D7?
+    if (!$mollom_form['fields']) {
+      $mollom_form['fields'] = array();
+    }
 
     // Attach form registry information.
     $mollom_form += mollom_get_form_info($form_id);
@@ -519,7 +525,7 @@ function mollom_form_load($form_id) {
  * Saves a Mollom form configuration.
  */
 function mollom_form_save(&$mollom_form) {
-  $exists = db_result(db_query_range("SELECT 1 FROM {mollom_form} WHERE form_id = '%s'", $mollom_form['form_id'], 0, 1));
+  $exists = db_query_range('SELECT 1 FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $mollom_form['form_id']))->fetchField();
   if ($exists) {
     $status = drupal_write_record('mollom_form', $mollom_form, 'form_id');
   }
@@ -654,7 +660,7 @@ function mollom_form_get_values($form_va
   if (!empty($mapping['author_name'])) {
     $data['author_name'] = $mapping['author_name'];
     // Try to inherit user from author name.
-    $account = user_load(array('name' => $data['author_name']));
+    $account = user_load_by_name($data['author_name']);
   }
   elseif (!empty($user->name)) {
     $data['author_name'] = $user->name;
@@ -715,14 +721,9 @@ function mollom_form_get_values($form_va
  */
 function _mollom_get_openid($account) {
   if (isset($account->uid)) {
-    $result = db_query("SELECT * FROM {authmap} WHERE module = 'openid' AND uid = %d", $account->uid);
-
-    $ids = array();
-    while ($identity = db_fetch_object($result)) {
-      $ids[] = $identity->authname;
-    }
+    $ids = db_query('SELECT authname FROM {authmap} WHERE module = :module AND uid = :uid', array(':module' => 'openid', ':uid' => $account->uid))->fetchCol();
 
-    if (count($ids)) {
+    if (!empty($ids)) {
       return implode($ids, ' ');
     }
   }
@@ -798,12 +799,11 @@ function _mollom_fallback() {
  */
 
 /**
- * Implements hook_elements().
+ * Implements hook_element_info().
  */
-function mollom_elements() {
+function mollom_element_info() {
   return array(
     'mollom' => array(
-      '#input' => TRUE,
       '#process' => array(
         // Try to fetch a Mollom session from cache during form processing/validation.
         'mollom_process_mollom_session_id',
@@ -821,7 +821,7 @@ function mollom_elements() {
 function mollom_theme() {
   return array(
     'mollom' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
   );
 }
@@ -836,7 +836,8 @@ function mollom_theme() {
  *
  * @todo Remove in D7; also #input from mollom_elements().
  */
-function theme_mollom($element) {
+function theme_mollom($variables) {
+  $element = $variables['element'];
   return isset($element['#children']) ? $element['#children'] : '';
 }
 
@@ -850,7 +851,7 @@ function theme_mollom($element) {
  * only. We expire it as soon as the form is submitted, to avoid it being
  * replayed.
  */
-function mollom_process_mollom($element, $input, &$form_state, $complete_form) {
+function mollom_process_mollom($element, &$form_state, $complete_form) {
   $element['#tree'] = TRUE;
 
   // Setup initial Mollom session and form information.
@@ -862,7 +863,6 @@ function mollom_process_mollom($element,
       'require_analysis' => $element['#mollom_form']['mode'] == MOLLOM_MODE_ANALYSIS,
       'require_captcha' => $element['#mollom_form']['mode'] == MOLLOM_MODE_CAPTCHA,
       'passed_captcha' => FALSE,
-      'user_session_id' => session_id(),
       'fields' => $element['#mollom_form']['fields'],
       'mapping' => $element['#mollom_form']['mapping'],
     );
@@ -879,8 +879,6 @@ function mollom_process_mollom($element,
   $element['captcha'] = array(
     '#type' => 'textfield',
     '#title' => t('Word verification'),
-    // @todo Or simply move into #pre_render, 'cause this is cosmetical only.
-    '#required' => $form_state['mollom']['require_captcha'],
     '#size' => 10,
     '#default_value' => '',
     '#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. Not case sensitive."),
@@ -912,18 +910,21 @@ function mollom_process_mollom($element,
  * @todo Investigate usage of $form_state['storage']['mollom'], but watch out
  *   for broken form state caching.
  */
-function mollom_process_mollom_session_id($element, $input, &$form_state) {
+function mollom_process_mollom_session_id($element, &$form_state) {
   // The current state can come either from the $form_state, if the form
   // was just rebuilt in the same request or from data posted by the user. In
   // that case we validate that the correct form_id and user session ID is used.
-  if (empty($form_state['mollom']) && !empty($input['session_id'])) {
-    list($timestamp, $mollom_session_id) = explode('-', $input['session_id'], 2);
+  if (empty($form_state['mollom']) && !empty($form_state['input']['mollom']['session_id'])) {
+    list($timestamp, $mollom_session_id) = explode('-', $form_state['input']['mollom']['session_id'], 2);
 
     if (!$mollom_session_id) {
-      watchdog('mollom', "Mollom ID '%session' is badly formatted.", array('%session' => $input['session_id']));
+      watchdog('mollom', "Mollom ID '%session' is badly formatted.", array('%session' => $form_state['input']['mollom']['session_id']));
+    }
+    elseif (!isset($_SESSION['mollom_sessions'][$mollom_session_id])) {
+      watchdog('mollom', "Mollom ID '%session' not found in the current user session.", array('%session' => $mollom_session_id));
     }
     elseif (!$cache = cache_get($mollom_session_id, 'cache_mollom')) {
-      if (time() - $timestamp > 30 * 60) {
+      if (REQUEST_TIME - $timestamp > 30 * 60) {
         watchdog('mollom', "Mollom ID '%session' is invalid, probably expired.", array('%session' => $mollom_session_id));
       }
       else {
@@ -933,9 +934,6 @@ function mollom_process_mollom_session_i
     elseif ($cache->data['form_id'] !== $form_state['values']['form_id']) {
       watchdog('mollom', "Mollom ID '%session' has been tampered with: it was generated for form %form1, but is used on form %form2.", array('%session' => $mollom_session_id, '%form1' => $cache->data['form_id'], '%form2' => $form_state['values']['form_id']));
     }
-    elseif ($cache->data['user_session_id'] !== session_id()) {
-      watchdog('mollom', "Mollom ID '%session' has been tampered with: it was generated for a user with Drupal session ID %sid1, but is used by a user with Drupal session ID %sid2.", array('%session' => $mollom_session_id, '%sid1' => $cache->data['user_session_id'], '%sid2' => session_id()));
-    }
     else {
       $form_state['mollom'] = $cache->data;
     }
@@ -994,11 +992,22 @@ function mollom_validate_analysis($form,
 /**
  * Form validation handler for CAPTCHA form element.
  */
-function mollom_validate_captcha($element, &$form_state) {
+function mollom_validate_captcha(&$form, &$form_state) {
   if (!$form_state['mollom']['require_captcha'] || $form_state['mollom']['passed_captcha']) {
     return;
   }
 
+  // @todo Problem: This error is output also in case we have no valid keys or a
+  //   communication error, in this request or perhaps even in the last already.
+  //   Thus, in case the fallback method blocks all submissions, a user gets TWO
+  //   error messages, and one of them being totally nuts, because *there is no*
+  //   CAPTCHA in the form, because we didn't reach the servers in the first
+  //   place. However, we also do not really want to invoke lots of XML-RPC
+  //   requests for the case when we (could) *know* that we won't get a usable
+  //   $result, because the servers are empty or keys are invalid - unless the
+  //   site administrator revisits Mollom's settings page again and fixes the
+  //   keys/servers.
+
   // Bail out if no value was provided.
   if (empty($form_state['values']['mollom']['captcha'])) {
     form_set_error('mollom][captcha', t('The CAPTCHA field is required.'));
@@ -1012,6 +1021,12 @@ function mollom_validate_captcha($elemen
     'author_ip' => ip_address(),
   ));
 
+  // Cancel validation if we have communication issues.
+  // @todo These should really be bitwise OR'ed error code constants...
+//  if ($result == NETWORK_ERROR || $result == MOLLOM_ERROR) {
+//    return;
+//  }
+
   // Explictly check for TRUE, since mollom.checkCaptcha() can also return an
   // error message (e.g. expired or invalid session_id).
   if ($result === TRUE) {
@@ -1057,6 +1072,13 @@ function mollom_pre_render_mollom($eleme
     if (!empty($element['#mollom']['session_id'])) {
       $data['session_id'] = $element['#mollom']['session_id'];
     }
+    // @todo D7: A horrible effect of the new rendering system: If we cannot
+    //   reach Mollom servers, then mollom() will invoke _mollom_fallback(),
+    //   which outputs a message. However, this is #pre_render. The main page
+    //   content is render()'ed *within* page.tpl.php. Which is also where
+    //   $messages are rendered. But $messages are rendered before $content!
+    //   I already briefly discussed this chicken-n-egg problem with moshe, but
+    //   as of now, we have no ideas. 19/12/2009 sun
     $result = mollom('mollom.getImageCaptcha', $data);
 
     // If we get a response, add the image CAPTCHA to the form element.
@@ -1070,26 +1092,36 @@ function mollom_pre_render_mollom($eleme
       // Assign the session ID returned by Mollom.
       $element['#mollom']['session_id'] = $result['session_id'];
     }
-    // Otherwise, hide the CAPTCHA if there was a communication error.
-    elseif ($result === NETWORK_ERROR) {
+    // Otherwise, hide the CAPTCHA.
+    else {
       $element['captcha']['#type'] = 'hidden';
+      unset($element['captcha']['#theme'], $element['captcha']['#theme_wrappers']);
     }
   }
 
   // If we received a Mollom session id via textual analysis or a CAPTCHA
   // request, inject it to the form.
+  $timestamp = REQUEST_TIME;
   if (!empty($element['#mollom']['session_id'])) {
-    $element['session_id']['#value'] = time() . '-' . $element['#mollom']['session_id'];
+    $element['session_id']['#value'] = $timestamp . '-' . $element['#mollom']['session_id'];
+
+    // Store the Mollom session id in the user session to force a
+    // session for anonymous users in Drupal 7 and Drupal 6 Pressflow.
+    // @see mollom_init()
+    // @see mollom_form_submit()
+    $_SESSION['mollom_sessions'][$element['#mollom']['session_id']] = $timestamp;
   }
 
   // If no CAPTCHA is required or the response was correct, hide the CAPTCHA.
   if (!$element['#mollom']['require_captcha'] || $element['#mollom']['passed_captcha']) {
     $element['captcha']['#type'] = 'hidden';
+    unset($element['captcha']['#theme'], $element['captcha']['#theme_wrappers']);
   }
   // Otherwise, empty the value of the CAPTCHA, since the user has to re-enter
   // a new one.
   else {
     $element['captcha']['#value'] = '';
+    $element['captcha']['#required'] = $element['#mollom']['require_captcha'];
   }
 
   // Due to a bug in Drupal core, we need to manually update Mollom session
@@ -1101,7 +1133,7 @@ function mollom_pre_render_mollom($eleme
   // along with form caching. >:-/
   // @see http://drupal.org/node/644222
   if (!empty($element['#mollom']['session_id'])) {
-    cache_set($element['#mollom']['session_id'], $element['#mollom'], 'cache_mollom', time() + 21600);
+    cache_set($element['#mollom']['session_id'], $element['#mollom'], 'cache_mollom', REQUEST_TIME + 21600);
   }
 
   return $element;
@@ -1114,9 +1146,11 @@ function mollom_pre_render_mollom($eleme
  *   'post_id' mapping.
  */
 function mollom_form_submit($form_id, &$form_state) {
-  // Flush Mollom session information from form state cache.
+  // Flush Mollom session information from database cache and user session.
   if (!empty($form_state['values']['mollom']['session_id'])) {
-    cache_clear_all($form_state['values']['mollom']['session_id'], 'cache_mollom');
+    $session_id = $form_state['values']['mollom']['session_id'];
+    cache_clear_all($session_id, 'cache_mollom');
+    unset($_SESSION['mollom_sessions'][$session_id]);
   }
   // Remove Mollom session information from form state to account for unforeseen
   // new builds of the form.
@@ -1271,7 +1305,7 @@ function mollom_get_statistics($refresh 
   $cache = cache_get('mollom:statistics');
 
   // Only fetch if $refresh is TRUE, the cache is empty, or the cache is expired.
-  if ($refresh || !$cache || time() >= $cache->expire) {
+  if ($refresh || !$cache || REQUEST_TIME >= $cache->expire) {
     if (_mollom_access()) {
       $statistics = drupal_map_assoc(array(
         'total_days',
@@ -1300,7 +1334,7 @@ function mollom_get_statistics($refresh 
     }
 
     // Cache the statistics and set them to expire in one hour.
-    cache_set('mollom:statistics', $statistics, 'cache', time() + 3600);
+    cache_set('mollom:statistics', $statistics, 'cache', REQUEST_TIME + 3600);
   }
   else {
     $statistics = $cache->data;
@@ -1318,7 +1352,7 @@ function mollom_get_statistics($refresh 
  * Implements hook_mollom_form_info().
  */
 function node_mollom_form_info() {
-  $types = node_get_types('types');
+  $types = node_type_get_types('types');
   $forms = array();
   foreach ($types as $type) {
     $form_id = $type->type . '_node_form';
@@ -1362,15 +1396,17 @@ function node_mollom_form_info() {
 }
 
 /**
- * Implements hook_nodeapi().
+ * Implements hook_node_insert().
  */
-function mollom_nodeapi($node, $op) {
-  if ($op == 'insert') {
-    mollom_data_save('node', $node->nid);
-  }
-  elseif ($op == 'delete') {
-    mollom_data_delete('node', $node->nid);
-  }
+function mollom_node_insert($node) {
+  mollom_data_save('node', $node->nid);
+}
+
+/**
+ * Implements hook_node_delete().
+ */
+function mollom_node_delete($node) {
+  mollom_data_delete('node', $node->nid);
 }
 
 /**
@@ -1389,6 +1425,26 @@ function mollom_form_node_admin_content_
 }
 
 /**
+ * Implements hook_node_view().
+ */
+function mollom_node_view($node, $build_mode) {
+  // Only show the links if the module is configured.
+  if (_mollom_access() && user_access('administer nodes') && mollom_get_mode($node->type . '_node_form')) {
+    $node->content['links']['mollom'] = array(
+      '#theme' => 'links',
+      '#links' => array(
+        'mollom_report' => array(
+          'title' => t('report to Mollom'),
+          'href' => 'mollom/report/node/' . $node->nid,
+          'query' => drupal_get_destination(),
+        ),
+      ),
+      '#attributes' => array('class' => array('links', 'inline')),
+    );
+  }
+}
+
+/**
  * Mollom report access callback; Determine access to report and delete a node.
  */
 function node_mollom_report_access($entity, $id) {
@@ -1442,61 +1498,17 @@ function comment_mollom_form_info() {
 }
 
 /**
- * Implements hook_form_FORMID_alter().
- *
- * When a registered user posts a comment or when a comment administrator edits
- * an existing comment, comment_form() does not define 'name' and 'mail' form
- * elements, so our form element mapping will fail.
- *
- * @see comment_mollom_form_info()
- * @see mollom_comment_form_validate()
- *
- * @todo Remove in D7.
- */
-function mollom_form_comment_form_alter(&$form, &$form_state) {
-  if (isset($form['author']) || isset($form['admin']['author'])) {
-    $form['#validate'][] = 'mollom_comment_form_validate';
-  }
-}
-
-/**
- * Form validation handler for comment_form().
- *
- * @todo Remove in D7.
+ * Implements hook_comment_insert().
  */
-function mollom_comment_form_validate($form, &$form_state) {
-  // If there were no validation errors, prepare submitted form values for
-  // validation via Mollom.
-  if (!form_get_errors()) {
-    // Author is a registered user or comment is edited by administrator.
-    if (isset($form_state['values']['author'])) {
-      // Populate 'name' with value of 'author'.
-      if (!isset($form_state['values']['name'])) {
-        form_set_value(array('#parents' => array('name')), $form_state['values']['author'], $form_state);
-      }
-      // Populate 'mail' based on corresponding user account.
-      if (!isset($form_state['values']['mail'])) {
-        // This should already be validated by comment_validate(), but we still
-        // double-check that we have a valid account before trying to access it.
-        $account = user_load(array('name' => $form_state['values']['author']));
-        if ($account) {
-          form_set_value(array('#parents' => array('mail')), $account->mail, $form_state);
-        }
-      }
-    }
-  }
+function mollom_comment_insert($comment) {
+  mollom_data_save('comment', $comment->cid);
 }
 
 /**
- * Implements hook_comment().
+ * Implements hook_comment_delete().
  */
-function mollom_comment($comment, $op) {
-  if ($op == 'insert') {
-    mollom_data_save('comment', $comment['cid']);
-  }
-  elseif ($op == 'delete') {
-    mollom_data_delete('comment', $comment->cid);
-  }
+function mollom_comment_delete($comment) {
+  mollom_data_delete('comment', $comment->cid);
 }
 
 /**
@@ -1515,16 +1527,38 @@ function mollom_form_comment_admin_overv
 }
 
 /**
+ * Implements hook_comment_view().
+ */
+function mollom_comment_view($comment, $build_mode) {
+  // Only show the links if the module is configured.
+  if (_mollom_access() && user_access('administer comments') && mollom_get_mode('comment_form')) {
+    $comment->content['links']['mollom'] = array(
+      '#theme' => 'links',
+      '#links' => array(
+        'mollom_report' => array(
+          'title' => t('report to Mollom'),
+          'href' => 'mollom/report/comment/' . $comment->cid,
+          'query' => drupal_get_destination(),
+        ),
+      ),
+      '#attributes' => array('class' => array('links', 'inline')),
+    );
+  }
+}
+
+/**
  * Mollom report delete callback; Deletes a comment and its replies.
+ *
+ * @see comment_confirm_delete_submit()
  */
 function comment_mollom_report_delete($entity, $id) {
-  module_load_include('inc', 'comment', 'comment.admin');
-  $comment = _comment_load($id);
-  _comment_delete_thread($comment);
-  _comment_update_node_statistics($comment->nid);
+  $comment = comment_load($id);
+  // Delete the comment and its replies.
+  comment_delete($comment->cid);
+  drupal_set_message(t('The comment and all its replies have been deleted.'));
+  watchdog('content', t('Deleted comment @cid and its replies.', array('@cid' => $comment->cid)));
+  // Clear the cache so an anonymous user sees that his comment was deleted.
   cache_clear_all();
-
-  drupal_set_message(t('The comment has been deleted.'));
 }
 
 /**
@@ -1540,7 +1574,7 @@ function comment_mollom_report_delete($e
  * Implements hook_mollom_form_info().
  */
 function user_mollom_form_info() {
-  $forms['user_register'] = array(
+  $forms['user_register_form'] = array(
     'title' => t('User registration form'),
     'mode' => MOLLOM_MODE_CAPTCHA,
     'entity' => 'user',
@@ -1577,7 +1611,7 @@ function user_mollom_form_info() {
  * Implements hook_mollom_form_info().
  */
 function contact_mollom_form_info() {
-  $forms['contact_mail_page'] = array(
+  $forms['contact_site_form'] = array(
     'title' => t('Site-wide contact form'),
     'mode' => MOLLOM_MODE_ANALYSIS,
     'bypass access' => array('administer site-wide contact form'),
@@ -1591,7 +1625,7 @@ function contact_mollom_form_info() {
       'author_mail' => 'mail',
     ),
   );
-  $forms['contact_mail_user'] = array(
+  $forms['contact_personal_form'] = array(
     'title' => t('User contact form'),
     'mode' => MOLLOM_MODE_ANALYSIS,
     'bypass access' => array('administer users'),
Index: mollom.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/Attic/mollom.pages.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 mollom.pages.inc
--- mollom.pages.inc	12 Dec 2009 20:57:18 -0000	1.1.2.6
+++ mollom.pages.inc	19 Dec 2009 21:07:36 -0000
@@ -44,7 +44,7 @@ function mollom_captcha_js($type, $sessi
  *   which should only be used to report session data that was not stored for an
  *   entity in the database (such as contact form submissions).
  */
-function mollom_report_form(&$form_state, $entity, $id) {
+function mollom_report_form($form, &$form_state, $entity, $id) {
   $form['entity'] = array(
     '#type' => 'value',
     '#value' => $entity,
@@ -57,7 +57,7 @@ function mollom_report_form(&$form_state
 
   return confirm_form($form,
     t('Are you sure you want to delete and report the content as inappropriate?'),
-    isset($_GET['destination']) ? $_GET['destination'] : '<front>',
+    '<front>',
     t('This action cannot be undone.'),
     t('Delete'), t('Cancel')
   );
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/Attic/mollom.test,v
retrieving revision 1.1.2.23
diff -u -p -r1.1.2.23 mollom.test
--- tests/mollom.test	14 Dec 2009 12:47:16 -0000	1.1.2.23
+++ tests/mollom.test	19 Dec 2009 21:26:16 -0000
@@ -82,7 +82,7 @@ class MollomWebTestCase extends DrupalWe
     // Call parent::setUp() allowing Mollom test cases to pass further modules.
     $modules = func_get_args();
     $modules[] = 'mollom';
-    call_user_func_array(array('parent', 'setUp'), $modules);
+    call_user_func_array(array($this, 'parent::setUp'), $modules);
 
     $this->admin_user = $this->drupalCreateUser(array(
       'administer mollom',
@@ -123,9 +123,14 @@ class MollomWebTestCase extends DrupalWe
     }
     module_load_include('inc', 'dblog', 'dblog.admin');
 
-    $where = ($seen_ids ? 'AND wid NOT IN (' . db_placeholders($seen_ids) . ')' : '');
-    $result = db_query("SELECT * FROM {watchdog} WHERE type = 'mollom' $where ORDER BY timestamp ASC", $seen_ids);
-    while ($row = db_fetch_object($result)) {
+    $query = db_select('watchdog', 'w')
+      ->fields('w')
+      ->condition('w.type', 'mollom')
+      ->orderBy('w.timestamp', 'ASC');
+    if ($seen_ids) {
+      $query->condition('w.wid', $seen_ids, 'NOT IN');
+    }
+    foreach ($query->execute() as $row) {
       if ($no_fail_expected ? $row->severity >= WATCHDOG_NOTICE : $row->severity < WATCHDOG_NOTICE) {
         $this->pass(_dblog_format_message($row), t('Watchdog'));
       }
@@ -183,10 +188,10 @@ class MollomWebTestCase extends DrupalWe
    */
   protected function setProtection($form_id, $fields = NULL) {
     // Determine whether the form is already protected.
-    $exists = db_result(db_query_range("SELECT 1 FROM {mollom_form} WHERE form_id = '%s'", $form_id, 0, 1));
+    $exists = db_query_range('SELECT 1 FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $form_id));
     // Add a new form.
     if (!$exists) {
-      $this->drupalGet('admin/settings/mollom');
+      $this->drupalGet('admin/config/content/mollom');
       $this->clickLink(t('Add form'));
       $edit = array(
         'mollom[form_id]' => $form_id,
@@ -195,7 +200,7 @@ class MollomWebTestCase extends DrupalWe
     }
     // Edit an existing form.
     else {
-      $this->drupalGet('admin/settings/mollom/manage/' . $form_id);
+      $this->drupalGet('admin/config/content/mollom/manage/' . $form_id);
     }
 
     $edit = array();
@@ -237,9 +242,9 @@ class MollomWebTestCase extends DrupalWe
    */
   protected function delProtection($form_id) {
     // Determine whether the form is protected.
-    $exists = db_result(db_query_range("SELECT 1 FROM {mollom_form} WHERE form_id = '%s'", $form_id, 0, 1));
+    $exists = db_query_range('SELECT 1 FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $form_id));
     if ($exists) {
-      $this->drupalGet('admin/settings/mollom/unprotect/' . $form_id);
+      $this->drupalGet('admin/config/content/mollom/unprotect/' . $form_id);
       $this->assertText(t('Mollom will no longer protect this form from spam.'), t('Unprotect confirmation form found.'));
       $this->drupalPost(NULL, array(), t('Confirm'));
     }
@@ -451,7 +456,7 @@ class MollomAccessTestCase extends Mollo
   function testKeyPairs() {
     // Check that a success message is shown.
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('admin/settings/mollom/settings');
+    $this->drupalGet('admin/config/content/mollom/settings');
     $this->assertText(t('We contacted the Mollom servers to verify your keys: the Mollom services are operating correctly. We are now blocking spam.'));
 
     // Set up invalid test keys and check that an error message is shown.
@@ -475,7 +480,7 @@ class MollomAccessTestCase extends Mollo
     // site configuration' permission. This user should have access to
     // the Mollom settings page.
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('admin/settings/mollom');
+    $this->drupalGet('admin/config/content/mollom');
     $this->assertResponse(200);
 
     // Check access for a user that has everything except the 'administer
@@ -483,7 +488,7 @@ class MollomAccessTestCase extends Mollo
     // settings page.
     $this->web_user = $this->drupalCreateUser(array_diff(module_invoke_all('perm'), array('administer mollom')));
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('admin/settings/mollom');
+    $this->drupalGet('admin/config/content/mollom');
     $this->assertResponse(403);
   }
 
@@ -491,7 +496,7 @@ class MollomAccessTestCase extends Mollo
    * Tests 'bypass access' property of registered forms.
    */
   function testBypassAccess() {
-    $node = $this->drupalCreateNode(array('body' => 'node body', 'type' => 'story'));
+    $node = $this->drupalCreateNode(array('body' => array(LANGUAGE_NONE => array(array('value' => 'node body'))), 'type' => 'article'));
 
     // Create a regular user and post a comment.
     $this->web_user = $this->drupalCreateUser(array('post comments', 'post comments without approval'));
@@ -561,7 +566,7 @@ class MollomFallbackTestCase extends Mol
     $this->drupalLogin($this->admin_user);
     $this->setProtection('user_pass');
     // Set the fallback strategy to 'blocking mode'.
-    $this->drupalPost('admin/settings/mollom/settings', array('mollom_fallback' => MOLLOM_FALLBACK_BLOCK), t('Save configuration'));
+    $this->drupalPost('admin/config/content/mollom/settings', array('mollom_fallback' => MOLLOM_FALLBACK_BLOCK), t('Save configuration'));
     $this->assertText('The configuration options have been saved.');
     $this->drupalLogout();
     $this->assertMollomWatchdogMessages();
@@ -587,7 +592,7 @@ class MollomFallbackTestCase extends Mol
     $this->drupalLogin($this->admin_user);
     $this->setProtection('user_pass');
     // Set the fallback strategy to 'accept mode'.
-    $this->drupalPost('admin/settings/mollom/settings', array('mollom_fallback' => MOLLOM_FALLBACK_ACCEPT), t('Save configuration'));
+    $this->drupalPost('admin/config/content/mollom/settings', array('mollom_fallback' => MOLLOM_FALLBACK_ACCEPT), t('Save configuration'));
     $this->assertText('The configuration options have been saved.');
     $this->drupalLogout();
 
@@ -689,6 +694,9 @@ class MollomFormConfigurationTestCase ex
 
   function setUp() {
     parent::setUp('mollom_test');
+    // Re-route Mollom communication to this testing site.
+    variable_set('mollom_servers', array($GLOBALS['base_url'] . '/xmlrpc.php?version='));
+
     $this->drupalLogin($this->admin_user);
   }
 
@@ -697,7 +705,7 @@ class MollomFormConfigurationTestCase ex
    */
   function testFormFieldsConfiguration() {
     // Protect Mollom test form.
-    $this->drupalGet('admin/settings/mollom/add');
+    $this->drupalGet('admin/config/content/mollom/add');
     $edit = array(
       'mollom[form_id]' => 'mollom_test_form',
     );
@@ -719,7 +727,7 @@ class MollomFormConfigurationTestCase ex
     $this->assertTrue($mollom_form, t('Form configuration exists.'));
 
     // Verify that field configuration was properly stored.
-    $this->drupalGet('admin/settings/mollom/manage/mollom_test_form');
+    $this->drupalGet('admin/config/content/mollom/manage/mollom_test_form');
     foreach ($edit as $name => $value) {
       // assertFieldByName() does not work for checkboxes.
       // @see assertFieldChecked()
@@ -737,7 +745,7 @@ class MollomFormConfigurationTestCase ex
     mollom_form_save($mollom_form);
 
     // Verify that field configuration contains only available elements.
-    $this->drupalGet('admin/settings/mollom/manage/mollom_test_form');
+    $this->drupalGet('admin/config/content/mollom/manage/mollom_test_form');
     $form_info = mollom_get_form_info('mollom_test_form');
     $fields = $this->xpath('//input[starts-with(@name, "mollom[fields]")]');
     $elements = array();
@@ -749,12 +757,13 @@ class MollomFormConfigurationTestCase ex
     // Try a simple submit of the form.
     $this->drupalLogout();
     $edit = array(
-      'title' => 'spam',
+      'title' => 'unsure',
     );
     $this->drupalPost('mollom-test/form', $edit, 'Submit');
     $this->assertNoText('Successful form submission.');
     $this->assertText($this->unsure_message);
     $this->postCorrectCaptcha(NULL, array(), 'Submit', 'Successful form submission.');
+    $this->assertMollomWatchdogMessages();
 
     // Try to submit values for top-level fields.
     $edit = array(
@@ -765,16 +774,18 @@ class MollomFormConfigurationTestCase ex
     $this->assertNoText('Successful form submission.');
     $this->assertNoText($this->unsure_message);
     $this->assertText($this->spam_message);
+    $this->assertMollomWatchdogMessages();
 
     // Try to submit values for nested field.
     $edit = array(
-      'title' => 'ham',
+      'title' => $this->randomString(),
       'parent[child]' => 'spam',
     );
     $this->drupalPost('mollom-test/form', $edit, 'Submit');
     $this->assertNoText('Successful form submission.');
     $this->assertNoText($this->unsure_message);
     $this->assertText($this->spam_message);
+    $this->assertMollomWatchdogMessages();
 
     // Try to submit values for nested field and multiple value field.
     // Start with ham values for simple, nested, and first multiple field.
@@ -789,8 +800,9 @@ class MollomFormConfigurationTestCase ex
     $this->assertNoText('Successful form submission.');
     $this->assertNoText($this->unsure_message);
     $this->assertNoText($this->spam_message);
+    $this->assertMollomWatchdogMessages();
 
-    // Add another ham value for multiple field.
+    // Add another value for multiple field.
     $edit = array(
       'field[new]' => 'ham',
     );
@@ -800,9 +812,15 @@ class MollomFormConfigurationTestCase ex
     $this->assertNoText('Successful form submission.');
     $this->assertNoText($this->unsure_message);
     $this->assertNoText($this->spam_message);
+    $this->assertMollomWatchdogMessages();
 
-    // Now add a spam value to the multiple field and submit the form.
+    // Now replace all ham values with random values, add a spam value to the
+    // multiple field and submit the form.
     $edit = array(
+      'title' => $this->randomString(),
+      'parent[child]' => $this->randomString(),
+      'field[0]' => $this->randomString(),
+      'field[1]' => $this->randomString(),
       'field[new]' => 'spam',
     );
     $this->drupalPost(NULL, $edit, 'Submit');
@@ -810,6 +828,7 @@ class MollomFormConfigurationTestCase ex
     // Verify that the form was not submitted and cannot be submitted.
     $this->assertNoText('Successful form submission.');
     $this->assertText($this->spam_message);
+    $this->assertMollomWatchdogMessages();
   }
 
   /**
@@ -827,7 +846,7 @@ class MollomFormConfigurationTestCase ex
     //   this module. Registered forms for Contact and Node modules are not
     //   contained. Uncomment these assertions in D7.
     /*
-    $this->drupalGet('admin/settings/mollom');
+    $this->drupalGet('admin/config/content/mollom');
     foreach ($form_info as $form_id => $info) {
       if (!empty($info['mode'])) {
         $this->assertText($info['title']);
@@ -836,12 +855,12 @@ class MollomFormConfigurationTestCase ex
     */
 
     // Unprotect user_register form.
-    $this->drupalPost('admin/settings/mollom/unprotect/user_register', array(), t('Confirm'));
+    $this->drupalPost('admin/config/content/mollom/unprotect/user_register', array(), t('Confirm'));
     $this->assertNoText($form_info['user_register']['title']);
     $this->assertFalse(mollom_form_load('user_register'), t('Form configuration no longer exists.'));
 
     // Re-protect user_register form.
-    $this->drupalGet('admin/settings/mollom/add');
+    $this->drupalGet('admin/config/content/mollom/add');
     $this->assertNoText(t('All available forms are protected already.'));
     $edit = array(
       'mollom[form_id]' => 'user_register',
@@ -862,7 +881,7 @@ class MollomFormConfigurationTestCase ex
         $edit = array(
           'mollom[form_id]' => $form_id,
         );
-        $this->drupalPost('admin/settings/mollom/add', $edit, t('Next'));
+        $this->drupalPost('admin/config/content/mollom/add', $edit, t('Next'));
         $this->assertText($info['title']);
         if (isset($info['mode'])) {
           // Verify that CAPTCHA-only forms contain no configurable fields.
@@ -883,7 +902,7 @@ class MollomFormConfigurationTestCase ex
     }
 
     // Verify that trying to add a form redirects to the overview.
-    $this->drupalGet('admin/settings/mollom/add');
+    $this->drupalGet('admin/config/content/mollom/add');
     $this->assertText(t('All available forms are protected already.'));
     $this->assertText(t('Operations'));
   }
@@ -917,6 +936,7 @@ class MollomUserFormsTestCase extends Mo
     // Try to reset the user's password by specifying an invalid CAPTCHA.
     $edit = array('name' => $this->web_user->name);
     $this->postIncorrectCaptcha('user/password', $edit, t('E-mail new password'));
+    $this->postCorrectCaptcha(NULL, array(), t('E-mail new password'));
 
     // Try to reset the user's password by specifying a valid CAPTCHA.
     $this->postCorrectCaptcha('user/password', $edit, t('E-mail new password'));
@@ -929,7 +949,7 @@ class MollomUserFormsTestCase extends Mo
   function testProtectRegisterUser() {
     // We first enable Mollom for the user registration form.
     $this->drupalLogin($this->admin_user);
-    $this->setProtection('user_register');
+    $this->setProtection('user_register_form');
     $this->drupalLogout();
 
     // Validate that the user registration form has a CAPTCHA text field.
@@ -944,13 +964,13 @@ class MollomUserFormsTestCase extends Mo
       'mail' => $name . '@example.com',
     );
     $this->postIncorrectCaptcha('user/register', $edit, t('Create new account'));
-    $this->assertFalse(user_load(array('name' => $name)), t('The user who attempted to register cannot be found in the database when the CAPTCHA is invalid.'));
+    $this->assertFalse(user_load_by_name($name), t('The user who attempted to register cannot be found in the database when the CAPTCHA is invalid.'));
 
     // Try to register with a valid CAPTCHA. Make sure the user was able
     // to successfully register.
     $this->postCorrectCaptcha('user/register', $edit, t('Create new account'));
     $this->assertText(t('Your password and further instructions have been sent to your e-mail address.'));
-    $this->assertTrue(user_load(array('name' => $name)), t('The user who attempted to register appears in the database when the CAPTCHA is valid.'));
+    $this->assertTrue(user_load_by_name($name), t('The user who attempted to register appears in the database when the CAPTCHA is valid.'));
   }
 }
 
@@ -968,9 +988,9 @@ class MollomCommentFormTestCase extends 
   function setUp() {
     parent::setUp('comment');
 
-    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval', 'create story content'));
-    $this->node = $this->drupalCreateNode(array('type' => 'story', 'uid' => $this->web_user->uid));
-    variable_set('comment_preview_story', COMMENT_PREVIEW_OPTIONAL);
+    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval', 'create article content'));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $this->web_user->uid));
+    variable_set('comment_preview_article', DRUPAL_OPTIONAL);
   }
 
   /**
@@ -1014,17 +1034,21 @@ class MollomCommentFormTestCase extends 
     // we will verify that this remains the same.
     $mollom_session_id = $this->getFieldValue("edit-mollom-session-id");
 
-    // Try to submit an incorrect answer for the CAPTCHA.
+    // Try to submit an incorrect answer for the CAPTCHA, without value for
+    // required field.
     $this->postIncorrectCaptcha(NULL, array(), t('Preview'));
+    $this->assertText(t('Comment field is required.'), t('Missing required field triggers form rebuild.'));
     $this->assertFieldByID('edit-mollom-session-id', $mollom_session_id, t('The Mollom Session ID is present on the comment form after a possible spam comment is previewed.'));
 
-    // Try to submit a correct answer for the CAPTCHA, but without one of the required field.
+    // Try to submit a correct answer for the CAPTCHA, still without required
+    // field value.
     $this->postCorrectCaptcha(NULL, array(), t('Preview'));
-    $this->assertText(t('Comment field is required.'), t('An empty comment field triggers a rebuild of the form.'));
+    $this->assertText(t('Comment field is required.'), t('Missing required field triggers form rebuild.'));
 
     // Finally, we should be able to submit a comment.
     $this->drupalPost(NULL, array('comment' => 'spam'), t('Save'));
-    $this->assertRaw('<p>spam</p>', t('The comment is finally posted and appears on the screen after it is submitted.'));
+    $this->assertText(t('Your comment has been posted.'));
+    $this->assertRaw('<p>spam</p>', t('Spam comment could be posted with correct CAPTCHA.'));
   }
 
   /**
@@ -1089,7 +1113,7 @@ class MollomCommentFormTestCase extends 
    * and therefore will not work correctly with the SimpleTest browser.
    */
   private function getCommentCount($nid) {
-    return db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $nid));
+    return db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
   }
 
   /**
@@ -1123,7 +1147,7 @@ class MollomContactFormTestCase extends 
   function setUp() {
     parent::setUp('contact');
 
-    $this->web_user = $this->drupalCreateUser(array('access site-wide contact form', 'access user profiles'));
+    $this->web_user = $this->drupalCreateUser(array('access site-wide contact form', 'access user profiles', 'access user contact forms'));
   }
 
   /**
@@ -1134,13 +1158,13 @@ class MollomContactFormTestCase extends 
   function testProtectContactUserForm() {
     // Enable Mollom for the contact form.
     $this->drupalLogin($this->admin_user);
-    $this->setProtection('contact_mail_user');
+    $this->setProtection('contact_personal_form');
     $this->drupalLogout();
 
     $this->drupalLogin($this->web_user);
     $url = 'user/' . $this->admin_user->uid . '/contact';
-    $button = t('Send e-mail');
-    $success = t('The message has been sent.');
+    $button = t('Send message');
+    $success = t('Your message has been sent.');
 
     // Submit a 'spam' message.  This should be blocked.
     $this->assertSpamSubmit($url, array('subject', 'message'), array(), $button);
@@ -1163,15 +1187,21 @@ class MollomContactFormTestCase extends 
   function testProtectContactSiteForm() {
     // Enable Mollom for the contact form.
     $this->drupalLogin($this->admin_user);
-    $this->setProtection('contact_mail_page');
+    $this->setProtection('contact_site_form');
     $this->drupalLogout();
 
     // Add some fields to the contact form so that it is active.
     $this->drupalLogin($this->web_user);
-    db_query("INSERT INTO {contact} (category, recipients, reply) VALUES ('%s', '%s', '%s')", 'test category', $this->web_user->mail, 'test auto-reply');
+    db_insert('contact')
+      ->fields(array(
+        'category' => 'test category',
+        'recipients' => $this->web_user->mail,
+        'reply' => 'test auto-reply',
+      ))
+      ->execute();
 
     $url = 'contact';
-    $button = t('Send e-mail');
+    $button = t('Send message');
     $success = t('Your message has been sent.');
 
     // Submit a 'spam' message.  This should be blocked.
@@ -1343,20 +1373,20 @@ class MollomDataTestCase extends MollomW
   function testAnalysis() {
     // Verify that comment form is protected.
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('admin/settings/mollom');
+    $this->drupalGet('admin/config/content/mollom');
     $this->assertText(t('Comment form'));
-    $this->drupalGet('admin/settings/mollom/manage/comment_form');
+    $this->drupalGet('admin/config/content/mollom/manage/comment_form');
 
     // Make comment preview optional.
     $edit = array(
       'comment_preview' => 0,
     );
-    $this->drupalPost('admin/content/node-type/story', $edit, t('Save content type'));
+    $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
 
     // Create a node we can comment on.
-    $node = $this->drupalCreateNode(array('type' => 'story', 'promote' => 1));
+    $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
     $this->drupalGet('');
-    $this->assertText($node->title);
+    $this->assertText($node->title[LANGUAGE_NONE][0]['value']);
 
     // Log in regular user and post a comment.
     $this->drupalLogout();
@@ -1371,7 +1401,7 @@ class MollomDataTestCase extends MollomW
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->assertText($this->unsure_message);
     $this->PostCorrectCaptcha(NULL, array(), t('Save'));
-    $comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE subject = '%s'", $edit['subject']));
+    $comment = db_query('SELECT * FROM {comment} WHERE subject = :subject', array(':subject' => $edit['subject']))->fetchObject();
     $this->assertTrue($comment, t('Comment exists in database.'));
 
     // Verify that submitted data equals post data.
@@ -1389,13 +1419,13 @@ class MollomDataTestCase extends MollomW
       DRUPAL_ANONYMOUS_RID . '[post comments]' => TRUE,
       DRUPAL_ANONYMOUS_RID . '[post comments without approval]' => TRUE,
     );
-    $this->drupalPost('admin/user/permissions', $edit, t('Save permissions'));
+    $this->drupalPost('admin/config/people/permissions', $edit, t('Save permissions'));
 
     // Allow anonymous users to post contact information.
     $edit = array(
       'comment_anonymous' => COMMENT_ANONYMOUS_MAY_CONTACT,
     );
-    $this->drupalPost('admin/content/node-type/story', $edit, t('Save content type'));
+    $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
 
     // Log out and post a comment as anonymous user.
     $this->drupalLogout();
@@ -1411,7 +1441,7 @@ class MollomDataTestCase extends MollomW
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->assertText($this->unsure_message);
     $this->PostCorrectCaptcha(NULL, array(), t('Save'));
-    $comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE subject = '%s'", $edit['subject']));
+    $comment = db_query('SELECT * FROM {comment} WHERE subject = :subject', array(':subject' => $edit['subject']))->fetchObject();
     $this->assertTrue($comment, t('Comment exists in database.'));
 
     // Verify that submitted data equals post data.
@@ -1425,7 +1455,7 @@ class MollomDataTestCase extends MollomW
 
     // Log in admin user and edit comment containing spam.
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('comment/edit/' . $comment->cid);
+    $this->drupalGet('comment/' . $comment->cid . '/edit');
     // Post without modification.
     $this->drupalPost(NULL, array(), t('Save'));
 
@@ -1450,15 +1480,15 @@ class MollomReportTestCase extends Mollo
   function setUp() {
     parent::setUp('comment');
 
-    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval', 'create story content'));
+    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval', 'create article content'));
   }
 
   /**
    * Tests reporting comments.
    */
   function testReportComment() {
-    $this->node = $this->drupalCreateNode(array('type' => 'story'));
-    variable_set('comment_preview_story', COMMENT_PREVIEW_OPTIONAL);
+    $this->node = $this->drupalCreateNode(array('type' => 'article'));
+    variable_set('comment_preview_article', DRUPAL_OPTIONAL);
 
     // Post a comment.
     $this->drupalLogin($this->web_user);
@@ -1467,7 +1497,7 @@ class MollomReportTestCase extends Mollo
     );
     $this->drupalPost('comment/reply/' . $this->node->nid, $edit, t('Save'));
     $this->assertMollomWatchdogMessages();
-    $this->comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE comment = '%s' AND nid = %d", array($edit['comment'], $this->node->nid)));
+    $this->comment = db_query('SELECT * FROM {comment} WHERE comment = :comment AND nid = :nid', array(':comment' => $edit['comment'], ':nid' => $this->node->nid))->fetchObject();
     $this->assertTrue($this->comment, t('Comment was found in the database.'));
     $this->assertTrue(mollom_data_load('comment', $this->comment->cid), t('Mollom session data was recorded.'));
 
@@ -1481,10 +1511,11 @@ class MollomReportTestCase extends Mollo
     );
     $this->drupalPost(NULL, $edit, t('Delete'));
     $this->assertMollomWatchdogMessages();
-    $this->assertText(t('The comment has been deleted.'));
+    $this->assertText(t('The content was successfully reported as inappropriate.'));
+    $this->assertText(t('The comment and all its replies have been deleted.'));
 
     // Verify that the comment and Mollom session data has been deleted.
-    $this->assertFalse(_comment_load($this->comment->cid), t('Comment was deleted.'));
+    $this->assertFalse(comment_load($this->comment->cid), t('Comment was deleted.'));
     $this->assertFalse(mollom_data_load('comment', $this->comment->cid), t('Mollom session data for comment was deleted.'));
   }
 }
Index: tests/mollom_test.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/Attic/mollom_test.info,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 mollom_test.info
--- tests/mollom_test.info	6 Dec 2009 18:35:16 -0000	1.1.2.1
+++ tests/mollom_test.info	18 Dec 2009 01:46:35 -0000
@@ -1,5 +1,6 @@
 ; $Id: mollom_test.info,v 1.1.2.1 2009/12/06 18:35:16 dries Exp $
 name = Mollom Test
 description = Testing module for Mollom functionality.
-core = 6.x
+core = 7.x
 hidden = TRUE
+files[] = mollom_test.module
Index: tests/mollom_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/Attic/mollom_test.module,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 mollom_test.module
--- tests/mollom_test.module	14 Dec 2009 12:47:16 -0000	1.1.2.2
+++ tests/mollom_test.module	19 Dec 2009 15:25:54 -0000
@@ -65,8 +65,9 @@ function mollom_test_check_content($data
     $quality = NULL;
   }
 
+  drupal_session_start();
   return array(
-    'session_id' => isset($data['session_id']) ? $data['session_id'] : session_id(),
+    'session_id' => !empty($data['session_id']) ? $data['session_id'] : session_id(),
     'spam' => $response,
     'quality' => $quality,
   );
@@ -80,8 +81,9 @@ function mollom_test_get_captcha($data) 
   $storage[] = $data;
   variable_set(__FUNCTION__, $storage);
 
+  drupal_session_start();
   return array(
-    'session_id' => isset($data['session_id']) ? $data['session_id'] : session_id(),
+    'session_id' => !empty($data['session_id']) ? $data['session_id'] : session_id(),
     'url' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'mollom') . '/images/powered-by-mollom-2.gif',
   );
 }
@@ -145,7 +147,7 @@ function mollom_test_mollom_form_info() 
 /**
  * Form builder for Mollom test form.
  */
-function mollom_test_form(&$form_state) {
+function mollom_test_form($form, &$form_state) {
   if (empty($form_state['storage'])) {
     $form_state['storage'] = array(
       'title' => '',
@@ -217,15 +219,12 @@ function mollom_test_form_field_submit($
   $form_state['storage']['field'][] = $form_state['values']['field']['new'];
   unset($form_state['input']['field']['new']);
   $form_state['rebuild'] = TRUE;
-  $form_state['cache'] = TRUE;
 }
 
 /**
  * Form submit handler for mollom_test_form().
  */
 function mollom_test_form_submit($form, &$form_state) {
-  $form_state['rebuild'] = FALSE;
-
   $form_state['values']['field'][] = $form_state['values']['field']['new'];
   unset($form_state['values']['field']['new']);
   drupal_set_message('Successful form submission.');
