function _forum_new in Drupal 4
Same name and namespace in other branches
- 5 modules/forum/forum.module \_forum_new()
- 6 modules/forum/forum.module \_forum_new()
Finds the first unread node for a given forum.
File
- modules/
forum.module, line 813 - 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 n.type = 'forum' 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;
}