*/ if (get_forum_saved_date($forum_id) < db_result($result, $i, 'date')) { $ret_val .= '<B>'; } /* show the subject and poster */ $poster = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); $ret_val .= db_result($result, $i, 'subject') . '</A></TD>' . '<TD>' . UserHelper::instance()->getLinkOnUser($poster) . '</TD>' . '<TD>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'date')) . '</TD></TR>'; /* Show subjects for submessages in this thread show_submessages() is recursive */ if ($style == 'threaded') { if (db_result($result, $i, 'has_followups') > 0) { $ret_val .= show_submessages(db_result($result, $i, 'thread_id'), db_result($result, $i, 'msg_id'), 1, 0); } } } } $i++; } /* This code puts the nice next/prev. */ if ($offset != 0 || db_numrows($result) > $i) { $ret_val .= '<TABLE WIDTH="100%" BORDER="0">'; $ret_val .= '<TR class="threadbody"><TD ALIGN="LEFT" WIDTH="50%">'; if ($offset != 0) { $ret_val .= '<B><span> <A HREF="javascript:history.back()">
function show_submessages($msg_arr, $msg_id, $level) { /* Recursive. Selects this message's id in this thread, then checks if any messages are nested underneath it. If there are, it calls itself, incrementing $level $level is used for indentation of the threads. */ global $total_rows, $sys_datefmt, $forum_id, $current_message; $rows = count($msg_arr[$msg_id]); if ($rows > 0) { for ($i = 0; $i < $rows; $i++) { /* Is this row's background shaded or not? */ $total_rows++; $ret_val .= ' <TR BGCOLOR="' . html_get_alt_row_color($total_rows) . '"><TD NOWRAP>'; /* How far should it indent? */ for ($i2 = 0; $i2 < $level; $i2++) { $ret_val .= ' '; } /* If it this is the message being displayed, don't show a link to it */ $ret_val .= ($current_message != $msg_arr[$msg_id][$i]['msg_id'] ? '<A HREF="/forum/message.php?msg_id=' . $msg_arr[$msg_id][$i]['msg_id'] . '">' : '') . html_image("images/msg.gif", "10", "12", array("BORDER" => "0")); /* See if this message is new or not */ if (get_forum_saved_date($forum_id) < $msg_arr[$msg_id][$i]['date']) { $ret_val .= '<B>'; } $ret_val .= ' ' . $msg_arr[$msg_id][$i]['subject'] . '</A></TD>' . '<TD>' . $msg_arr[$msg_id][$i]['user_name'] . '</TD>' . '<TD>' . date($sys_datefmt, $msg_arr[$msg_id][$i]['date']) . '</TD></TR>'; if ($msg_arr[$msg_id][$i]['has_followups'] > 0) { /* Call yourself, incrementing the level */ $ret_val .= show_submessages($msg_arr, $msg_arr[$msg_id][$i]['msg_id'], $level + 1); } } } return $ret_val; }
function show_submessages($thread_id, $msg_id, $level, $et = 0) { /* Recursive. Selects this message's id in this thread, then checks if any messages are nested underneath it. If there are, it calls itself, incrementing $level $level is used for indentation of the threads. */ global $total_rows, $forum_id, $current_message; $sql = "SELECT user.user_name,forum.has_followups,forum.msg_id,forum.subject,forum.thread_id,forum.body,forum.date,forum.is_followup_to " . "FROM forum,user WHERE forum.thread_id=" . db_ei($thread_id) . " AND user.user_id=forum.posted_by AND forum.is_followup_to=" . db_ei($msg_id) . " " . "ORDER BY forum.msg_id ASC;"; $result = db_query($sql); $rows = db_numrows($result); $ret_val = ''; if ($result && $rows > 0) { for ($i = 0; $i < $rows; $i++) { /* Is this row's background shaded or not? */ $total_rows++; $ret_val .= ' <TR class="' . util_get_alt_row_color($total_rows) . '"><TD NOWRAP>'; /* How far should it indent? */ for ($i2 = 0; $i2 < $level; $i2++) { $ret_val .= ' '; } /* If it this is the message being displayed, don't show a link to it */ $ret_val .= ($current_message != db_result($result, $i, 'msg_id') ? '<A HREF="/forum/message.php?msg_id=' . db_result($result, $i, 'msg_id') . '">' : '') . '<IMG SRC="' . util_get_image_theme("msg.png") . '" BORDER=0 HEIGHT=12 WIDTH=10> '; /* See if this message is new or not */ if (get_forum_saved_date($forum_id) < db_result($result, $i, 'date')) { $ret_val .= '<B>'; } $poster = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); $ret_val .= db_result($result, $i, 'subject') . '</A></TD>' . '<TD>' . UserHelper::instance()->getLinkOnUser($poster) . '</TD>' . '<TD>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $i, 'date')) . '</TD></TR>'; /* Show the body/message if requested */ if ($et == 1) { $ret_val .= ' <TR class="' . util_get_alt_row_color($total_rows) . '"><TD> </TD><TD COLSPAN=2>' . nl2br(db_result($result, $i, 'body')) . '</TD><TR>'; } if (db_result($result, $i, 'has_followups') > 0) { /* Call yourself, incrementing the level */ $ret_val .= show_submessages($thread_id, db_result($result, $i, 'msg_id'), $level + 1, $et); } } } return $ret_val; }
If so, highlite it in bold */ if (get_forum_saved_date($forum_id) < $thread['date']) { $ret_val .= '<B>'; } /* show the subject and poster */ $ret_val .= ' ' . $thread['subject'] . '</A></TD>' . '<TD>' . $thread['user_name'] . '</TD>' . '<TD>' . date($sys_datefmt, $thread['date']) . '</TD></TR>'; /* 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 { /*