function _forum_new in Drupal 6
Same name and namespace in other branches
- 4 modules/forum.module \_forum_new()
- 5 modules/forum/forum.module \_forum_new()
Finds the first unread node for a given forum.
File
- modules/
forum/ forum.module, line 635 - Enable threaded discussions about general topics.
Code
function _forum_new($tid) {
global $user;
$sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND h.nid IS NULL AND n.created > %d ORDER BY created";
$sql = db_rewrite_sql($sql);
$nid = db_result(db_query_range($sql, $user->uid, $tid, NODE_NEW_LIMIT, 0, 1));
return $nid ? $nid : 0;
}