From db8652122c2b0705eed8e4fde76baccbe497319a Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 31 Jul 2001 18:37:25 +0000 Subject: More compliance updates + select previous posts in viewtopic git-svn-id: file:///svn/phpbb/trunk@770 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 146 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 113 insertions(+), 33 deletions(-) (limited to 'phpBB/viewtopic.php') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index eb8269466e..3ca7068f68 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -133,7 +133,7 @@ $join_sql_table = (!isset($post_id)) ? "" : "" . POSTS_TABLE . " p, " . POSTS_TA $join_sql = (!isset($post_id)) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id"; $count_sql = (!isset($post_id)) ? "" : ", COUNT(p2.post_id) AS prev_posts"; -$order_sql = (!isset($post_id)) ? "" : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_votecreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC"; +$order_sql = (!isset($post_id)) ? "" : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_votecreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC"; $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_votecreate, f.auth_vote, f.auth_attachments" . $count_sql . " FROM $join_sql_table " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f @@ -158,7 +158,6 @@ $forum_id = $forum_row['forum_id']; $topic_title = stripslashes($forum_row['topic_title']); $topic_id = $forum_row['topic_id']; $topic_time = $forum_row['topic_time']; -$total_replies = $forum_row['topic_replies'] + 1; if(!empty($post_id)) { @@ -192,6 +191,76 @@ if(!$is_auth['auth_view'] || !$is_auth['auth_read']) // End auth check // +// +// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed +// then get it's value, find the number of topics with dates newer than it (to properly +// handle pagination) and alter the main query +// +$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364); +$previous_days_text = array($lang['All_Posts'], "1 " . $lang['Day'], "7 " . $lang['Days'], "2 " . $lang['Weeks'], "1 " . $lang['Month'], "3 ". $lang['Months'], "6 " . $lang['Months'], "1 " . $lang['Year']); + +if(!empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays'])) +{ + $post_days = (!empty($HTTP_POST_VARS['postdays'])) ? $HTTP_POST_VARS['postdays'] : $HTTP_GET_VARS['postdays']; + $min_post_time = time() - ($post_days * 86400); + + $sql = "SELECT COUNT(post_id) AS num_posts + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_id + AND post_time >= $min_post_time"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain limited topics count information", "", __LINE__, __FILE__, $sql); + } + list($total_replies) = $db->sql_fetchrow($result); + + $limit_posts_time = "AND p.post_time >= $min_post_time "; + + if(!empty($HTTP_POST_VARS['postdays'])) + { + $start = 0; + } +} +else +{ + $total_replies = $forum_row['topic_replies'] + 1; + + $limit_posts_time = ""; + $post_days = 0; +} + +$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_time_order = "ASC"; +} + +$select_post_order = ""; + // // Go ahead and pull all data for this topic // @@ -199,8 +268,9 @@ $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id - AND p.post_id = pt.post_id - ORDER BY p.post_time ASC + AND p.post_id = pt.post_id + $limit_posts_time + ORDER BY p.post_time $post_time_order LIMIT $start, ".$board_config['posts_per_page']; if(!$result = $db->sql_query($sql)) { @@ -236,6 +306,9 @@ $template->set_filenames(array( $jumpbox = make_jumpbox(); $template->assign_vars(array( + "L_GO" => $lang['Go'], + "L_JUMP_TO" => $lang['Jump_to'], + "L_SELECT_FORUM" => $lang['Select_forum'], "JUMPBOX_LIST" => $jumpbox, "SELECT_NAME" => POST_FORUM_URL) ); @@ -246,8 +319,13 @@ $template->assign_vars(array( "FORUM_NAME" => $forum_name, "TOPIC_ID" => $topic_id, "TOPIC_TITLE" => $topic_title, - "POST_FORUM_URL" => POST_FORUM_URL, - "USERS_BROWSING" => $users_browsing) + + "L_DISPLAY_POSTS" => $lang['Display_posts'], + + "S_SELECT_POST_DAYS" => $select_post_days, + "S_SELECT_POST_ORDER" => $select_post_order, + "S_POST_DAYS_ACTION" => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$start")) + ); // // End header @@ -257,13 +335,13 @@ $template->assign_vars(array( // Post, reply and other URL generation for // templating vars // -$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"); -$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id"); +$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"); +$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id"); $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"); -$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous"); -$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next"); +$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous"); +$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next"); $reply_img = ($forum_row['forum_status'] == FORUM_LOCKED || $forum_row['topic_status'] == TOPIC_LOCKED) ? $images['reply_locked'] : $images['reply_new']; $post_img = ($forum_row['forum_status'] == FORUM_LOCKED) ? $images['post_locked'] : $images['post_new']; @@ -318,7 +396,7 @@ for($i = 0; $i < $total_posts; $i++) if($postrow[$i]['user_avatar'] != "" && $poster_id != ANONYMOUS) { - $poster_avatar = (strstr("http", $postrow[$i]['user_avatar']) && $board_config['allow_avatar_remote']) ? "

" : "

"; + $poster_avatar = (strstr("http", $postrow[$i]['user_avatar']) && $board_config['allow_avatar_remote']) ? "

" : "
\"\"
"; } else { @@ -367,19 +445,19 @@ for($i = 0; $i < $total_posts; $i++) if($poster_id != ANONYMOUS) { - $profile_img = "\"""; + $profile_img = "\"""; - $pm_img = "\"""; + $pm_img = "\"""; - $email_img = ($postrow[$i]['user_viewemail'] == 1) ? "\""" : ""; + $email_img = ($postrow[$i]['user_viewemail'] == 1) ? "\""" : ""; - $www_img = ($postrow[$i]['user_website']) ? "\""" : ""; + $www_img = ($postrow[$i]['user_website']) ? "\""" : ""; if($postrow[$i]['user_icq']) { - $icq_status_img = ""; + $icq_status_img = ""; - $icq_add_img = "\"""; + $icq_add_img = "\"""; } else { @@ -387,11 +465,11 @@ for($i = 0; $i < $total_posts; $i++) $icq_add_img = ""; } - $aim_img = ($postrow[$i]['user_aim']) ? "\""" : ""; + $aim_img = ($postrow[$i]['user_aim']) ? "\""" : ""; - $msn_img = ($postrow[$i]['user_msnm']) ? "\""" : ""; + $msn_img = ($postrow[$i]['user_msnm']) ? "\""" : ""; - $yim_img = ($postrow[$i]['user_yim']) ? "\""" : ""; + $yim_img = ($postrow[$i]['user_yim']) ? "\""" : ""; } else { @@ -406,17 +484,17 @@ for($i = 0; $i < $total_posts; $i++) $yim_img = ""; } - $search_img = ""; + $search_img = ""; - $edit_img = "\"""; + $edit_img = "\"""; - $quote_img = "\"""; + $quote_img = "\"""; if( $is_auth['auth_mod'] ) { - $ip_img = "\"""; + $ip_img = "\"""; - $delpost_img = "\"""; + $delpost_img = "\"""; } $post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : $topic_title; @@ -474,13 +552,15 @@ for($i = 0; $i < $total_posts; $i++) // Again this will be handled by the templating // code at some point // - $color = (!($i % 2)) ? "#" . $theme['td_color1'] : "#" . $theme['td_color2']; + $row_color = ( !($i % 2) ) ? "#" . $theme['td_color1'] : "#" . $theme['td_color2']; + $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("postrow", array( + "ROW_COLOR" => $row_color, + "ROW_CLASS" => $row_class, "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, @@ -521,23 +601,23 @@ if( $is_auth['auth_mod'] ) { $s_auth_can .= $lang['You'] . " " . $lang['can'] . " " . $lang['moderate_forum'] . "
"; - $topic_mod = "\"" "; + $topic_mod = "\"" "; - $topic_mod .= "\"" "; + $topic_mod .= "\"" "; if($forum_row['topic_status'] == TOPIC_UNLOCKED) { - $topic_mod .= "\"" "; + $topic_mod .= "\"" "; } else { - $topic_mod .= "\"" "; + $topic_mod .= "\"" "; } - $topic_mod .= "\"" "; + $topic_mod .= "\"" "; } $template->assign_vars(array( - "PAGINATION" => generate_pagination("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id", $total_replies, $board_config['posts_per_page'], $start), + "PAGINATION" => generate_pagination("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start), "ON_PAGE" => ( floor( $start / $board_config['posts_per_page'] ) + 1 ), "TOTAL_PAGES" => ceil( $total_replies / $board_config['posts_per_page'] ), -- cgit v1.2.1