mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Fixed: announcements being listed last
Changed: moved up the announcements query a little, rows are stored in the order they're fetched, the final order of topics is in $topic_list. Will be easier if we come to prefetching topics git-svn-id: file:///svn/phpbb/trunk@4509 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
49b47422b3
commit
f614337627
1 changed files with 45 additions and 46 deletions
|
@ -287,10 +287,8 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
|||
$icons = array();
|
||||
obtain_icons($icons);
|
||||
|
||||
|
||||
// Grab all topic data
|
||||
$total_topics = 0;
|
||||
$rowset = array();
|
||||
$rowset = $announcement_list = $topic_list = array();
|
||||
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
|
@ -304,23 +302,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
|||
$sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1';
|
||||
$sql_select = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['user_id'] != ANONYMOUS) ? ', tt.mark_type, tt.mark_time' : '';
|
||||
|
||||
// If the user is trying to reach late pages, start searching from the end
|
||||
$store_reverse = FALSE;
|
||||
$limit = $config['topics_per_page'];
|
||||
|
||||
if ($start > $topics_count / 2)
|
||||
{
|
||||
$store_reverse = TRUE;
|
||||
|
||||
if ($start + $config['topics_per_page'] > $topics_count)
|
||||
{
|
||||
$limit = min($config['topics_per_page'], max(1, $topics_count - $start));
|
||||
}
|
||||
|
||||
$sql_sort_order = preg_replace('/(ASC|DESC)/e', "('\$1' == 'ASC') ? 'DESC' : 'ASC'", $sql_sort_order);
|
||||
$start = max(0, $topics_count - $limit - $start);
|
||||
}
|
||||
|
||||
// Obtain announcements
|
||||
$sql = "SELECT t.* $sql_select
|
||||
FROM $sql_from
|
||||
WHERE t.forum_id IN ($forum_id, 0)
|
||||
|
@ -330,18 +312,33 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
|||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($store_reverse)
|
||||
{
|
||||
array_unshift($rowset, $row);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rowset[] = $row;
|
||||
}
|
||||
$total_topics++;
|
||||
$rowset[$row['topic_id']] = $row;
|
||||
$announcement_list[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// If the user is trying to reach late pages, start searching from the end
|
||||
$store_reverse = FALSE;
|
||||
$sql_limit = $config['topics_per_page'];
|
||||
|
||||
if ($start > $topics_count / 2)
|
||||
{
|
||||
$store_reverse = TRUE;
|
||||
|
||||
if ($start + $config['topics_per_page'] > $topics_count)
|
||||
{
|
||||
$sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start));
|
||||
}
|
||||
|
||||
$sql_sort_order = preg_replace('/(ASC|DESC)/e', "('\$1' == 'ASC') ? 'DESC' : 'ASC'", $sql_sort_order);
|
||||
$sql_start = max(0, $topics_count - $sql_limit - $start);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_start = $start;
|
||||
}
|
||||
|
||||
// Obtain other topics
|
||||
$sql = "SELECT t.* $sql_select
|
||||
FROM $sql_from
|
||||
WHERE t.forum_id = $forum_id
|
||||
|
@ -349,24 +346,26 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
|||
$sql_approved
|
||||
$sql_limit_time
|
||||
ORDER BY t.topic_type DESC, $sql_sort_order";
|
||||
$result = $db->sql_query_limit($sql, $limit, $start);
|
||||
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
||||
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($store_reverse)
|
||||
{
|
||||
array_unshift($rowset, $row);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rowset[] = $row;
|
||||
}
|
||||
$total_topics++;
|
||||
$rowset[$row['topic_id']] = $row;
|
||||
$topic_list[] = $row['topic_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($store_reverse)
|
||||
{
|
||||
$topic_list = array_merge($announcement_list, array_reverse($topic_list));
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_list = array_merge($announcement_list, $topic_list);
|
||||
}
|
||||
|
||||
// Okay, lets dump out the page ...
|
||||
if ($total_topics)
|
||||
if (count($topic_list))
|
||||
{
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
|
@ -380,9 +379,9 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
|||
$mark_forum_read = true;
|
||||
|
||||
$i = $s_type_switch = 0;
|
||||
foreach ($rowset as $key => $row)
|
||||
foreach ($topic_list as $topic_id)
|
||||
{
|
||||
$topic_id = $row['topic_id'];
|
||||
$row =& $rowset[$topic_id];
|
||||
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue