function heartbeat_get_node_comments in Heartbeat 7
Same name and namespace in other branches
- 6.4 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 827 - Heartbeat comments for activity.
Code
function heartbeat_get_node_comments($node, $all = FALSE, $uaid = NULL) {
global $user;
$comments = array();
$count = 0;
if (user_access('access comments')) {
// Pre-process variables.
$nid = $node->nid;
$plugin = heartbeat_plugins_get_plugin('activitycomments')
->getPlugin();
if ($plugin) {
$comments_per_page = $plugin->HEARTBEAT_NODE_COMMENTS_PER_PAGE;
$query = "SELECT c.*, fdcb.comment_body_value AS 'comment', fdcb.comment_body_format AS 'format',\n\t u.uid, u.name AS registered_name, u.signature,\n\t u.signature_format, u.picture, u.data, c.thread, c.status\n\t FROM {comment} c\n\t INNER JOIN {field_data_comment_body} fdcb on fdcb.entity_id = c.cid\n\t INNER JOIN {users} u ON c.uid = u.uid\n\t WHERE c.nid = :nid AND c.status = :status ORDER BY c.cid DESC";
$query_args = array(
':nid' => $nid,
':status' => COMMENT_PUBLISHED,
);
if ($all) {
$result = db_query($query, $query_args);
}
else {
$result = db_query_range($query, 0, $comments_per_page, $query_args);
}
//drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
foreach ($result as $comment) {
$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;
$comment->uaid = $uaid;
$comments[] = $comment;
}
}
}
return $comments;
}