Commented out current prev/next topic for time being

git-svn-id: file:///svn/phpbb/trunk@355 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-05-27 22:08:47 +00:00
parent dd76a72bc8
commit fb9aa3f905

View file

@ -27,6 +27,10 @@ include('includes/bbcode.'.$phpEx);
$page_title = "View Topic - $topic_title"; $page_title = "View Topic - $topic_title";
$pagetype = "viewtopic"; $pagetype = "viewtopic";
//
// Start initial var setup
//
if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility
{ {
$topic_id = $HTTP_GET_VARS[POST_TOPIC_URL]; $topic_id = $HTTP_GET_VARS[POST_TOPIC_URL];
@ -36,16 +40,26 @@ else
$topic_id = $HTTP_GET_VARS['topic']; $topic_id = $HTTP_GET_VARS['topic'];
} }
$start = (isset($HTTP_GET_VARS['start'])) ? $HTTP_GET_VARS['start'] : 0;
$is_moderator = 0; $is_moderator = 0;
//
// End initial var setup
//
if(!isset($topic_id)) if(!isset($topic_id))
{ {
error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again"); error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again");
} }
// This is the single/double 'integrated'
// query to obtain the next/previous
// topic from just the current topic_id
// //
// Start: 'Next newest topic' & 'Next oldest topic' functionality // We will make this word, if it's the last thing I
// // do ... and it quite possibly will be!
/*
if(isset($HTTP_GET_VARS['view'])) if(isset($HTTP_GET_VARS['view']))
{ {
if($HTTP_GET_VARS['view'] == 'newer') if($HTTP_GET_VARS['view'] == 'newer')
@ -59,23 +73,11 @@ if(isset($HTTP_GET_VARS['view']))
switch($dbms) switch($dbms)
{ {
case 'oracle': case 'mysql':
case 'mssql':
case 'odbc':
case 'postgres':
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE t.topic_id in
(select max(topic_id) from ".TOPICS_TABLE." WHERE topic_time ".$operator." (select topic_time as t_time from ".TOPICS_TABLE." where topic_id = $topic_id))
AND f.forum_id = ".$HTTP_GET_VARS[POST_FORUM_URL]."
AND f.forum_id = t.forum_id
AND fm.forum_id = t.forum_id
AND u.user_id = fm.user_id";
break;
default:
// And now the stupid MySQL case...I wish they would get around to implementing subselectes... // And now the stupid MySQL case...I wish they would get around to implementing subselectes...
$sub_query = "SELECT topic_time FROM ".TOPICS_TABLE." WHERE topic_id = $topic_id"; $sub_query = "SELECT topic_time
FROM ".TOPICS_TABLE."
WHERE topic_id = $topic_id";
if($sub_result = $db->sql_query($sub_query)) if($sub_result = $db->sql_query($sub_query))
{ {
$resultset = $db->sql_fetchrowset($sub_result); $resultset = $db->sql_fetchrowset($sub_result);
@ -102,6 +104,17 @@ if(isset($HTTP_GET_VARS['view']))
} }
} }
break; break;
default:
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE t.topic_id in
(select max(topic_id) from ".TOPICS_TABLE." WHERE topic_time ".$operator." (select topic_time as t_time from ".TOPICS_TABLE." where topic_id = $topic_id))
AND f.forum_id = ".$HTTP_GET_VARS[POST_FORUM_URL]."
AND f.forum_id = t.forum_id
AND fm.forum_id = t.forum_id
AND u.user_id = fm.user_id";
break;
} }
} }
// //
@ -109,14 +122,18 @@ if(isset($HTTP_GET_VARS['view']))
// //
else else
{ {
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, */
f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_type, f.forum_name, f.forum_id, u.username, u.user_id
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE t.topic_id = $topic_id WHERE t.topic_id = $topic_id
AND f.forum_id = t.forum_id AND f.forum_id = t.forum_id
AND fm.forum_id = t.forum_id AND fm.forum_id = t.forum_id
AND u.user_id = fm.user_id"; AND u.user_id = fm.user_id";
}
// This closes out the opening braces above
// Needed for the view/next query
//}
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
@ -130,14 +147,20 @@ if(!$result = $db->sql_query($sql))
error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__); error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
} }
} }
if(!$total_rows = $db->sql_numrows($result)) if(!$total_rows = $db->sql_numrows($result))
{ {
if(isset($HTTP_GET_VARS['view'])) //
// This should be considered temporary since
// it should be moved to the templating file
// when if...else constructs become available
//
/* if(isset($HTTP_GET_VARS['view']))
{ {
error_die(GENERAL_ERROR, $l_nomoretopics); error_die(GENERAL_ERROR, $l_nomoretopics);
} }
else else
{ { */
if(DEBUG) if(DEBUG)
{ {
$error = $db->sql_error(); $error = $db->sql_error();
@ -147,14 +170,14 @@ if(!$total_rows = $db->sql_numrows($result))
{ {
error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again."); error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again.");
} }
} // }
} }
$forum_row = $db->sql_fetchrowset($result); $forum_row = $db->sql_fetchrowset($result);
$topic_title = $forum_row[0]['topic_title'];
$forum_id = $forum_row[0]['forum_id'];
$forum_name = stripslashes($forum_row[0]['forum_name']); $forum_name = stripslashes($forum_row[0]['forum_name']);
// If we're viewing a 'newer' or 'older' topic the current topic_id is unreliable $forum_id = $forum_row[0]['forum_id'];
$topic_id = $forum_row[0]['topic_id']; $total_replies = $forum_row[0]['topic_replies'] + 1;
$topic_title = $forum_row[0]['topic_title'];
$topic_time = $forum_row[0]['topic_time'];
// //
// Start session management // Start session management
@ -176,32 +199,37 @@ for($x = 0; $x < $total_rows; $x++)
} }
// //
// Add checking for private forums here // Start auth check
// //
// //
// Set the body template // End auth check
// //
$template->set_filenames(array(
"body" => "viewtopic_body.tpl",
"jumpbox" => "jumpbox.tpl")
);
$jumpbox = make_jumpbox();
$template->assign_vars(array(
"JUMPBOX_LIST" => $jumpbox,
"S_JUMPBOX_ACTION" => append_sid("viewforum.".$phpEx),
"SELECT_NAME" => POST_FORUM_URL)
);
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
$total_replies = $forum_row[0]['topic_replies'] + 1; //
// Get next and previous topic_id's
//
$sql_next_id = "SELECT topic_id
FROM ".TOPICS_TABLE."
WHERE topic_time > $topic_time
AND forum_id = $forum_id
ORDER BY topic_time ASC
LIMIT 1";
$sql_prev_id = "SELECT topic_id
FROM ".TOPICS_TABLE."
WHERE topic_time < $topic_time
AND forum_id = $forum_id
ORDER BY topic_time DESC
LIMIT 1";
$result_next = $db->sql_query($sql_next_id);
$result_prev = $db->sql_query($sql_prev_id);
$topic_next_row = $db->sql_fetchrow($result_next);
$topic_prev_row = $db->sql_fetchrow($result_prev);
if(!isset($start)) //
{ // Go ahead and pull all data for this topic
$start = 0; //
} $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, 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_avatar, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject
FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id AND p.poster_id = u.user_id
@ -214,6 +242,11 @@ if(!$result = $db->sql_query($sql))
} }
if(!$total_posts = $db->sql_numrows($result)) if(!$total_posts = $db->sql_numrows($result))
{ {
//
// Again this should be considered temporary and
// will appear in the templates file at some
// point
//
error_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", __LINE__, __FILE__); error_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", __LINE__, __FILE__);
} }
$sql = "SELECT * $sql = "SELECT *
@ -226,6 +259,34 @@ if(!$ranks_result = $db->sql_query($sql))
$postrow = $db->sql_fetchrowset($result); $postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult); $ranksrow = $db->sql_fetchrowset($ranksresult);
//
// Dump out the page header and
// load viewtopic body template
//
include('includes/page_header.'.$phpEx);
$template->set_filenames(array(
"body" => "viewtopic_body.tpl",
"jumpbox" => "jumpbox.tpl")
);
$jumpbox = make_jumpbox();
$template->assign_vars(array(
"JUMPBOX_LIST" => $jumpbox,
"SELECT_NAME" => POST_FORUM_URL)
);
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
$template->assign_vars(array(
"FORUM_ID" => $forum_id,
"FORUM_NAME" => $forum_name,
"TOPIC_ID" => $topic_id,
"TOPIC_TITLE" => $topic_title,
"POST_FORUM_URL" => POST_FORUM_URL,
"USERS_BROWSING" => $users_browsing)
);
//
// End header
//
// //
// Post, reply and other URL generation for // Post, reply and other URL generation for
// templating vars // templating vars
@ -233,22 +294,30 @@ $ranksrow = $db->sql_fetchrowset($ranksresult);
$new_topic_url = append_sid("posting.".$phpEx."?mode=newtopic&".POST_FORUM_URL."=$forum_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&".POST_FORUM_URL."=$forum_id"); $reply_topic_url = append_sid("posting.".$phpEx."?mode=reply&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id");
$view_forum_url = append_sid("viewforum.".$phpEx."?".POST_FORUM_URL."=$forum_id"); $view_forum_url = append_sid("viewforum.".$phpEx."?".POST_FORUM_URL."=$forum_id");
$view_older_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".POST_FORUM_URL."=$forum_id&view=newer"); $view_prev_topic_url = (!empty($topic_prev_row['topic_id'])) ? append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_prev_row['topic_id']) : "";
$view_newer_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".POST_FORUM_URL."=$forum_id&view=older"); $view_next_topic_url = (!empty($topic_next_row['topic_id'])) ? append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_next_row['topic_id']) : "";
$template->assign_vars(array( $template->assign_vars(array(
"L_POSTED" => $l_posted, "L_POSTED" => $l_posted,
"U_POST_NEW_TOPIC" => $new_topic_url, "U_POST_NEW_TOPIC" => $new_topic_url,
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
"TOPIC_TITLE" => $topic_title, "TOPIC_TITLE" => $topic_title,
"U_VIEW_FORUM" => $view_forum_url, "U_VIEW_FORUM" => $view_forum_url,
"U_VIEW_OLDER_TOPIC" => $view_older_topic_url, "U_VIEW_OLDER_TOPIC" => $view_prev_topic_url,
"U_VIEW_NEWER_TOPIC" => $view_newer_topic_url, "U_VIEW_NEWER_TOPIC" => $view_next_topic_url,
"U_POST_REPLY_TOPIC" => $reply_topic_url)); "U_POST_REPLY_TOPIC" => $reply_topic_url));
// //
// Dump out the page header // Update the topic view counter
// If we get here then the page is unlikely
// to fail generating ...
// //
include('includes/page_header.'.$phpEx); $sql = "UPDATE ".TOPICS_TABLE."
SET topic_views = topic_views + 1
WHERE topic_id = $topic_id";
if(!$update_result = $db->sql_query($sql))
{
error_die(SQL_QUERY, "Couldn't update topic views.", __LINE__, __FILE__);
}
// //
// Okay, let's do the loop, yeah come on baby let's do the loop // Okay, let's do the loop, yeah come on baby let's do the loop
@ -262,6 +331,7 @@ for($x = 0; $x < $total_posts; $x++)
$poster_posts = $postrow[$x]['user_posts']; $poster_posts = $postrow[$x]['user_posts'];
$poster_from = ($postrow[$x]['user_from']) ? "$l_from: ".$postrow[$x]['user_from'] : ""; $poster_from = ($postrow[$x]['user_from']) ? "$l_from: ".$postrow[$x]['user_from'] : "";
$poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']); $poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']);
$poster_avatar = ($postrow[$x]['user_avatar'] != "") ? "<img src=\"".$board_config['avatar_path']."/".$postrow[$x]['user_avatar']."\">" : "";
if($poster_id != ANONYMOUS && $poster_id != DELETED) if($poster_id != ANONYMOUS && $poster_id != DELETED)
{ {
if(!$postrow[$x]['user_rank']) if(!$postrow[$x]['user_rank'])
@ -321,7 +391,7 @@ for($x = 0; $x < $total_posts; $x++)
$delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>"; $delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>";
} }
$post_subject = stripslashes($postrow[$x]['post_subject']); $post_subject = ($postrow[$x]['post_subject'] != "") ? stripslashes($postrow[$x]['post_subject']) : "Re: ".$topic_title;
$message = stripslashes($postrow[$x]['post_text']); $message = stripslashes($postrow[$x]['post_text']);
$bbcode_uid = $postrow[$x]['bbcode_uid']; $bbcode_uid = $postrow[$x]['bbcode_uid'];
$user_sig = stripslashes($postrow[$x]['user_sig']); $user_sig = stripslashes($postrow[$x]['user_sig']);
@ -342,9 +412,12 @@ for($x = 0; $x < $total_posts; $x++)
} }
$message = make_clickable($message); $message = make_clickable($message);
$message = str_replace("\n", "<br />", $message); $message = str_replace("\n", "<br />", $message);
//
// Again this will be handled by the templating
// code at some point
//
if(!($x % 2)) if(!($x % 2))
{ {
$color = "#".$theme['td_color1']; $color = "#".$theme['td_color1'];
@ -365,6 +438,7 @@ for($x = 0; $x < $total_posts; $x++)
"POSTER_JOINED" => $poster_joined, "POSTER_JOINED" => $poster_joined,
"POSTER_POSTS" => $poster_posts, "POSTER_POSTS" => $poster_posts,
"POSTER_FROM" => $poster_from, "POSTER_FROM" => $poster_from,
"POSTER_AVATAR" => $poster_avatar,
"POST_DATE" => $post_date, "POST_DATE" => $post_date,
"POST_SUBJECT" => $post_subject, "POST_SUBJECT" => $post_subject,
"MESSAGE" => $message, "MESSAGE" => $message,
@ -404,16 +478,6 @@ $template->assign_vars(array(
$template->pparse("body"); $template->pparse("body");
flush();
//
// Update the number of views on this topic. I did the flush() above so the user can see the output
// right away and dosan't have to wait for this update query to finish.
//
$sql = "UPDATE ".TOPICS_TABLE." SET topic_views = topic_views + 1 WHERE topic_id = $topic_id";
// We don't care too much if this query succeeds or not so I'm not going to bother checking
$db->sql_query($sql);
include('includes/page_tail.'.$phpEx); include('includes/page_tail.'.$phpEx);
?> ?>