From 2986175f0c0e1b26307455f397c8a303efac974d Mon Sep 17 00:00:00 2001
From: Gordon Heydon <gordon@heydon.com.au>
Date: Mon, 5 Mar 2012 10:36:44 +1100
Subject: [PATCH 2/2] Views Integration for mollom

---
 mollom.module    |   20 +++++++++++++-
 mollom.views.inc |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletions(-)
 create mode 100644 mollom.views.inc

diff --git a/mollom.module b/mollom.module
index 90f01b7..0667eac 100644
--- a/mollom.module
+++ b/mollom.module
@@ -3458,4 +3458,22 @@ function mollom_action_comment($comment, $op) {
 
 /**
  * @} End of "name mollom_action".
- */
\ No newline at end of file
+ */
+
+/**
+ * @name mollom_views Views integration for Mollom.
+ * @{
+ */
+
+/**
+ * Implementation of hook_views_api().
+ */
+function mollom_views_api() {
+ return array(
+   'api' => 2.0
+ );
+}
+
+/**
+ * @} End of "name mollom_views".
+ */
diff --git a/mollom.views.inc b/mollom.views.inc
new file mode 100644
index 0000000..5644636
--- /dev/null
+++ b/mollom.views.inc
@@ -0,0 +1,77 @@
+<?php
+
+/**
+ * @file
+ */
+
+/**
+ * Implmementation of hook_views_data().
+ */
+function mollom_views_data() {
+  $data = array();
+  
+  $data['mollom']['table']['group'] = t('Mollom');
+  
+  $data['mollom']['table']['join'] = array(
+    'node' => array(
+      'left_field' => 'nid',
+      'field' => 'id',
+      'type' => 'LEFT',
+      'extra' => array(
+        array(
+          'field' => 'entity',
+          'value' => 'node',
+        )
+      ),
+    ),
+    'node_revision' => array(
+      'left_field' => 'nid',
+      'field' => 'id',
+      'type' => 'LEFT',
+      'extra' => array(
+        array(
+          'field' => 'entity',
+          'value' => 'node',
+        )
+      ),
+    ),
+    'comments' => array(
+      'left_field' => 'cid',
+      'field' => 'id',
+      'type' => 'LEFT',
+      'extra' => array(
+        array(
+          'field' => 'entity',
+          'value' => 'comment',
+        )
+      ),
+    ),
+  );
+  
+  $data['mollom']['spamScore'] = array(
+    'title' => t('Spam Score'),
+    'help' => t('Score which mollom assigned to the piece of content'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+  );
+  $data['mollom']['spamClassification'] = array(
+    'title' => t('Spam classification'),
+    'help' => t('Mollom\'s classification of the content'),
+    'field' => array(
+      'handler' => 'views_handler_field'
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  
+  return $data;
+}
\ No newline at end of file
-- 
1.7.5.4

