mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Add unread posts search support for cookie-based tracking
Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10005 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b4297abf2a
commit
45f5700384
2 changed files with 56 additions and 10 deletions
|
@ -1646,7 +1646,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of unread topics
|
* 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 int $user_id User ID (or false for current user)
|
||||||
* @param string $sql_extra Extra WHERE SQL statement
|
* @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_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'])
|
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'])
|
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
||||||
{
|
{
|
||||||
// We do not implement unread topics list for cookie based tracking
|
global $tracking_topics;
|
||||||
// because it would require expensive database queries
|
|
||||||
|
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;
|
return $unread_topics_list;
|
||||||
|
|
|
@ -372,8 +372,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unreadposts':
|
case 'unreadposts':
|
||||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
|
||||||
{
|
|
||||||
$l_search_title = $user->lang['SEARCH_UNREAD'];
|
$l_search_title = $user->lang['SEARCH_UNREAD'];
|
||||||
// force sorting
|
// force sorting
|
||||||
$show_results = 'topics';
|
$show_results = 'topics';
|
||||||
|
@ -399,10 +397,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
$field = 'topic_id';
|
$field = 'topic_id';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
// Do nothing if it's cookie based read tracking
|
|
||||||
// Just do not break and let user to see newposts
|
|
||||||
|
|
||||||
case 'newposts':
|
case 'newposts':
|
||||||
$l_search_title = $user->lang['SEARCH_NEW'];
|
$l_search_title = $user->lang['SEARCH_NEW'];
|
||||||
|
|
Loading…
Add table
Reference in a new issue