mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-22 00:32:29 +02:00
Fixed some little bugs in viewtopic. Also made sure viewtopic's next/prev functionality only views topics in the current forum.
Added some extra error messages to modify profile for when the query fails. git-svn-id: file:///svn/phpbb/trunk@321 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d525c3bc51
commit
b7f6539036
@ -90,6 +90,7 @@ $l_returnindex = "$l_toreturn to the forum index";
|
||||
$l_returntopic = "$l_toreturn to the forum topic list.";
|
||||
|
||||
$l_error = "Error";
|
||||
$l_dberror = "A database error occured, please try again later.";
|
||||
$l_tryagain = "Please go back and try again.";
|
||||
$l_mismatch = "Passwords do not match.";
|
||||
$l_userremoved = "This user has been removed from the User database";
|
||||
|
@ -411,6 +411,25 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
|
||||
|
||||
include('includes/page_tail.'.$phpEx);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DEBUG)
|
||||
{
|
||||
$error = $db->sql_error();
|
||||
$error_msg = "Could not update the users table.<br>Reason: ".$error['message']."<br>Query: $sql";
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_msg = $l_dberror;
|
||||
}
|
||||
$template->set_filenames(array(
|
||||
"reg_header" => "error_body.tpl"
|
||||
));
|
||||
$template->assign_vars(array(
|
||||
"ERROR_MESSAGE" => $error_msg
|
||||
));
|
||||
$template->pparse("reg_header");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -27,8 +27,6 @@ include('includes/bbcode.'.$phpEx);
|
||||
$page_title = "View Topic - $topic_title";
|
||||
$pagetype = "viewtopic";
|
||||
|
||||
$is_moderator = 0;
|
||||
|
||||
if(!isset($HTTP_GET_VARS['topic'])) // For backward compatibility
|
||||
{
|
||||
$topic_id = $HTTP_GET_VARS[POST_TOPIC_URL];
|
||||
@ -38,6 +36,8 @@ else
|
||||
$topic_id = $HTTP_GET_VARS['topic'];
|
||||
}
|
||||
|
||||
$is_moderator = 0;
|
||||
|
||||
if(!isset($topic_id))
|
||||
{
|
||||
error_die(GENERAL_ERROR, "You have reached this page in error, please go back and try again");
|
||||
@ -57,29 +57,36 @@ if(isset($HTTP_GET_VARS['view']))
|
||||
$operator = "<";
|
||||
}
|
||||
|
||||
switch(SQL_LAYER)
|
||||
switch($dbms)
|
||||
{
|
||||
case 'mysql':
|
||||
//
|
||||
// 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";
|
||||
case 'oracle':
|
||||
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 min(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...
|
||||
$sub_query = "SELECT topic_time FROM ".TOPICS_TABLE." WHERE topic_id = $topic_id";
|
||||
if($sub_result = $db->sql_query($sub_query))
|
||||
{
|
||||
$result = $db->sql_fetchrow($sub_result);
|
||||
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies,
|
||||
$resultset = $db->sql_fetchrowset($sub_result);
|
||||
$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, ".TOPICS_TABLE." t2, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
|
||||
WHERE t.topic_time ".$operator." ".$result['topic_time']."
|
||||
AND t2.topic_id = $topic_id
|
||||
AND t.forum_id = t2.forum_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND fm.forum_id = t.forum_id
|
||||
AND u.user_id = fm.user_id
|
||||
ORDER BY t.topic_time DESC";
|
||||
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
|
||||
WHERE t.topic_time ".$operator." ".$resultset[0]['topic_time']."
|
||||
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";
|
||||
$db->sql_freeresult($sub_result);
|
||||
}
|
||||
else
|
||||
@ -94,22 +101,7 @@ if(isset($HTTP_GET_VARS['view']))
|
||||
error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
//
|
||||
// The default query handles all the other supported
|
||||
// DB's; PostgreSQL, MSSQL, ODBC and of course Oracle
|
||||
//
|
||||
echo $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 min(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 = t.forum_id
|
||||
AND fm.forum_id = t.forum_id
|
||||
AND u.user_id = fm.user_id";
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -117,15 +109,13 @@ if(isset($HTTP_GET_VARS['view']))
|
||||
//
|
||||
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
|
||||
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
|
||||
WHERE t.topic_id = $topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
$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 = $topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
AND fm.forum_id = t.forum_id
|
||||
AND u.user_id = fm.user_id";
|
||||
|
||||
}
|
||||
|
||||
if(!$result = $db->sql_query($sql))
|
||||
@ -181,7 +171,11 @@ for($x = 0; $x < $total_rows; $x++)
|
||||
// Add checking for private forums here
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Set the body template
|
||||
//
|
||||
$template->set_filenames(array(
|
||||
"body" => "viewtopic_body.tpl"));
|
||||
|
||||
$total_replies = $forum_row[0]['topic_replies'] + 1;
|
||||
|
||||
@ -215,33 +209,6 @@ if(!$ranks_result = $db->sql_query($sql))
|
||||
$postrow = $db->sql_fetchrowset($result);
|
||||
$ranksrow = $db->sql_fetchrowset($ranksresult);
|
||||
|
||||
//
|
||||
// Dump out the page header
|
||||
//
|
||||
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
|
||||
// templating vars
|
||||
@ -249,15 +216,22 @@ $template->assign_vars(array(
|
||||
$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_older_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=newer");
|
||||
$view_newer_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=older");
|
||||
$view_older_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".POST_FORUM_URL."=$forum_id&view=newer");
|
||||
$view_newer_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".POST_FORUM_URL."=$forum_id&view=older");
|
||||
$template->assign_vars(array(
|
||||
"U_POST_NEW_TOPIC" => $new_topic_url,
|
||||
"FORUM_NAME" => $forum_name,
|
||||
"TOPIC_TITLE" => $topic_title,
|
||||
"U_VIEW_FORUM" => $view_forum_url,
|
||||
"U_VIEW_OLDER_TOPIC" => $view_older_topic_url,
|
||||
"U_VIEW_NEWER_TOPIC" => $view_newer_topic_url,
|
||||
"U_POST_REPLY_TOPIC" => $reply_topic_url));
|
||||
|
||||
//
|
||||
// Dump out the page header
|
||||
//
|
||||
include('includes/page_header.'.$phpEx);
|
||||
|
||||
//
|
||||
// Okay, let's do the loop, yeah come on baby let's do the loop
|
||||
// and it goes like this ...
|
||||
@ -411,6 +385,16 @@ $template->assign_vars(array(
|
||||
|
||||
$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);
|
||||
|
||||
?>
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user