mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
More small adjustments to get_unread_topics_list(). #46765
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9883 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d2420fe555
commit
e2d24413b6
@ -4139,7 +4139,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||
|
||||
if ($user_id === false)
|
||||
{
|
||||
$user_id = $user->data['user_id'];
|
||||
$user_id = (int) $user->data['user_id'];
|
||||
}
|
||||
|
||||
$tracked_topics_list = $unread_topics_list = $read_topics_list = array();
|
||||
@ -4151,11 +4151,12 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||
// This list is to fetch later the forums user never read (fully) before
|
||||
$sql = 'SELECT forum_id
|
||||
FROM ' . FORUMS_TRACK_TABLE . "
|
||||
WHERE user_id = {$user_id}";
|
||||
WHERE user_id = $user_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$tracked_forums_list[] = $row['forum_id'];
|
||||
$tracked_forums_list[] = (int) $row['forum_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@ -4164,20 +4165,21 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TRACK_TABLE . " tt
|
||||
WHERE t.topic_id = tt.topic_id
|
||||
AND t.topic_last_post_time >= tt.mark_time
|
||||
AND tt.user_id = {$user_id}
|
||||
AND tt.user_id = $user_id
|
||||
$sql_extra
|
||||
ORDER BY t.topic_last_post_time DESC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['topic_last_post_time'] == $row['mark_time'])
|
||||
{
|
||||
// Check if there're read topics for the forums having unread ones
|
||||
$read_topics_list[$row['topic_id']] = $row['mark_time'];
|
||||
$read_topics_list[$row['topic_id']] = (int) $row['mark_time'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$unread_topics_list[$row['topic_id']] = $row['mark_time'];
|
||||
$unread_topics_list[$row['topic_id']] = (int) $row['mark_time'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
@ -4192,13 +4194,14 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||
WHERE t.forum_id = ft.forum_id
|
||||
AND t.topic_last_post_time > ft.mark_time
|
||||
AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . "
|
||||
AND ft.user_id = {$user_id}
|
||||
AND ft.user_id = $user_id
|
||||
$sql_extra
|
||||
ORDER BY t.topic_last_post_time DESC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$unread_topics_list[$row['topic_id']] = $row['mark_time'];
|
||||
$unread_topics_list[$row['topic_id']] = (int) $row['mark_time'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@ -4208,16 +4211,17 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||
|
||||
// And the last step - find unread topics were not found before (that can mean a user has never read some forums)
|
||||
$sql = 'SELECT topic_id
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
WHERE topic_last_post_time > {$user->data['user_lastmark']}
|
||||
AND " . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . '
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . '
|
||||
AND ' . $db->sql_in_set('topic_id', $tracked_topics_list, true, true) . '
|
||||
AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . "
|
||||
$sql_extra
|
||||
ORDER BY topic_last_post_time DESC";
|
||||
$result = $db->sql_query_limit($sql, 1000);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$unread_topics_list[$row['topic_id']] = $user->data['user_lastmark'];
|
||||
$unread_topics_list[$row['topic_id']] = (int) $user->data['user_lastmark'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user