From 70968cb0250437902dbb3423bf2b62df3cab183b Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 17 Jul 2002 20:57:31 +0000 Subject: [PATCH] More re-arrangements git-svn-id: file:///svn/phpbb/trunk@2714 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 1018 +++++++++++++++++++++---------------------- 1 file changed, 489 insertions(+), 529 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0a137f9010..330695af87 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -145,32 +145,28 @@ if ( $userdata['user_id'] != ANONYMOUS && isset($HTTP_POST_VARS['rating']) ) $join_sql_table = ( !$post_id ) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 '; $join_sql = ( !$post_id ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id"; $count_sql = ( !$post_id ) ? '' : ", COUNT(p2.post_id) AS prev_posts"; -$order_sql = ( !$post_id ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id ORDER BY p.post_id ASC"; +$order_sql = ( !$post_id ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.default_style ORDER BY p.post_id ASC"; -$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id " . $count_sql . " +$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.default_style" . $count_sql . " FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " WHERE $join_sql - AND f.forum_id = t.forum_id + AND f.forum_id = t.forum_id $order_sql"; $result = $db->sql_query($sql); -if ( !($forum_data = $db->sql_fetchrow($result)) ) +if ( !(extract($db->sql_fetchrow($result))) ) { message_die(MESSAGE, 'Topic_post_not_exist'); } - // // Configure style, language, etc. // -$userdata['user_style'] = ( $forum_data['forum_style'] ) ? $forum_data['user_style'] : $userdata['user_style']; +$userdata['user_style'] = ( $default_style ) ? $default_style : $userdata['user_style']; $session->configure($userdata); -$forum_id = $forum_data['forum_id']; - $acl = new auth('forum', $userdata, $forum_id); - // // Start auth check // @@ -193,14 +189,9 @@ if ( !$acl->get_acl($forum_id, 'forum', 'read') ) // End auth check // -$forum_name = $forum_data['forum_name']; -$topic_title = $forum_data['topic_title']; -$topic_id = $forum_data['topic_id']; -$topic_time = $forum_data['topic_time']; - if ( !empty($post_id) ) { - $start = floor(($forum_data['prev_posts'] - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page']; + $start = floor(($prev_posts - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page']; } $s_watching_topic = ''; @@ -229,12 +220,12 @@ if ( isset($HTTP_POST_VARS['sort']) ) $result = $db->sql_query($sql); $start = 0; - $total_replies = ( $row = $db->sql_fetchrow($result) ) ? $row['num_posts'] : 0; + $topic_replies = ( $row = $db->sql_fetchrow($result) ) ? $row['num_posts'] : 0; $limit_posts_time = "AND p.post_time >= $min_post_time "; } else { - $total_replies = ( $forum_data['topic_replies'] ) ? $forum_data['topic_replies'] + 1 : 1; + $topic_replies++; } $sort_key = ( isset($HTTP_POST_VARS['sort_key']) ) ? $HTTP_POST_VARS['sort_key'] : $HTTP_GET_VARS['sort_key']; @@ -242,7 +233,7 @@ if ( isset($HTTP_POST_VARS['sort']) ) } else { - $total_replies = $forum_data['topic_replies'] + 1; + $topic_replies++; $limit_posts_time = ''; $sort_days = 0; @@ -280,55 +271,6 @@ for($i = 0; $i < count($previous_days); $i++) } $select_post_days .= ''; -// -// Decide how to order the post display -// -if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) ) -{ - $post_order = (!empty($HTTP_POST_VARS['postorder'])) ? $HTTP_POST_VARS['postorder'] : $HTTP_GET_VARS['postorder']; - $post_time_order = ( $post_order == 'asc' ) ? 'ASC' : 'DESC'; -} -else -{ - $post_order = 'asc'; - $post_time_order = 'ASC'; -} - -$select_post_order = ''; - -// -// Go ahead and pull all data for this topic -// -$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid - FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt - WHERE p.topic_id = $topic_id - AND p.post_approved = " . TRUE . " - $limit_posts_time - AND pt.post_id = p.post_id - AND u.user_id = p.poster_id - ORDER BY $sort_order - LIMIT $start, " . $board_config['posts_per_page']; -$result = $db->sql_query($sql); - -if ( $row = $db->sql_fetchrow($result) ) -{ - $postrow = array(); - do - { - $postrow[] = $row; - } - while ( $row = $db->sql_fetchrow($result) ); - $db->sql_freeresult($result); - - $total_posts = count($postrow); -} -else -{ - message_die(MESSAGE, $lang['No_posts_topic']); -} - $sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_special, rank_min"; @@ -406,7 +348,7 @@ $s_forum_rules = ''; get_forum_rules('topic', $s_forum_rules, $forum_id); $topic_mod = ''; -$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'lock') ) ? ( ( $forum_data['topic_status'] == TOPIC_UNLOCKED ) ? '' : '' ) : ''; +$topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'lock') ) ? ( ( $topic_status == TOPIC_UNLOCKED ) ? '' : '' ) : ''; $topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'delete') ) ? '' : ''; $topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'move') ) ? '' : ''; $topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'split') ) ? '' : ''; @@ -415,7 +357,7 @@ $topic_mod .= ( $acl->get_acl($forum_id, 'mod', 'merge') ) ? '