function heartbeat_get_node_comments in Heartbeat 6.4
Same name and namespace in other branches
- 7 modules/heartbeat_comments/heartbeat_comments.module \heartbeat_get_node_comments()
Theme function to render comment(s) on a node
1 call to heartbeat_get_node_comments()
- heartbeat_get_reactions in modules/
heartbeat_comments/ heartbeat_comments.module - Function to fetch reactions on a heartbeat message.
File
- modules/
heartbeat_comments/ heartbeat_comments.module, line 790 - heartbeat_comments.module Heartbeat comments can come with two possible
Code
function heartbeat_get_node_comments($node, $all = FALSE) {
global $user;
$comments = array();
$count = 0;
if (user_access('access comments')) {
// Pre-process variables.
$nid = $node->nid;
$comments_per_page = HEARTBEAT_NODE_COMMENTS_PER_PAGE;
$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment,
c.format, c.timestamp, c.name, c.mail, c.homepage,
u.uid, u.name AS registered_name, u.signature,
u.signature_format, u.picture, u.data, c.thread, c.status
FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid
WHERE c.nid = %d AND c.status = %d';
$query_args = array(
$nid,
);
$query_args[] = COMMENT_PUBLISHED;
$query .= ' ORDER BY c.cid DESC';
$query = db_rewrite_sql($query, 'c', 'cid');
if ($all) {
$result = db_query($query, $query_args);
}
else {
$result = db_query_range($query, $query_args, 0, $comments_per_page);
}
//drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
while ($comment = db_fetch_object($result)) {
$comment = drupal_unpack($comment);
// Sanitize the comment messages.
$comment->comment = check_markup($comment->comment, $comment->format, FALSE);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$comment->depth = count(explode('.', $comment->thread)) - 1;
$comments[] = $comment;
}
}
return $comments;
}