function forum_show_nested_messages($thread_id, $msg_id) { global $total_rows, $Language; $sql = "SELECT user.user_name,forum.has_followups,user.realname,user.user_id,forum.msg_id,forum.group_forum_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to, forum_group_list.group_id " . "FROM forum,user,forum_group_list WHERE forum.thread_id=" . db_ei($thread_id) . " AND user.user_id=forum.posted_by AND forum.is_followup_to=" . db_ei($msg_id) . " AND forum_group_list.group_forum_id = forum.group_forum_id " . "ORDER BY forum.date ASC;"; $result = db_query($sql); $rows = db_numrows($result); $ret_val = ''; if ($result && $rows > 0) { $ret_val .= ' <UL>'; /* iterate and show the messages in this result for each message, recurse to show any submessages */ for ($i = 0; $i < $rows; $i++) { // increment the global total count $total_rows++; // show the actual nested message $ret_val .= forum_show_a_nested_message($result, $i) . '<P>'; if (db_result($result, $i, 'has_followups') > 0) { // Call yourself if there are followups $ret_val .= forum_show_nested_messages($thread_id, db_result($result, $i, 'msg_id')); } } $ret_val .= ' </UL>'; } return $ret_val; }
function forum_show_nested_messages($msg_arr, $msg_id) { global $total_rows, $sys_datefmt; $rows = count($msg_arr[$msg_id]); $ret_val = ''; if ($msg_arr[$msg_id] && $rows > 0) { $ret_val .= ' <UL>'; /* iterate and show the messages in this result for each message, recurse to show any submessages */ for ($i = 0; $i < $rows; $i++) { // increment the global total count $total_rows++; // show the actual nested message $ret_val .= forum_show_a_nested_message($msg_arr[$msg_id][$i]) . '<P>'; if ($msg_arr[$msg_id][$i]['has_followups'] > 0) { // Call yourself if there are followups $ret_val .= forum_show_nested_messages($msg_arr, $msg_arr[$msg_id][$i]['msg_id']); } } $ret_val .= ' </UL>'; } else { //$ret_val .= "<P><B>no messages actually follow up to $msg_id</B>"; } return $ret_val; }
//echo "<br>Max Rows: $max_rows\n"; if ($rows > $max_rows) { $rows = $max_rows; } $i = 0; while ($i < $rows && $total_rows < $max_rows) { $thread = $msg_arr["0"][$i]; $total_rows++; /* New slashdot-inspired nested threads, showing all submessages and bodies */ $ret_val .= forum_show_a_nested_message($thread) . '<BR>'; if ($thread['has_followups'] > 0) { //show submessages for this message $ret_val .= forum_show_nested_messages($msg_arr, $thread['msg_id']); } $i++; } } else { if ($style == 'threaded') { $sql = "SELECT users.user_name,users.realname,forum.has_followups, " . "users.user_id,forum.msg_id,forum.subject,forum.thread_id, " . "forum.body,forum.date,forum.is_followup_to,forum.most_recent_date,forum.group_forum_id " . "FROM forum,users " . "WHERE forum.group_forum_id='{$forum_id}' AND users.user_id=forum.posted_by " . "ORDER BY forum.most_recent_date DESC"; $result = db_query($sql, $max_rows + 25, $offset); while ($row = db_fetch_array($result)) { $msg_arr["{$row['is_followup_to']}"][] = $row; } $title_arr = array(); $title_arr[] = 'Thread'; $title_arr[] = 'Author'; $title_arr[] = 'Date'; $ret_val .= html_build_list_table_top($title_arr);