From: Meik S. <acy...@ph...> - 2009-09-08 10:36:43
|
Author: acydburn Date: Tue Sep 8 11:36:22 2009 New Revision: 10121 Log: Further adjust unread tracking query, should work now for user last mark times less than forum/topic mark times. Modified: branches/phpBB-3_0_0/phpBB/includes/functions.php branches/phpBB-3_0_0/phpBB/includes/functions_display.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 Sep 8 11:36:22 2009 *************** *** 1683,1688 **** --- 1683,1690 ---- if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics + $last_mark = $user->data['user_lastmark']; + $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', *************** *** 1691,1706 **** 'LEFT_JOIN' => array( array( '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, ), array( '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, ), ), ! 'WHERE' => "((tt.topic_id OR ft.forum_id) ! OR t.topic_last_post_time > {$user->data['user_lastmark']}) $sql_extra $sql_sort", ); --- 1693,1715 ---- 'LEFT_JOIN' => array( array( 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), ! 'ON' => "tt.user_id = $user_id AND t.topic_id = tt.topic_id AND tt.mark_time > $last_mark", ), array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), ! 'ON' => "ft.user_id = $user_id AND t.forum_id = ft.forum_id AND ft.mark_time > $last_mark", ), ), ! 'WHERE' => " ! ( ! (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_sort", ); *************** *** 1711,1718 **** while ($row = $db->sql_fetchrow($result)) { $topic_id = (int) $row['topic_id']; ! ! $unread_topics[$topic_id] = ($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : (int) $row['topic_mark_time']; } $db->sql_freeresult($result); } --- 1720,1726 ---- while ($row = $db->sql_fetchrow($result)) { $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); } $db->sql_freeresult($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 Sep 8 11:36:22 2009 *************** *** 107,115 **** $ga_unread = false; if ($root_data['forum_id'] == 0) { ! $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0'); ! if (sizeof($unread_ga_list)) { $ga_unread = true; } --- 107,115 ---- $ga_unread = false; if ($root_data['forum_id'] == 0) { ! $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); ! if (!empty($unread_ga_list)) { $ga_unread = true; } |