/[drupal]/contributions/modules/views/modules/comment/views_handler_field_node_new_comments.inc
ViewVC logotype

Diff of /contributions/modules/views/modules/comment/views_handler_field_node_new_comments.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7.4.1, Mon Nov 2 22:01:26 2009 UTC revision 1.7.4.2, Mon Nov 9 22:46:05 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: views_handler_field_node_new_comments.inc,v 1.6.2.1 2009/07/02 00:13:06 merlinofchaos Exp $  // $Id: views_handler_field_node_new_comments.inc,v 1.7.4.1 2009/11/02 22:01:26 merlinofchaos Exp $
3    
4  /**  /**
5   * Field handler to display the number of new comments   * Field handler to display the number of new comments
# Line 63  class views_handler_field_node_new_comme Line 63  class views_handler_field_node_new_comme
63      }      }
64    
65      if ($nids) {      if ($nids) {
66        $result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = %d WHERE n.nid IN (" . implode(', ', $nids) . ") AND c.timestamp > GREATEST(COALESCE(h.timestamp, %d), %d) AND c.status = %d GROUP BY n.nid  ", $user->uid, NODE_NEW_LIMIT, NODE_NEW_LIMIT, COMMENT_PUBLISHED);        $result = db_query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment} c ON n.nid = c.nid
67            LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN (:nids)
68            AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp) AND c.status = :status GROUP BY n.nid  ", array(
69              ':status' => COMMENT_PUBLISHED,
70              ':h_uid' => $user->uid,
71              ':nids' => $nids,
72              ':timestamp' => NODE_NEW_LIMIT,
73            ));
74    
75        while ($node = db_fetch_object($result)) {        foreach ($result as $node) {
76          foreach ($ids[$node->nid] as $id) {          foreach ($ids[$node->nid] as $id) {
77            $values[$id]->{$this->field_alias} = $node->num_comments;            $values[$id]->{$this->field_alias} = $node->num_comments;
78          }          }
79        }        }
   
80      }      }
81    }    }
82    
# Line 81  class views_handler_field_node_new_comme Line 87  class views_handler_field_node_new_comme
87        $node->type = $values->{$this->aliases['type']};        $node->type = $values->{$this->aliases['type']};
88        $this->options['alter']['make_link'] = TRUE;        $this->options['alter']['make_link'] = TRUE;
89        $this->options['alter']['path'] = 'node/' . $node->nid;        $this->options['alter']['path'] = 'node/' . $node->nid;
90        $this->options['alter']['query'] = comment_new_page_count($values->node_comment_statistics_comment_count, $values->node_new_comments, $node);        $this->options['alter']['query'] = comment_new_page_count($values->{$this->field_alias}, $values->node_new_comments, $node);
91        $this->options['alter']['fragment'] = 'new';        $this->options['alter']['fragment'] = 'new';
92      }      }
93    

Legend:
Removed from v.1.7.4.1  
changed lines
  Added in v.1.7.4.2

  ViewVC Help
Powered by ViewVC 1.1.2