? code-clean.sh
? modules
? spam-comment-queue-HEAD.patch
Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.43
diff -u -r1.43 mollom.admin.inc
--- mollom.admin.inc	9 Oct 2010 23:13:01 -0000	1.43
+++ mollom.admin.inc	12 Oct 2010 01:50:05 -0000
@@ -597,6 +597,132 @@
 }
 
 /**
+ * TODO
+ */
+function mollom_comment_queue() {
+  return drupal_get_form('mollom_comment_queue_form');
+}
+
+/**
+ * TODO
+ */
+function mollom_comment_queue_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->addField('m', 'moderate', 'spam', 'profanity');
+  $result = $query
+    ->fields('c', array('cid', 'subject', 'name', 'changed'))
+    ->condition('c.status', COMMENT_NOT_PUBLISHED)
+    ->condition('m.entity', 'comment')
+    ->limit(50)
+    ->orderByHeader($header)
+    ->execute();
+
+  // Build an array of all the comment IDs and load them in one pass.
+  $cids = array();
+  foreach ($result as $row) {
+    $cids[] = $row->cid;
+  }
+  $comments = comment_load_multiple($cids);
+
+  $options = array();
+  foreach ($comments as $comment) {
+    // Collect status information.
+    $status = array();
+    if (isset($comment->spam) && $comment->spam == MOLLOM_ANALYSIS_SPAM) {
+      $status[] = t('spam');
+    }
+    if (isset($comment->profanity) && $comment->profanity == 1) { // @todo use define for consistency?
+      $status[] = t('profanity');
+    }
+    $status = implode(', ', $status);
+
+    $options[$comment->cid] = array(
+      'subject' => array(
+        'data' => array(
+          '#type' => 'markup',
+          '#markup' => l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) .'<br />' . check_plain(truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 384, TRUE, TRUE)),
+        ),
+      ),
+      'author' => theme('username', array('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 . '/publish', // @fixme
+        ),
+      ),
+    );
+  }
+
+  $form['comments'] = array(
+    '#type' => 'tableselect',
+    '#header' => $header,
+    '#options' => $options,
+    '#empty' => t('No comments available.'),
+  );
+
+  // @todo: implement delete 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;
+}
+
+/**
+ * Returns a menu title which includes the number of spam and profane comments.
+ */
+function mollom_comment_queue_count() {
+  $count = db_query('SELECT COUNT(id) FROM {mollom} WHERE moderate = 1')->fetchField();
+  return t('Spam comments (@count)', array('@count' => $count));
+  // @todo somehow this callback isn't always invoked when we'd want it to be ... to be investigated. Bug?
+}
+
+/**
+ * Implements hook_entity_load().
+ */
+function mollom_entity_load($entities, $type) {
+  // Extract an array of all entity ids.
+  $ids = array_keys($entities);
+
+  // Fetch the spam and profanity scores for these entities.
+  $mollom = db_query("SELECT id, spam, profanity FROM {mollom} WHERE entity = :type AND id IN (:ids)", array(':type' => $type, ':ids' => $ids))->fetchAllAssoc('id');
+  // @todo check if this entity type is protected by Mollom to avoid query
+
+  // Add these scores to the entities.
+  foreach ($entities as $id => $entity) {
+    $entities[$id]->spam = $mollom[$id]->spam;
+    $entities[$id]->profanity = $mollom[$id]->profanity;
+  }
+
+  // @todo looks like this might not always be properly invoked. Values dissapear sometimes. Bug?
+}
+
+/**
  * Form builder; Global Mollom settings form.
  *
  * This form does not validate Mollom API keys, since the fallback method still
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.89
diff -u -r1.89 mollom.module
--- mollom.module	9 Oct 2010 23:13:01 -0000	1.89
+++ mollom.module	12 Oct 2010 01:50:06 -0000
@@ -285,6 +285,15 @@
     'file' => 'mollom.admin.inc',
   );
 
+  $items['admin/content/comment/mollom'] = array(
+    'title callback' => 'mollom_comment_queue_count',
+    'page callback' => array('mollom_comment_queue'),
+    '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',
