From 476718aa43c3139f19a31f89356a21ff8e83fc74 Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Sun, 4 Mar 2001 04:17:02 +0000 Subject: Viewtopic mostly done. Need private forum stuff, pagination, and some SQL tweaks git-svn-id: file:///svn/phpbb/trunk@81 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 2 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index b4278d1182..fba5d0352a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1,6 +1,6 @@ sql_query($sql)) +{ + error_die($db, QUERY_ERROR); +} + +// +// Add checking for private forums here +// + +if(!$total_rows = $db->sql_numrows($result)) +{ + error_die($db, GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again."); +} + +$forum_row = $db->sql_fetchrowset($result); +for($x = 0; $x < $total_rows; $x++) +{ + $moderators[] = array("user_id" => $forum_row[$x]["user_id"], + "username" => $forum_row[$x]["username"]); + if($userdata["user_id"] == $forum_row[$x]["user_id"]) + { + $is_moderator = 1; + } +} + +if(!isset($start)) +{ + $start = 0; +} +$sql = "SELECT t.topic_title, t.topic_status, f.forum_name + FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f + WHERE t.topic_id = '$topic_id' AND f.forum_id = t.forum_id"; + +if(!$result = $db->sql_query($sql)) +{ + error_die($db, QUERY_ERROR); +} +if(!$topic_info = $db->sql_fetchrowset($result)) +{ + error_die($db, GENERAL_ERROR, "Could not get topic data
$sql"); +} +$forum_name = stripslashes($topic_info[0]["forum_name"]); +$topic_title = stripslashes($topic_info[0]["topic_title"]); +$pagetype = "viewtopic"; +$page_title = "View Topic - $topic_title"; +include('page_header.'.$phpEx); + +$sql = "SELECT u.*, r.rank_title, r.rank_image, + p.post_time, p.post_id, pt.post_text + FROM ".POSTS_TABLE." p + LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id + LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id OR (u.user_posts > r.rank_min AND u.user_posts < r.rank_max)) + LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id + WHERE p.topic_id = '$topic_id' + ORDER BY p.post_time ASC LIMIT $start, $posts_per_page"; + +if(!$result = $db->sql_query($sql)) +{ + error_die($db, QUERY_ERROR); +} +if(!$total_posts = $db->sql_numrows($result)) +{ + error_die($db, GENERAL_ERROR, "Error getting post data."); +} +$postrow = $db->sql_fetchrowset($result); + +$template->set_block("body", "postrow", "posts"); + +for($x = 0; $x < $total_posts; $x++) +{ + $poster = stripslashes($postrow[$x]["username"]); + $poster_id = $postrow[$x]["user_id"]; + $poster_rank = stripslashes($postrow[$x]["rank_title"]); + $rank_image = ($postrow[$x]["rank_image"]) ? "" : ""; + $post_date = date($date_format, $postrow[$x]["post_time"]); + + $poster_posts = $postrow[$x]["user_posts"]; + $poster_from = ($postrow[$x]["user_from"]) ? "$l_from: ".$postrow[$x]["user_from"] : ""; + $poster_joined = $postrow[$x]["user_regdate"]; + + $profile_img = "\"$l_profileof"; + $email_img = ($postrow[$x]["user_viewemail"] == 1) ? "\"$l_email" : ""; + $www_img = ($postrow[$x]["user_website"]) ? "\"$l_viewsite\"" : ""; + if($postrow[$x]["user_icq"]) + { + + $icq_status_img = "\"$l_icqstatus\""; + $icq_add_img = "\"$l_icq\""; + } + else + { + $icq_status_img = ""; + $icq_add_img = ""; + } + $aim_img = ($postrow[$x]["user_aim"]) ? "" : ""; + $msn_img = ($postrow[$x]["user_msn"]) ? "" : ""; + $yim_img = ($postrow[$x]["user_yim"]) ? "" : ""; + + $edit_img = "\"$l_editdelete\""; + $quote_img = "\"$l_replyquote\""; + $pmsg_img = "\"$l_sendpsmg\""; + if($is_moderator) + { + $ip_img = "\"$l_viewip\""; + $delpost_img = "\"$l_delete\""; + } + + $message = stripslashes($postrow[$x]["post_text"]); + if(!$allow_html) + { + $message = strip_tags($message); + } + if($allow_bbcode) + { + // do bbcode stuff here + } + + if(!($x % 2)) + { + $color = "#DDDDDD"; + } + else + { + $color = "#CCCCCC"; + } + + $message = eregi_replace("\[addsig]$", "
_________________
" . stripslashes($postrow[$x]["user_sig"]), $message); + $template->set_var(array("TOPIC_TITLE" => $topic_title, + "L_POSTED" => $l_posted, + "L_JOINED" => $l_joined, + "POSTER_NAME" => $poster, + "POSTER_RANK" => $poster_rank, + "RANK_IMAGE" => $rank_image, + "ROW_COLOR" => $color, + "POSTER_JOINED" => $poster_joined, + "POSTER_POSTS" => $poster_posts, + "POSTER_FROM" => $poster_from, + "POST_DATE" => $post_date, + "MESSAGE" => $message, + "PROFILE_IMG" => $profile_img, + "EMAIL_IMG" => $email_img, + "WWW_IMG" => $www_img, + "ICQ_STATUS_IMG" => $icq_status_img, + "ICQ_ADD_IMG" => $icq_add_img, + "AIM_IMG" => $aim_img, + "MSN_IMG" => $msn_img, + "YIM_IMG" => $yim_img, + "EDIT_IMG" => $edit_img, + "QUOTE_IMG" => $quote_img, + "PMSG_IMG" => $pmsg_img, + "IP_IMG" => $ip_img, + "DELPOST_IMG" => $delpost_img)); + $template->parse("posts", "postrow", true); +} +$template->pparse("output", array("posts", "body")); +include('page_tail.'.$phpEx); + + + ?> -- cgit v1.2.1