Commit 1727ace4 authored by jcnventura's avatar jcnventura

Issue #1299150 by lliss: View integration for the most emailed counter.

parent 7395329c
......@@ -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',
),
);
}
<?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']);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment