mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
Further adjust unread tracking query, should work now for user last mark times less than forum/topic mark times.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10121 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d85493ab16
commit
5537393f76
2 changed files with 16 additions and 8 deletions
|
@ -1683,6 +1683,8 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
|
||||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||||
{
|
{
|
||||||
// Get list of the unread topics
|
// Get list of the unread topics
|
||||||
|
$last_mark = $user->data['user_lastmark'];
|
||||||
|
|
||||||
$sql_array = array(
|
$sql_array = array(
|
||||||
'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time',
|
'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time',
|
||||||
|
|
||||||
|
@ -1691,16 +1693,23 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
|
||||||
'LEFT_JOIN' => array(
|
'LEFT_JOIN' => array(
|
||||||
array(
|
array(
|
||||||
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||||
'ON' => 't.topic_id = tt.topic_id AND t.topic_last_post_time > tt.mark_time AND tt.user_id = ' . $user_id,
|
'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id AND tt.mark_time > $last_mark",
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||||
'ON' => 't.forum_id = ft.forum_id AND t.topic_last_post_time > ft.mark_time AND ft.user_id = ' . $user_id,
|
'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id AND ft.mark_time > $last_mark",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
'WHERE' => "((tt.topic_id OR ft.forum_id)
|
'WHERE' => "
|
||||||
OR t.topic_last_post_time > {$user->data['user_lastmark']})
|
(
|
||||||
|
(tt.mark_time AND t.topic_last_post_time > tt.mark_time) OR
|
||||||
|
(tt.mark_time IS NULL AND ft.mark_time AND t.topic_last_post_time > ft.mark_time) OR
|
||||||
|
(
|
||||||
|
((tt.mark_time IS NULL AND ft.mark_time IS NULL) OR (tt.mark_time < $last_mark AND ft.mark_time < $last_mark))
|
||||||
|
AND t.topic_last_post_time > $last_mark
|
||||||
|
)
|
||||||
|
)
|
||||||
$sql_extra
|
$sql_extra
|
||||||
$sql_sort",
|
$sql_sort",
|
||||||
);
|
);
|
||||||
|
@ -1711,8 +1720,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$topic_id = (int) $row['topic_id'];
|
$topic_id = (int) $row['topic_id'];
|
||||||
|
$unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark);
|
||||||
$unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time'];
|
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||||
$ga_unread = false;
|
$ga_unread = false;
|
||||||
if ($root_data['forum_id'] == 0)
|
if ($root_data['forum_id'] == 0)
|
||||||
{
|
{
|
||||||
$unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0');
|
$unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);
|
||||||
|
|
||||||
if (sizeof($unread_ga_list))
|
if (!empty($unread_ga_list))
|
||||||
{
|
{
|
||||||
$ga_unread = true;
|
$ga_unread = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue