mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Better tracking of global announcements
Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10018 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
54362bbe2b
commit
d2d5ecef8d
3 changed files with 46 additions and 6 deletions
|
@ -1730,13 +1730,13 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
|
||||||
$tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list));
|
$tracked_topics_list = array_merge(array_keys($unread_topics_list), array_keys($read_topics_list));
|
||||||
|
|
||||||
// And the last step - find unread topics were not found before (that can mean a user has never read some forums)
|
// 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
|
$sql = 'SELECT t.topic_id
|
||||||
FROM ' . TOPICS_TABLE . '
|
FROM ' . TOPICS_TABLE . ' t
|
||||||
WHERE topic_last_post_time > ' . (int) $user->data['user_lastmark'] . '
|
WHERE t.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('t.topic_id', $tracked_topics_list, true, true) . '
|
||||||
AND ' . $db->sql_in_set('forum_id', $tracked_forums_list, true, true) . "
|
AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . "
|
||||||
$sql_extra
|
$sql_extra
|
||||||
ORDER BY topic_last_post_time DESC";
|
ORDER BY t.topic_last_post_time DESC";
|
||||||
$result = $db->sql_query_limit($sql, 1000);
|
$result = $db->sql_query_limit($sql, 1000);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
|
@ -102,6 +102,19 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||||
|
|
||||||
$forum_tracking_info = array();
|
$forum_tracking_info = array();
|
||||||
$branch_root_id = $root_data['forum_id'];
|
$branch_root_id = $root_data['forum_id'];
|
||||||
|
|
||||||
|
// Check for unread global announcements
|
||||||
|
// For index page only we do it
|
||||||
|
$ga_unread = false;
|
||||||
|
if ($root_data['forum_id'] == 0)
|
||||||
|
{
|
||||||
|
$unread_ga_list = get_unread_topics_list($user->data['user_id'], 'AND t.forum_id = 0');
|
||||||
|
if (sizeof($unread_ga_list))
|
||||||
|
{
|
||||||
|
$ga_unread = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$forum_id = $row['forum_id'];
|
$forum_id = $row['forum_id'];
|
||||||
|
@ -309,6 +322,12 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||||
|
|
||||||
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
|
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
|
||||||
|
|
||||||
|
// Mark the first visible forum on index as unread if there's any unread global announcement
|
||||||
|
if (($forum_id == $forum_ids_moderator[0]) && ($root_data['forum_id'] == 0) && $ga_unread)
|
||||||
|
{
|
||||||
|
$forum_unread = true;
|
||||||
|
}
|
||||||
|
|
||||||
$folder_image = $folder_alt = $l_subforums = '';
|
$folder_image = $folder_alt = $l_subforums = '';
|
||||||
$subforums_list = array();
|
$subforums_list = array();
|
||||||
|
|
||||||
|
|
|
@ -1593,6 +1593,27 @@ if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($use
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get last post time for all global announcements
|
||||||
|
// to keep proper forums tracking
|
||||||
|
if ($topic_data['topic_type'] == POST_GLOBAL)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT topic_last_post_time as forum_last_post_time
|
||||||
|
FROM ' . TOPICS_TABLE . '
|
||||||
|
WHERE forum_id = 0
|
||||||
|
ORDER BY topic_last_post_time DESC';
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time');
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$sql = 'SELECT mark_time as forum_mark_time
|
||||||
|
FROM ' . FORUMS_TRACK_TABLE . '
|
||||||
|
WHERE forum_id = 0
|
||||||
|
AND user_id = ' . $user->data['user_id'];
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time');
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
|
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
|
||||||
if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
|
if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue