function advanced_forum_last_post_in_topic in Advanced Forum 7.2
Same name and namespace in other branches
- 5 advanced_forum.module \advanced_forum_last_post_in_topic()
- 6.2 advanced_forum.module \advanced_forum_last_post_in_topic()
- 6 advanced_forum.module \advanced_forum_last_post_in_topic()
Get the comment id of the last post in a topic.
Parameters
int $nid: Node id.
Return value
int cid of last post.
1 call to advanced_forum_last_post_in_topic()
- advanced_forum_last_post_link in ./
advanced_forum.module - Get a link to the last post in a topic.
File
- ./
advanced_forum.module, line 1050 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_last_post_in_topic($nid) {
// $nid is empty if new topic in preview.
if (empty($nid)) {
return NULL;
}
$node = node_load($nid);
// Comment module version.
$query = 'SELECT c.cid
FROM {comment} c
WHERE c.nid = :nid AND c.status = :status
ORDER BY c.cid DESC';
$result = db_query_range($query, 0, 1, array(
':nid' => $nid,
':status' => COMMENT_PUBLISHED,
))
->fetchField();
return $result;
}