function advanced_forum_unread_comments_in_forum in Advanced Forum 6
Same name and namespace in other branches
- 5 advanced_forum.module \advanced_forum_unread_comments_in_forum()
Calculates the number of unread replies for each forum and returns the count for the requested forum.
1 call to advanced_forum_unread_comments_in_forum()
- advanced_forum_preprocess_forum_list in ./
advanced_forum.module - Preprocesses template variables for the forum list template.
File
- ./
advanced_forum.module, line 1723 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_unread_comments_in_forum($tid, $uid) {
static $result_cache = NULL;
if (is_NULL($result_cache)) {
$result_cache = array();
$sql = "SELECT COUNT(c.cid) AS count, f.tid\n FROM {comments} c\n INNER JOIN {forum} f ON c.nid = f.nid\n INNER JOIN {node} n ON f.vid = n.vid\n LEFT JOIN {history} h ON c.nid = h.nid AND h.uid = %d\n WHERE c.status = 0 AND c.timestamp > %d AND (c.timestamp > h.timestamp OR h.timestamp IS NULL)\n GROUP BY f.tid";
$sql = db_rewrite_sql($sql, 'c', 'cid');
$result = db_query($sql, $uid, NODE_NEW_LIMIT);
while ($row = db_fetch_array($result)) {
$result_cache[$row['tid']] = $row['count'];
}
}
return isset($result_cache[$tid]) ? $result_cache[$tid] : 0;
}