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; }
Show subjects for submessages in this thread show_submessages() is recursive */ if ($thread['has_followups'] > 0) { $ret_val .= show_submessages($msg_arr, $thread['msg_id'], 1); } $i++; } $ret_val .= '</TABLE>'; } else { if ($style == 'flat') { $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.group_forum_id " . "FROM forum,users " . "WHERE forum.group_forum_id='{$forum_id}' AND users.user_id=forum.posted_by " . "ORDER BY forum.msg_id DESC"; $result = db_query($sql, $max_rows + 1, $offset); $i = 0; while (($row = db_fetch_array($result)) && $i < $max_rows) { $ret_val .= forum_show_a_nested_message($row) . '<BR>'; $i++; } } else { /* This is the view that is most similar to the "Ultimate BB view" */ $sql = "SELECT f.most_recent_date,users.user_name,users.realname,users.user_id,f.msg_id,f.subject,f.thread_id," . "(count(f2.thread_id)-1) AS followups,max(f2.date) AS recent " . "FROM forum f, forum f2, users " . "WHERE f.group_forum_id='{$forum_id}' " . "AND f.is_followup_to=0 " . "AND users.user_id=f.posted_by " . "AND f.thread_id=f2.thread_id " . "GROUP BY f.most_recent_date,users.user_name,users.realname,users.user_id,f.msg_id,f.subject,f.thread_id " . "ORDER BY f.most_recent_date DESC"; $result = db_query($sql, $max_rows + 1, $offset); //echo db_error(); //echo "In Ultimate View"; $title_arr = array(); $title_arr[] = 'Topic'; $title_arr[] = 'Topic Starter'; $title_arr[] = 'Replies'; $title_arr[] = 'Last Post';