function advanced_forum_statistics_replies in Advanced Forum 6.2
Same name and namespace in other branches
- 7.2 advanced_forum.module \advanced_forum_statistics_replies()
Counts total amount of replies. Initial posts are added to this total in the calling function.
Parameters
$refresh: TRUE if the stored count should be updated.
Return value
Total number of replies in the forum.
3 calls to advanced_forum_statistics_replies()
- advanced_forum_comment in ./
advanced_forum.module - Implementation of hook_comment().
- advanced_forum_nodeapi in ./
advanced_forum.module - Implementation of hook_nodeapi().
- advanced_forum_preprocess_advanced_forum_statistics in includes/
theme.inc - Preprocesses template variables for the forum statistics template.
File
- ./
advanced_forum.module, line 737 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_statistics_replies($refresh = FALSE) {
// Check for cached total.
$total_replies = variable_get('advanced_forum_stats_replies', 0);
// If there's no cache or we need to refresh the cache
if ($refresh || $total_replies == 0) {
if (module_exists('nodecomment')) {
$total_replies = db_result(db_query('SELECT COUNT(cid) FROM {node_comments} c INNER JOIN {forum} f ON (f.nid = c.nid)'));
}
else {
$total_replies = db_result(db_query('SELECT SUM(s.comment_count) FROM {node_comment_statistics} s INNER JOIN {forum} f ON (s.nid = f.nid)'));
}
variable_set('advanced_forum_stats_replies', $total_replies);
}
return $total_replies;
}