git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9523 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Henry Sudhof 2009-06-02 13:51:19 +00:00
parent 4a36fe5264
commit b9ece6bdfe

View file

@ -394,7 +394,8 @@ if (!isset($topic_tracking_info))
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject'); $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
$join_user_sql = array('a' => true, 't' => false, 's' => false);
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
@ -858,6 +859,7 @@ if (!empty($topic_data['poll_start']))
// If the user is trying to reach the second half of the topic, fetch it starting from the end // If the user is trying to reach the second half of the topic, fetch it starting from the end
$store_reverse = false; $store_reverse = false;
$sql_limit = $config['posts_per_page']; $sql_limit = $config['posts_per_page'];
$sql_sort_order = $direction = '';
if ($start > $total_posts / 2) if ($start > $total_posts / 2)
{ {
@ -869,15 +871,24 @@ if ($start > $total_posts / 2)
} }
// Select the sort order // Select the sort order
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
$sql_start = max(0, $total_posts - $sql_limit - $start); $sql_start = max(0, $total_posts - $sql_limit - $start);
} }
else else
{ {
// Select the sort order // Select the sort order
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
$sql_start = $start; $sql_start = $start;
} }
if (is_array($sort_by_sql[$sort_key]))
{
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
}
else
{
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
// Container for user details, only process once // Container for user details, only process once
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array(); $post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();
@ -887,10 +898,10 @@ $i = $i_total = 0;
// Go ahead and pull all data for this topic // Go ahead and pull all data for this topic
$sql = 'SELECT p.post_id $sql = 'SELECT p.post_id
FROM ' . POSTS_TABLE . ' p' . (($sort_by_sql[$sort_key][0] == 'u') ? ', ' . USERS_TABLE . ' u': '') . " FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
" . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . " " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
" . (($sort_by_sql[$sort_key][0] == 'u') ? 'AND u.user_id = p.poster_id': '') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
$limit_posts_time $limit_posts_time
ORDER BY $sql_sort_order"; ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);