}
return $form_info;
}
+
+/**
+ * Implements hook_views_api().
+ */
+function print_mail_views_api() {
+ return array(
+ 'api' => 2.0,
+ 'path' => drupal_get_path('module', 'print_mail'),
+ );
+}
+
+/**
+ * Implements hook_views_data_alter().
+ *
+ * Provide a new option the views sorts for the number of times
+ * a node has been emailed.
+ */
+function print_mail_views_data_alter(&$data) {
+ $data['node']['print_mail_sentcount'] = array(
+ 'title' => t('Number of times emailed'),
+ 'help' => t("The total number of times the node has been sent through print module's send by email feature."),
+ 'sort' => array(
+ 'handler' => 'views_handler_sort_print_mail_sentcount',
+ ),
+ );
+}
--- /dev/null
+<?php
+
+/**
+ * Extend the default sort handler.
+ * Add a relationship with custom join to print's emailed counter
+ */
+class views_handler_sort_print_mail_sentcount extends views_handler_sort {
+ function query() {
+ $table = 'print_mail_page_counter';
+ $join = new views_join;
+ $join->construct($table, NULL, "CONCAT('node/', node.nid)", 'path', NULL, 'LEFT');
+ $alias = $this->query->add_relationship($table, $join, 'node');
+ $this->query->add_orderby($table, 'sentcount', $this->options['order']);
+ }
+}