? 928110-1.tracker2_views.patch
? 928110-2.tracker2_views.patch
? dif
? tracker2_views.tgz
cvs diff: Diffing .
Index: tracker2.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tracker2/tracker2.module,v
retrieving revision 1.14.2.7
diff -u -p -r1.14.2.7 tracker2.module
--- tracker2.module	29 Sep 2010 17:07:38 -0000	1.14.2.7
+++ tracker2.module	1 Oct 2010 20:35:17 -0000
@@ -323,3 +323,13 @@ function tracker2_theme() {
     ),
   );
 }
+
+/**
+ * Implementation of hook_views_api().
+ */
+function tracker2_views_api() {
+  return array(
+    'api' => 2.0,
+    'path' => drupal_get_path('module', 'tracker2') . '/views',
+  );
+}
cvs diff: Diffing views
Index: views/tracker2.views.inc
===================================================================
RCS file: views/tracker2.views.inc
diff -N views/tracker2.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/tracker2.views.inc	1 Oct 2010 20:35:18 -0000
@@ -0,0 +1,191 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Provides support for Views integration.
+ */
+
+/**
+ * Implementation of hook_views_data().
+ */
+function tracker2_views_data() {
+  $data = array();
+
+  $data['tracker2_node']['table']['group']  = t('Tracker 2');
+  $data['tracker2_node']['table']['join'] = array(
+    'node' => array(
+      'type' => 'INNER',
+      'left_field' => 'nid',
+      'field' => 'nid',
+    ),
+  );
+  $data['tracker2_node']['nid'] = array(
+    'title' => t('NID'),
+    'help' => t('The node ID of the node.'),
+    'field' => array(
+      'handler' => 'views_handler_field_node',
+      'click sortable' => TRUE,
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_node_nid',
+      'parent' => 'views_handler_argument_numeric', // make sure parent is included
+      'name field' => 'title', // the field to display in the summary.
+      'numeric' => TRUE,
+      'validate type' => 'nid',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  $data['tracker2_node']['changed'] = array(
+    'title' => t('Updated date'),
+    'help' => t('The date the node was last updated.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+  $data['tracker2_node']['published'] = array(
+    'title' => t('Published'),
+    'help' => t('Whether or not the node is published.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'tracker2_handler_filter_boolean_operator',
+      'label' => t('Published'),
+      'type' => 'yes-no',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
+  $data['tracker2_user']['table']['group']  = t('Tracker 2 - User');
+  $data['tracker2_user']['table']['join'] = array(
+    'node' => array(
+      'type' => 'INNER',
+      'left_field' => 'nid',
+      'field' => 'nid',
+    ),
+    'user' => array(
+      'type' => 'INNER',
+      'left_field' => 'uid',
+      'field' => 'uid',
+    ),
+  );
+  $data['tracker2_user']['nid'] = array(
+    'title' => t('NID'),
+    'help' => t('The node ID of the node a user created or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_node',
+      'click sortable' => TRUE,
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_node_nid',
+      'parent' => 'views_handler_argument_numeric', // make sure parent is included
+      'name field' => 'title', // the field to display in the summary.
+      'numeric' => TRUE,
+      'validate type' => 'nid',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  $data['tracker2_user']['uid'] = array(
+    'title' => t('UID'),
+    'help' => t('The user ID of a user who touched the node (either created or commented on it).'),
+    'field' => array(
+      'handler' => 'views_handler_field_user',
+      'click sortable' => TRUE,
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_user_uid',
+      'name field' => 'name', // display this field in the summary
+    ),
+    'filter' => array(
+      'title' => t('Name'),
+      'handler' => 'views_handler_filter_user_name',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  $data['tracker2_user']['changed'] = array(
+    'title' => t('Updated date'),
+    'help' => t('The date the node was last updated or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+  $data['tracker2_user']['published'] = array(
+    'title' => t('Published'),
+    'help' => t('Whether or not the node is published. You must use an argument or filter on UID or you will get misleading results using this field.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'tracker2_handler_filter_boolean_operator',
+      'label' => t('Published'),
+      'type' => 'yes-no',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
+  return $data;
+}
+
+/**
+ * Implementation of hook_views_data_alter().
+ */
+function tracker2_views_data_alter(&$data) {
+  // Swap out the handlers for the uid_touch filter and argument.
+  $data['node']['uid_touch']['argument']['handler'] = 'tracker2_handler_argument_comment_user_uid';
+  $data['node']['uid_touch']['filter']['handler'] = 'tracker2_handler_filter_comment_user_uid';
+}
+
+/**
+ * Implementation of hook_views_handlers().
+ */
+function tracker2_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'tracker2') . '/views',
+    ),
+    'handlers' => array(
+      'tracker2_handler_argument_comment_user_uid' => array(
+        'parent' => 'views_handler_argument_comment_user_uid',
+      ),
+      'tracker2_handler_filter_boolean_operator' => array(
+        'parent' => 'views_handler_filter_boolean_operator',
+      ),
+      'tracker2_handler_filter_comment_user_uid' => array(
+        'parent' => 'views_handler_filter_user_name',
+      ),
+    ),
+  );
+}
Index: views/tracker2_handler_argument_comment_user_uid.inc
===================================================================
RCS file: views/tracker2_handler_argument_comment_user_uid.inc
diff -N views/tracker2_handler_argument_comment_user_uid.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/tracker2_handler_argument_comment_user_uid.inc	1 Oct 2010 20:35:18 -0000
@@ -0,0 +1,15 @@
+<?php
+// $Id$
+
+/**
+ * UID argument to check for nodes that user posted or commented on.
+ */
+class tracker2_handler_argument_comment_user_uid extends views_handler_argument_comment_user_uid {
+  function query() {
+    // Because this handler thinks it's an argument for a field on the {node}
+    // table, we need to make sure {tracker2_user} is JOINed and use its alias
+    // for the WHERE clause.
+    $tracker2_user_alias = $this->query->ensure_table('tracker2_user');
+    $this->query->add_where(0, "$tracker2_user_alias.uid = %d", $this->argument);
+  }
+}
Index: views/tracker2_handler_filter_boolean_operator.inc
===================================================================
RCS file: views/tracker2_handler_filter_boolean_operator.inc
diff -N views/tracker2_handler_filter_boolean_operator.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/tracker2_handler_filter_boolean_operator.inc	1 Oct 2010 20:35:18 -0000
@@ -0,0 +1,22 @@
+<?php
+// $Id$
+
+/**
+ * Filter handler for boolean values to use = 1 instead of <> 0.
+ */
+class tracker2_handler_filter_boolean_operator extends views_handler_filter_boolean_operator {
+  function query() {
+    $this->ensure_my_table();
+    $where = "$this->table_alias.$this->real_field ";
+    if (empty($this->value)) {
+      $where .= '= 0';
+      if ($this->accept_null) {
+        $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
+      }
+    }
+    else {
+      $where .= '= 1';
+    }
+    $this->query->add_where($this->options['group'], $where);
+  }
+}
Index: views/tracker2_handler_filter_comment_user_uid.inc
===================================================================
RCS file: views/tracker2_handler_filter_comment_user_uid.inc
diff -N views/tracker2_handler_filter_comment_user_uid.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/tracker2_handler_filter_comment_user_uid.inc	1 Oct 2010 20:35:18 -0000
@@ -0,0 +1,15 @@
+<?php
+// $Id$
+
+/**
+ * UID filter to check for nodes that user posted or commented on.
+ */
+class tracker2_handler_filter_comment_user_uid extends views_handler_filter_comment_user_uid {
+  function query() {
+    // Because this handler thinks it's an argument for a field on the {node}
+    // table, we need to make sure {tracker2_user} is JOINed and use its alias
+    // for the WHERE clause.
+    $tracker2_user_alias = $this->query->ensure_table('tracker2_user');
+    $this->query->add_where(0, "$tracker2_user_alias.uid = %d", $this->argument);
+  }
+}
