summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--print_mail/print_mail.module26
-rw-r--r--print_mail/views_handler_sort_print_mail_sentcount.inc15
2 files changed, 41 insertions, 0 deletions
diff --git a/print_mail/print_mail.module b/print_mail/print_mail.module
index d57a4bf..799a059 100644
--- a/print_mail/print_mail.module
+++ b/print_mail/print_mail.module
@@ -588,3 +588,29 @@ function print_mail_mollom_form_info($form_id) {
}
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',
+ ),
+ );
+}
diff --git a/print_mail/views_handler_sort_print_mail_sentcount.inc b/print_mail/views_handler_sort_print_mail_sentcount.inc
new file mode 100644
index 0000000..a274263
--- /dev/null
+++ b/print_mail/views_handler_sort_print_mail_sentcount.inc
@@ -0,0 +1,15 @@
+<?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']);
+ }
+}