function comment_num_new
7.x comment.module | comment_num_new($nid, $timestamp = 0) |
6.x comment.module | comment_num_new($nid, $timestamp = 0) |
Get number of new comments for current user and specified node.
Parameters
$nid: Node-id to count comments for.
$timestamp: Time to count from (defaults to time of last user access to node).
Return value
The result or FALSE on error.
4 calls to comment_num_new()
- comment_node_view in drupal-7.x/
modules/ comment/ comment.module - Implements hook_node_view().
- comment_tokens in drupal-7.x/
modules/ comment/ comment.tokens.inc - Implements hook_tokens().
- forum_get_topics in drupal-7.x/
modules/ forum/ forum.module - Gets all the topics in a forum.
- tracker_page in drupal-7.x/
modules/ tracker/ tracker.pages.inc - Page callback: prints a listing of active nodes on the site.
2 string references to 'comment_num_new'
- comment_schema in drupal-7.x/
modules/ comment/ comment.install - Implements hook_schema().
- comment_update_7003 in drupal-7.x/
modules/ comment/ comment.install - Split {comment}.timestamp into 'created' and 'changed', improve indexing on {comment}.
File
- drupal-7.x/
modules/ comment/ comment.module, line 1729 - Enables users to comment on published content.
Code
function comment_num_new($nid, $timestamp = 0) {
global $user;
if ($user->uid) {
// Retrieve the timestamp at which the current user last viewed this node.
if (!$timestamp) {
$timestamp = node_last_viewed($nid);
}
$timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT);
// Use the timestamp to retrieve the number of new comments.
return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array(
':nid' => $nid,
':timestamp' => $timestamp,
':status' => COMMENT_PUBLISHED,
))->fetchField();
}
else {
return FALSE;
}
}