Fix ordering problem for topics

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2498 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-04-07 00:41:55 +00:00
parent 152f0c89ad
commit 0e21269487

View file

@ -115,11 +115,7 @@ else
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
//
// Define some globally used data
//
$sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']); $sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']);
$sort_by_sql = array('p.post_time', 'pt.post_subject', 't.topic_title', 'u.username', 'f.forum_id');
// //
// Begin core code // Begin core code
@ -446,8 +442,8 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
} }
else if ( $search_author != '' || $search_time || $auth_sql != '' ) else if ( $search_author != '' || $search_time || $auth_sql != '' )
{ {
$where_sql = ( $search_author == '' && $auth_sql == '' ) ? "post_id IN (" . implode(', ', $search_ids) . ")" : "p.post_id IN (" . implode(", ", $search_ids) . ")"; $where_sql = ( $search_author == '' && $auth_sql == '' ) ? 'post_id IN (' . implode(', ', $search_ids) . ')' : 'p.post_id IN (' . implode(', ', $search_ids) . ')';
$from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . " p"; $from_sql = ( $search_author == '' && $auth_sql == '' ) ? POSTS_TABLE : POSTS_TABLE . ' p';
if ( $search_time ) if ( $search_time )
{ {
@ -640,10 +636,29 @@ else if ( $search_keywords != '' || $search_author != '' || $search_id )
AND p2.post_id = t.topic_last_post_id AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id"; AND u2.user_id = p2.poster_id";
} }
$per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page']; $per_page = ( $show_results == 'posts' ) ? $board_config['posts_per_page'] : $board_config['topics_per_page'];
$sql .= " ORDER BY " . $sort_by_sql[$sort_by] . " $sort_dir LIMIT $start, " . $per_page; $sql .= " ORDER BY ";
switch ( $sort_by )
{
case 1:
$sql .= ( $show_results == 'posts' ) ? 'pt.post_subject' : 't.topic_title';
break;
case 2:
$sql .= 't.topic_title';
break;
case 3:
$sql .= 'u.username';
break;
case 4:
$sql .= 'f.forum_id';
break;
default:
$sql .= ( $show_results == 'posts' ) ? 'p.post_time' : 'p2.post_time';
break;
}
$sql .= " $sort_dir LIMIT $start, " . $per_page;
if ( !$result = $db->sql_query($sql) ) if ( !$result = $db->sql_query($sql) )
{ {
@ -1298,4 +1313,4 @@ $template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> ?>