aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/functions.php59
-rw-r--r--phpBB/search.php7
2 files changed, 56 insertions, 10 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 02bd24b246..8f263f08e4 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1646,7 +1646,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
/**
* Get list of unread topics
-* only for registered users and non-cookie tracking
*
* @param int $user_id User ID (or false for current user)
* @param string $sql_extra Extra WHERE SQL statement
@@ -1664,7 +1663,7 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
}
$tracked_topics_list = $unread_topics_list = $read_topics_list = array();
- $tracked_forums_list = array();
+ $tracked_forums_list = $mark_time = array();
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
@@ -1748,8 +1747,60 @@ function get_unread_topics_list($user_id = false, $sql_extra = '')
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
{
- // We do not implement unread topics list for cookie based tracking
- // because it would require expensive database queries
+ global $tracking_topics;
+
+ if (!isset($tracking_topics) || !sizeof($tracking_topics))
+ {
+ $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
+ $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
+ }
+
+ if (!$user->data['is_registered'])
+ {
+ $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
+ }
+ else
+ {
+ $user_lastmark = $user->data['user_lastmark'];
+ }
+
+ $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time
+ FROM ' . TOPICS_TABLE . ' t
+ WHERE t.topic_last_post_time > ' . $user_lastmark . "
+ $sql_extra
+ ORDER BY t.topic_last_post_time DESC";
+
+ $result = $db->sql_query_limit($sql, 1000);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_id = (int) $row['forum_id'];
+ $topic_id = (int) $row['topic_id'];
+ $topic_id36 = base_convert($topic_id, 10, 36);
+
+ if (isset($tracking_topics['t'][$topic_id36]))
+ {
+ $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate'];
+ if ($row['topic_last_post_time'] > $last_read[$topic_id])
+ {
+ $unread_topics_list[$topic_id] = $last_read[$topic_id];
+ }
+ }
+ else if (isset($tracking_topics['f'][$forum_id]))
+ {
+ $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate'];
+ if ($row['topic_last_post_time'] > $mark_time[$forum_id])
+ {
+ $unread_topics_list[$topic_id] = $mark_time[$forum_id];
+ }
+ }
+ else
+ {
+ $unread_topics_list[$topic_id] = $user_lastmark;
+ }
+
+ }
+ $db->sql_freeresult($result);
}
return $unread_topics_list;
diff --git a/phpBB/search.php b/phpBB/search.php
index 3556c5b435..f991e8e023 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -372,8 +372,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
break;
case 'unreadposts':
- if ($config['load_db_lastread'] && $user->data['is_registered'])
- {
$l_search_title = $user->lang['SEARCH_UNREAD'];
// force sorting
$show_results = 'topics';
@@ -399,10 +397,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$sql_sort";
$field = 'topic_id';
}
- break;
- }
- // Do nothing if it's cookie based read tracking
- // Just do not break and let user to see newposts
+ break;
case 'newposts':
$l_search_title = $user->lang['SEARCH_NEW'];