2 // $Id: views_handler_field_history_user_timestamp.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
4 * Field handler to display the marker for new content.
6 class views_handler_field_history_user_timestamp extends views_handler_field_node {
7 function init(&$view, $options) {
8 parent::init($view, $options);
11 $this->additional_fields['created'] = array('table' => 'node', 'field' => 'created');
12 $this->additional_fields['changed'] = array('table' => 'node', 'field' => 'changed');
13 if (module_exists('comment') && !empty($this->options['comments'])) {
14 $this->additional_fields['last_comment'] = array('table' => 'node_comment_statistics', 'field' => 'last_comment_timestamp');
19 function option_definition() {
20 $options = parent::option_definition();
22 $options['comments'] = array('default' => FALSE);
27 function options_form(&$form, &$form_state) {
28 parent::options_form($form, $form_state);
29 if (module_exists('comment')) {
30 $form['comments'] = array(
31 '#type' => 'checkbox',
32 '#title' => t('Check for new comments as well'),
33 '#default_value' => !empty($this->options['comments']),
39 // Only add ourselves to the query if logged in.
47 function render($values) {
48 // Let's default to 'read' state.
49 // This code shadows node_mark, but it reads from the db directly and
50 // we already have that info.
54 $last_read = $values->{$this->field_alias};
55 $created = $values->{$this->aliases['created']};
56 $changed = $values->{$this->aliases['changed']};
58 $last_comment = module_exists('comment') && !empty($this->options['comments']) ? $values->{$this->aliases['last_comment']} : 0;
60 if (!$last_read && $created > NODE_NEW_LIMIT) {
63 elseif ($changed > $last_read && $changed > NODE_NEW_LIMIT) {
66 elseif ($last_comment > $last_read && $last_comment > NODE_NEW_LIMIT) {
69 return $this->render_link(theme('mark', $mark), $values);