Index: uc_node_access.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_node_access/uc_node_access.module,v
retrieving revision 1.1.4.4
diff -u -p -r1.1.4.4 uc_node_access.module
--- uc_node_access.module	25 Aug 2010 15:04:54 -0000	1.1.4.4
+++ uc_node_access.module	12 Nov 2010 14:14:35 -0000
@@ -590,3 +629,13 @@ function uc_node_access_grant_access($or
     }
   }
 }
+
+/**
+ * Implementation of hook_views_api().
+ */
+function uc_node_access_views_api() {
+  return array(
+    'api' => '2.0',
+    'path' => drupal_get_path('module', 'uc_node_access') .'/views',
+  );
+}
Index: views/uc_node_access.views.inc
--- /dev/null
+++ views/uc_node_access.views.inc
@@ -0,0 +1,73 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_views_data().
+ */
+function uc_node_access_views_data() {
+  $data['uc_node_access_products']['table']['group'] = t('Product');
+  $data['uc_node_access_products']['table']['join']['node'] = array(
+    'left_field' => 'nid',
+    'field' => 'access_nid',
+  );
+  $data['uc_node_access_products']['pfid'] = array(
+    'title' => t('Has node access feature'),
+    'help' => t('Check that the node has a node access product feature attached.'),
+    'filter' => array(
+      'handler' => 'views_handler_filter_boolean_operator',
+      'type' => 'yes-no',
+      'accept_null' => TRUE,
+      'label' => t('Has node access feature'),
+    ),
+  );
+
+  $data['uc_node_access_expirations']['table']['group'] = t('Node access');
+  $data['uc_node_access_expirations']['table']['join']['node'] = array(
+    'left_field' => 'nid',
+    'field' => 'access_nid',
+    'extra' => array(
+      array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
+    ),
+  );
+  $data['uc_node_access_expirations']['expiration'] = array(
+    'title' => t('Expiry'),
+    'help' => t('The date that access to this node will expire for the current user.'),
+    'field' => array(
+      'handler' => 'uc_node_access_handler_field_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
+  $data['uc_node_access_expirations']['has_expiration'] = array(
+    'title' => t('Expires'),
+    'help' => t('Filter for nodes that will eventually expire.'),
+    'filter' => array(
+      'field' => 'expiration',
+      'handler' => 'views_handler_filter_boolean_operator',
+      'type' => 'yes-no',
+      'accept_null' => TRUE,
+      'label' => t('Node access will expire'),
+    ),
+  );
+
+  return $data;
+}
+
+/**
+ * Implementation of hook_views_handlers().
+ */
+function uc_node_access_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'uc_node_access') . '/views',
+    ),
+    'handlers' => array(
+      'uc_node_access_handler_field_date' => array('parent' => 'views_handler_field_date'),
+    ),
+  );
+}
Index: views/uc_node_access.views_default.inc
--- /dev/null
+++ views/uc_node_access.views_default.inc
@@ -0,0 +1,161 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_views_default_views().
+ */
+function uc_node_access_views_default_views() {
+  $view = new view;
+  $view->name = 'uc_node_access';
+  $view->description = '';
+  $view->tag = 'Ubercart';
+  $view->view_php = '';
+  $view->base_table = 'node';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->override_option('fields', array(
+    'title' => array(
+      'label' => 'Title',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'link_to_node' => 1,
+      'exclude' => 0,
+      'id' => 'title',
+      'table' => 'node',
+      'field' => 'title',
+      'relationship' => 'none',
+    ),
+    'expiration' => array(
+      'label' => 'Expires',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'html' => 0,
+        'strip_tags' => 0,
+      ),
+      'empty' => 'never',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'date_format' => 'raw time hence',
+      'custom_date_format' => '',
+      'exclude' => 0,
+      'id' => 'expiration',
+      'table' => 'uc_node_access_expirations',
+      'field' => 'expiration',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('filters', array(
+    'status' => array(
+      'operator' => '=',
+      'value' => '1',
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+      ),
+      'id' => 'status',
+      'table' => 'node',
+      'field' => 'status',
+      'relationship' => 'none',
+    ),
+    'pfid' => array(
+      'operator' => '=',
+      'value' => '1',
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+      ),
+      'id' => 'pfid',
+      'table' => 'uc_node_access_products',
+      'field' => 'pfid',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('access', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('cache', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('title', 'Subscribed content');
+  $handler->override_option('items_per_page', 0);
+  $handler->override_option('distinct', 0);
+  $handler->override_option('style_plugin', 'table');
+  $handler->override_option('style_options', array(
+    'grouping' => '',
+    'override' => 1,
+    'sticky' => 0,
+    'order' => 'asc',
+    'columns' => array(
+      'title' => 'title',
+      'expiration' => 'expiration',
+    ),
+    'info' => array(
+      'title' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'expiration' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+    ),
+    'default' => '-1',
+  ));
+  $handler = $view->new_display('page', 'Page', 'page_1');
+  $handler->override_option('path', 'nodeaccess');
+  $handler->override_option('menu', array(
+    'type' => 'none',
+    'title' => '',
+    'description' => '',
+    'weight' => 0,
+    'name' => 'navigation',
+  ));
+  $handler->override_option('tab_options', array(
+    'type' => 'none',
+    'title' => '',
+    'description' => '',
+    'weight' => 0,
+    'name' => 'navigation',
+  ));
+  $views[$view->name] = $view;
+
+  return $views;
+}
Index: views/uc_node_access_handler_field_date.inc
--- /dev/null
+++ views/uc_node_access_handler_field_date.inc
@@ -0,0 +1,25 @@
+<?php
+// $Id$
+
+class uc_node_access_handler_field_date extends views_handler_field_date {
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $form['date_format']['#options']['raw time hence'] = t('Time hence');
+    $form['custom_date_format']['#dependency']['edit-options-date-format'][] = 'raw time hence';
+  }
+
+  function render($values) {
+    $value = $values->{$this->field_alias};
+    $format = $this->options['date_format'];
+
+    if ($value && $format == 'raw time hence') {
+      $time_diff = $value - time();
+      $custom_format = $this->options['custom_date_format'];
+      return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
+    }
+    else {
+      return parent::render($values);
+    }
+  }
+}
