|
From: Paul S. O. <ps...@us...> - 2002-02-02 18:03:49
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv29445
Modified Files:
posting.php viewforum.php
Log Message:
Introduce an additional DB field for first_topic_id ... RUN update_to_RC3 ONCE YOU'VE UPDATED
Index: posting.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/posting.php,v
retrieving revision 1.142
retrieving revision 1.143
diff -C2 -r1.142 -r1.143
*** posting.php 2002/01/28 18:47:41 1.142
--- posting.php 2002/02/02 18:03:44 1.143
***************
*** 419,431 ****
if( $post_id )
{
! $sql = "SELECT p2.post_id, t.topic_id, t.topic_status, t.topic_last_post_id, t.topic_vote, f.forum_id, f.forum_name, f.forum_status, f.forum_last_post_id
! FROM " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE p.post_id = $post_id
- AND p2.topic_id = p.topic_id
AND t.topic_id = p.topic_id
! AND f.forum_id = t.forum_id
! ORDER BY p2.post_time ASC
! LIMIT 1";
!
}
else
--- 419,427 ----
if( $post_id )
{
! $sql = "SELECT t.topic_id, t.topic_status, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, f.forum_id, f.forum_name, f.forum_status, f.forum_last_post_id
! FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE p.post_id = $post_id
AND t.topic_id = p.topic_id
! AND f.forum_id = t.forum_id";
}
else
***************
*** 453,457 ****
$topic_id = $check_row['topic_id'];
! $is_first_post_topic = ($check_row['post_id'] == $post_id) ? TRUE : 0;
$is_last_post_topic = ($check_row['topic_last_post_id'] == $post_id) ? TRUE : 0;
$is_last_post_forum = ($check_row['forum_last_post_id'] == $post_id) ? TRUE : 0;
--- 449,453 ----
$topic_id = $check_row['topic_id'];
! $is_first_post_topic = ($check_row['topic_first_post_id'] == $post_id) ? TRUE : 0;
$is_last_post_topic = ($check_row['topic_last_post_id'] == $post_id) ? TRUE : 0;
$is_last_post_forum = ($check_row['forum_last_post_id'] == $post_id) ? TRUE : 0;
***************
*** 932,937 ****
if( $db->sql_query($sql) )
{
$sql = "UPDATE " . TOPICS_TABLE . "
! SET topic_last_post_id = $new_post_id";
if($mode == "reply")
{
--- 928,934 ----
if( $db->sql_query($sql) )
{
+ $first_post_sql = ( $mode == "newtopic" ) ?", topic_first_post_id = $new_post_id" : "";
$sql = "UPDATE " . TOPICS_TABLE . "
! SET topic_last_post_id = $new_post_id" . $first_post_sql;
if($mode == "reply")
{
***************
*** 1437,1442 ****
// is update the forums table data as necessary
//
$sql = "UPDATE " . TOPICS_TABLE . "
! SET topic_replies = topic_replies - 1
WHERE topic_id = $topic_id";
--- 1434,1454 ----
// is update the forums table data as necessary
//
+ $first_post_sql = "";
+ if( $is_first_post_topic )
+ {
+ $sql = "SELECT MIN(post_id) AS first_post
+ FROM " . POSTS_TABLE . "
+ WHERE topic_id = $topic_id";
+ if($result = $db->sql_query($sql))
+ {
+ if( $row = $db->sql_fetchrow($result) )
+ {
+ $first_post_sql = ", topic_first_post_id = " . $row['first_post'];
+ }
+ }
+ }
+
$sql = "UPDATE " . TOPICS_TABLE . "
! SET topic_replies = topic_replies - 1" . $first_post_sql . "
WHERE topic_id = $topic_id";
Index: viewforum.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/viewforum.php,v
retrieving revision 1.124
retrieving revision 1.125
diff -C2 -r1.124 -r1.125
*** viewforum.php 2002/01/28 17:20:40 1.124
--- viewforum.php 2002/02/02 18:03:44 1.125
***************
*** 275,316 ****
$select_topic_days .= "</select>";
//
! // Grab all the basic data (all topics except announcements)
! // for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
! WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id
! AND t.topic_type <> " . POST_ANNOUNCE . "
! $limit_topics_time
! ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
! LIMIT $start, ".$board_config['topics_per_page'];
! if( !$t_result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
}
! $total_topics = $db->sql_numrows($t_result);
//
! // All announcement data, this keeps announcements
! // on each viewforum page ...
//
! $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
! FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
! WHERE t.forum_id IN ($forum_id, -1)
AND t.topic_poster = u.user_id
! AND p.post_id = t.topic_last_post_id
! AND p.poster_id = u2.user_id
! AND t.topic_type = " . POST_ANNOUNCE . "
! ORDER BY t.topic_last_post_id DESC ";
! if( !$ta_result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
}
- $total_announcements = $db->sql_numrows($ta_result);
//
// Total topics ...
--- 275,335 ----
$select_topic_days .= "</select>";
+
//
! // All announcement data, this keeps announcements
! // on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
! WHERE t.forum_id IN ($forum_id, -1)
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id
! AND t.topic_type = " . POST_ANNOUNCE . "
! ORDER BY t.topic_last_post_id DESC ";
! if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
+ }
+
+ $topic_rowset = array();
+ $total_announcements = 0;
+ while( $row = $db->sql_fetchrow($result) )
+ {
+ $topic_rowset[] = $row;
+ $total_announcements++;
}
!
! $db->sql_freeresult($result);
//
! // Grab all the basic data (all topics except announcements)
! // for this forum
//
! $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
! FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
! WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
! AND p.post_id = t.topic_first_post_id
! AND p2.post_id = t.topic_last_post_id
! AND u2.user_id = p2.poster_id
! AND t.topic_type <> " . POST_ANNOUNCE . "
! $limit_topics_time
! ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
! LIMIT $start, ".$board_config['topics_per_page'];
! if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
}
+ $total_topics = 0;
+ while( $row = $db->sql_fetchrow($result) )
+ {
+ $topic_rowset[] = $row;
+ $total_topics++;
+ }
+
+ $db->sql_freeresult($result);
+
//
// Total topics ...
***************
*** 350,358 ****
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"" . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
}
- else
- {
- $s_auth_mod_img = "";
- }
$template->set_filenames(array(
"body" => "viewforum_body.tpl",
--- 369,387 ----
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"" . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>");
}
+ //
+ // Mozilla navigation bar
+ //
+ $nav_links['up'] = array(
+ 'url' => append_sid("index.".$phpEx),
+ 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
+ );
+
+ //
+ // Dump out the page header and load viewforum template
+ //
+ $page_title = $lang['View_forum'] . " - " . $forum_row['forum_name'];
+ include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
$template->set_filenames(array(
"body" => "viewforum_body.tpl",
***************
*** 392,395 ****
--- 421,426 ----
"L_POST_NEW_TOPIC" => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'],
+ "S_AUTH_LIST" => $s_auth_can,
+
"U_MARK_READ" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&mark=topics"))
);
***************
*** 403,431 ****
if( $total_topics )
{
- //
- // First get announcements
- //
- while( $ta_row = $db->sql_fetchrow($ta_result) )
- {
- $topic_rowset[] = $ta_row;
- }
- //
- // Now get everything else
- //
- while( $t_row = $db->sql_fetchrow($t_result) )
- {
- $topic_rowset[] = $t_row;
- }
-
for($i = 0; $i < $total_topics; $i++)
{
! if( count($orig_word) )
! {
! $topic_title = preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']);
! }
! else
! {
! $topic_title = $topic_rowset[$i]['topic_title'];
! }
$topic_type = $topic_rowset[$i]['topic_type'];
--- 434,440 ----
if( $total_topics )
{
for($i = 0; $i < $total_topics; $i++)
{
! $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
$topic_type = $topic_rowset[$i]['topic_type'];
***************
*** 456,482 ****
{
$total_pages = ceil(($replies+1)/$board_config['posts_per_page']);
! $goto_page = " [ <img src=\"" . $images['icon_gotopost'] . "\" alt=\"" . $lang['Goto_page'] . "\" title=\"" . $lang['Goto_page'] . "\" />" . $lang['Goto_page'] . ": ";
$times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
{
! $goto_page .= "<a href=\"".append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . "\">$times</a>";
! if( $times == 1 && $total_pages > 4)
{
! $goto_page .= " ... ";
$times = $total_pages - 3;
! $j += ($total_pages-4) * $board_config['posts_per_page'];
}
! else if ($times < $total_pages)
{
! $goto_page .= ", ";
}
$times++;
}
! $goto_page .= " ] ";
}
else
{
! $goto_page = "";
}
--- 465,491 ----
{
$total_pages = ceil(($replies+1)/$board_config['posts_per_page']);
! $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
{
! $goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>';
! if( $times == 1 && $total_pages > 4 )
{
! $goto_page .= ' ... ';
$times = $total_pages - 3;
! $j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
}
! else if ( $times < $total_pages )
{
! $goto_page .= ', ';
}
$times++;
}
! $goto_page .= ' ] ';
}
else
{
! $goto_page = '';
}
***************
*** 486,491 ****
$topic_id = $topic_rowset[$i]['topic_moved_id'];
! $folder_image = "<img src=\"" . $images['folder'] . "\" alt=\"" . $lang['No_new_posts'] . "\" title=\"" . $lang['No_new_posts'] . "\" />";
! $newest_post_img = "";
}
else
--- 495,500 ----
$topic_id = $topic_rowset[$i]['topic_moved_id'];
! $folder_image = '<img src="' . $images['folder'] . '" alt="' . $lang['No_new_posts'] . '" title="' . $lang['No_new_posts'] . '" />';
! $newest_post_img = '';
}
else
***************
*** 555,561 ****
if( $unread_topics )
{
! $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
! $newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
else
--- 564,570 ----
if( $unread_topics )
{
! $folder_image = '<img src="' . $folder_new . '" alt="' . $lang['New_posts'] . '" title="' . $lang['New_posts'] . '" />';
! $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
else
***************
*** 563,575 ****
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
! $newest_post_img = "";
}
}
else
{
! $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />";
! $newest_post_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest\"><img src=\"" . $images['icon_newest_reply'] . "\" alt=\"" . $lang['View_newest_post'] . "\" title=\"" . $lang['View_newest_post'] . "\" border=\"0\" /></a> ";
}
}
--- 572,584 ----
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = '<img src="' . $folder . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" border="0" />';
! $newest_post_img = '';
}
}
else
{
! $folder_image = '<img src="' . $folder_new . '" alt="' . $lang['New_posts'] . '" title="' . $lang['New_posts'] . '" />';
! $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
}
***************
*** 577,582 ****
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
! $newest_post_img = "";
}
}
--- 586,591 ----
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = '<img src="' . $folder . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" border="0" />';
! $newest_post_img = '';
}
}
***************
*** 584,589 ****
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />";
! $newest_post_img = "";
}
}
--- 593,598 ----
{
$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
! $folder_image = '<img src="' . $folder . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" border="0" />';
! $newest_post_img = '';
}
}
***************
*** 591,603 ****
$view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
! $topic_poster = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $topic_rowset[$i]['user_id']) . "\">" : "";
$topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
! $topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? "</a>" : "";
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
! $last_post = $last_post_time . "<br />";
! $last_post .= ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username'] . " " : $lang['Guest'] . " " ) : "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $topic_rowset[$i]['id2']) . "\">" . $topic_rowset[$i]['user2'] . "</a> ";
! $last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $topic_rowset[$i]['topic_last_post_id']) . "#" . $topic_rowset[$i]['topic_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" alt=\"" . $lang['View_latest_post'] . "\" title=\"" . $lang['View_latest_post'] . "\" border=\"0\" /></a>";
$views = $topic_rowset[$i]['topic_views'];
--- 600,612 ----
$view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
! $topic_poster = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $topic_rowset[$i]['user_id']) . '">' : '';
$topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
! $topic_poster .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
! $last_post = $last_post_time . '<br />';
! $last_post .= ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username'] != "" ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a> ';
! $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $topic_rowset[$i]['topic_last_post_id']) . "#" . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
$views = $topic_rowset[$i]['topic_views'];
***************
*** 629,635 ****
"PAGE_NUMBER" => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
! "L_GOTO_PAGE" => $lang['Goto_page'],
!
! "S_NO_TOPICS" => FALSE)
);
--- 638,642 ----
"PAGE_NUMBER" => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
! "L_GOTO_PAGE" => $lang['Goto_page'])
);
***************
*** 650,667 ****
//
- // Mozilla navigation bar
- //
- $nav_links['up'] = array(
- 'url' => append_sid("index.".$phpEx),
- 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
- );
-
- //
- // Dump out the page header and load viewforum template
- //
- $page_title = $lang['View_forum'] . " - " . $forum_row['forum_name'];
- include($phpbb_root_path . 'includes/page_header.'.$phpEx);
-
- //
// Parse the page and print
//
--- 657,660 ----
***************
*** 673,675 ****
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
! ?>
--- 666,668 ----
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
! ?>
\ No newline at end of file
|