Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.43
diff -u -p -r1.43 mollom.admin.inc
--- mollom.admin.inc	9 Oct 2010 23:13:01 -0000	1.43
+++ mollom.admin.inc	12 Oct 2010 18:36:45 -0000
@@ -708,3 +708,102 @@ function mollom_reports_page($form, &$fo
   return $form;
 }
 
+/**
+ * Form constructor for Mollom's comment moderation queue.
+ */
+function mollom_comment_moderation_form() {
+  $header = array(
+    'subject' => array('data' => t('Comment'), 'field' => 'subject'),
+    'author' => array('data' => t('Author'), 'field' => 'name'),
+    'changed' => array('data' => t('Updated'), 'field' => 'changed', 'sort' => 'desc'),
+    'status' => array('data' => t('Status')),
+    'operations' => array('data' => t('Operations')),
+  );
+
+  $query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
+  $query->join('mollom', 'm', 'm.id = c.cid');
+  $query
+    ->fields('c', array('cid', 'subject', 'name', 'changed'))
+    ->fields('m', array('moderate', 'spam', 'profanity'))
+    ->condition('m.entity', 'comment')
+    ->condition('m.moderate', 1)
+    ->limit(50)
+    ->orderByHeader($header);
+
+  // Build an array of all the comment IDs and load them in one pass.
+  $cids = array();
+  foreach ($query->execute() as $row) {
+    $cids[] = $row->cid;
+  }
+  $comments = comment_load_multiple($cids);
+
+  $options = array();
+  foreach ($comments as $comment) {
+    // Collect status information.
+    $status = array();
+    if (isset($comment->mollom->spam) && $comment->mollom->spam == MOLLOM_ANALYSIS_SPAM) {
+      $status[] = t('Spam');
+    }
+    if (isset($comment->mollom->profanity) && $comment->mollom->profanity >= 0.5) {
+      $status[] = t('Profanity');
+    }
+    $status = implode(', ', $status);
+
+    $comment_teaser = truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 384, TRUE, TRUE);
+    $options[$comment->cid] = array(
+      'subject' => array(
+        'data' => array(
+          '#type' => 'link',
+          '#title' => $comment->subject,
+          '#href' => 'comment/' . $comment->cid,
+          '#options' => array(
+            'fragment' => 'comment-' . $comment->cid,
+          ),
+          '#suffix' => '<br />' . check_plain($comment_teaser),
+        ),
+      ),
+      'author' => array(
+        'data' => array(
+          '#theme' => 'username',
+          '#account' => $comment,
+        ),
+      ),
+      'changed' => format_date($comment->changed, 'short'),
+      'status' => array(
+        'data' => array(
+          '#type' => 'markup',
+          '#markup' => $status,
+        ),
+      ),
+      'operations' => array(
+        'data' => array(
+          '#type' => 'link',
+          '#title' => t('publish'),
+          '#href' => 'comment/' . $comment->cid . '/approve',
+        ),
+      ),
+    );
+  }
+
+  $form['comments'] = array(
+    '#type' => 'tableselect',
+    '#header' => $header,
+    '#options' => $options,
+    '#empty' => t('No comments available.'),
+  );
+
+  // @todo Implement form submit handlers.
+  $form['delete selected'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete selected'),
+  );
+  $form['delete all'] = array(
+    '#type' => 'submit',
+    '#value' => t('Delete all'),
+  );
+
+  $form['pager'] = array('#theme' => 'pager');
+
+  return $form;
+}
+
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.89
diff -u -p -r1.89 mollom.module
--- mollom.module	9 Oct 2010 23:13:01 -0000	1.89
+++ mollom.module	12 Oct 2010 18:28:45 -0000
@@ -285,6 +285,17 @@ function mollom_menu() {
     'file' => 'mollom.admin.inc',
   );
 
+  // Comment moderation UI.
+  $items['admin/content/comment/mollom'] = array(
+    'title' => 'Spam comments (@count)',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('mollom_comment_moderation_form'),
+    'access arguments' => array('administer comments'),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'mollom.admin.inc',
+    'weight' => 2,
+  );
+
   // AJAX callback to request new CAPTCHA.
   $items['mollom/captcha/%/%/%'] = array(
     'page callback' => 'mollom_captcha_js',
@@ -298,6 +309,30 @@ function mollom_menu() {
 }
 
 /**
+ * Implements hook_menu_link_alter().
+ */
+function mollom_menu_link_alter(&$link) {
+  // Enable hook_translated_menu_link_alter() for admin/content/comment/mollom.
+  if ($link['link_path'] == 'admin/content/comment/mollom') {
+    $link['options']['alter'] = TRUE;
+  }
+}
+
+/**
+ * Implements hook_translated_menu_link_alter().
+ */
+function mollom_translated_menu_link_alter(&$link) {
+  // Replace @count with actual count of to be moderated comments.
+  if ($link['link_path'] == 'admin/content/comment/mollom') {
+    $count = db_query('SELECT COUNT(id) FROM {mollom} WHERE entity = :entity AND moderate = :moderate', array(
+      ':entity' => 'comment',
+      ':moderate' => 1,
+    ))->fetchField();
+    $link['title'] = t($link['link_title'], array('@count' => $count));
+  }
+}
+
+/**
  * Access callback; check if the module is configured.
  *
  * This function does not actually check whether Mollom keys are valid for the
@@ -410,7 +445,23 @@ function mollom_cron() {
  *   The entity id to retrieve data for.
  */
 function mollom_data_load($entity, $id) {
-  return db_query_range('SELECT * FROM {mollom} WHERE entity = :entity AND id = :id', 0, 1, array(':entity' => $entity, ':id' => $id))->fetchObject();
+  $data = mollom_data_load_multiple(array($id));
+  return $data ? $data[$id] : FALSE;
+}
+
+/**
+ * Load Mollom data records from the database.
+ *
+ * @param $entity
+ *   The entity type to retrieve data for.
+ * @param $ids
+ *   A list of entity ids to retrieve data for.
+ */
+function mollom_data_load_multiple($entity, array $ids) {
+  return db_query('SELECT * FROM {mollom} WHERE entity = :entity AND id IN (:ids)', array(
+    ':entity' => $entity,
+    ':ids' => $ids,
+  ))->fetchAllAssoc('id');
 }
 
 /**
@@ -2049,6 +2100,18 @@ function mollom_mail_add_report_link(&$m
 }
 
 /**
+ * Implements hook_entity_load().
+ */
+function mollom_entity_load($entities, $type) {
+  // Attach Mollom session data to all loaded entities, if there is any.
+  if ($data = mollom_data_load_multiple($type, array_keys($entities))) {
+    foreach ($data as $id => $record) {
+      $entities[$id]->mollom = $record;
+    }
+  }
+}
+
+/**
  * @name mollom_node Node module integration for Mollom.
  * @{
  */
