| 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 |
| 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 |
|
|
| 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 |
|
|