|
From: Ruslan U. <rx...@ph...> - 2009-08-18 14:51:54
|
Author: rxu
Date: Tue Aug 18 15:51:08 2009
New Revision: 10018
Log:
Better tracking of global announcements
Authorised by: AcydBurn
Modified:
branches/phpBB-3_0_0/phpBB/includes/functions.php
branches/phpBB-3_0_0/phpBB/includes/functions_display.php
branches/phpBB-3_0_0/phpBB/viewtopic.php
Modified: branches/phpBB-3_0_0/phpBB/includes/functions.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/functions.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/functions.php Tue Aug 18 15:51:08 2009
***************
*** 1730,1742 ****
$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)
! $sql = 'SELECT topic_id
! 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))
--- 1730,1742 ----
$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)
! $sql = 'SELECT t.topic_id
! FROM ' . TOPICS_TABLE . ' t
! WHERE t.topic_last_post_time > ' . (int) $user->data['user_lastmark'] . '
! AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . '
! AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . "
$sql_extra
! ORDER BY t.topic_last_post_time DESC";
$result = $db->sql_query_limit($sql, 1000);
while ($row = $db->sql_fetchrow($result))
Modified: branches/phpBB-3_0_0/phpBB/includes/functions_display.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/functions_display.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/functions_display.php Tue Aug 18 15:51:08 2009
***************
*** 102,107 ****
--- 102,120 ----
$forum_tracking_info = array();
$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))
{
$forum_id = $row['forum_id'];
***************
*** 309,314 ****
--- 322,333 ----
$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 = '';
$subforums_list = array();
Modified: branches/phpBB-3_0_0/phpBB/viewtopic.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/viewtopic.php (original)
--- branches/phpBB-3_0_0/phpBB/viewtopic.php Tue Aug 18 15:51:08 2009
***************
*** 1593,1598 ****
--- 1593,1619 ----
}
}
+ // 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.
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])
{
|