mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-13 20:28:44 +01:00
[ticket/9684] Fix Forum/Topic-Tracking for global announcements
Should be ready for intensive testing now. PHPBB3-9684
This commit is contained in:
parent
9265ffbcd5
commit
712a51caea
@ -1323,35 +1323,6 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
|
||||
{
|
||||
$mark_time = array();
|
||||
|
||||
// Get global announcement info
|
||||
if ($global_announce_list && sizeof($global_announce_list))
|
||||
{
|
||||
if (!isset($forum_mark_time[0]))
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT mark_time
|
||||
FROM ' . FORUMS_TRACK_TABLE . "
|
||||
WHERE user_id = {$user->data['user_id']}
|
||||
AND forum_id = 0";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$mark_time[0] = $row['mark_time'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($forum_mark_time[0] !== false)
|
||||
{
|
||||
$mark_time[0] = $forum_mark_time[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false)
|
||||
{
|
||||
$mark_time[$forum_id] = $forum_mark_time[$forum_id];
|
||||
@ -1361,14 +1332,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
|
||||
|
||||
foreach ($topic_ids as $topic_id)
|
||||
{
|
||||
if ($global_announce_list && isset($global_announce_list[$topic_id]))
|
||||
{
|
||||
$last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1412,8 +1376,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||
$sql = 'SELECT forum_id, mark_time
|
||||
FROM ' . FORUMS_TRACK_TABLE . "
|
||||
WHERE user_id = {$user->data['user_id']}
|
||||
AND forum_id " .
|
||||
(($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id");
|
||||
AND forum_id = $forum_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$mark_time = array();
|
||||
@ -1427,14 +1390,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||
|
||||
foreach ($topic_ids as $topic_id)
|
||||
{
|
||||
if ($global_announce_list && isset($global_announce_list[$topic_id]))
|
||||
{
|
||||
$last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1472,13 +1428,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||
if (sizeof($topic_ids))
|
||||
{
|
||||
$mark_time = array();
|
||||
if ($global_announce_list && sizeof($global_announce_list))
|
||||
{
|
||||
if (isset($tracking_topics['f'][0]))
|
||||
{
|
||||
$mark_time[0] = base_convert($tracking_topics['f'][0], 36, 10) + $config['board_startdate'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($tracking_topics['f'][$forum_id]))
|
||||
{
|
||||
@ -1489,14 +1438,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||
|
||||
foreach ($topic_ids as $topic_id)
|
||||
{
|
||||
if ($global_announce_list && isset($global_announce_list[$topic_id]))
|
||||
{
|
||||
$last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
$last_read[$topic_id] = $user_lastmark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,11 +188,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||
{
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
|
||||
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,10 @@ class ucp_main
|
||||
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
|
||||
AND tt.user_id = ' . $user->data['user_id'] . ')';
|
||||
$sql_select .= ', tt.mark_time';
|
||||
|
||||
$sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id
|
||||
AND ft.user_id = ' . $user->data['user_id'] . ')';
|
||||
$sql_select .= ', ft.mark_time AS forum_mark_time';
|
||||
}
|
||||
|
||||
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
|
||||
@ -87,15 +91,34 @@ class ucp_main
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$topic_tracking_info = array();
|
||||
$topic_forum_list = array();
|
||||
foreach ($rowset as $t_id => $row)
|
||||
{
|
||||
if (isset($forum_tracking_info[$row['forum_id']]))
|
||||
{
|
||||
$row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
|
||||
}
|
||||
|
||||
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
|
||||
$topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
|
||||
}
|
||||
|
||||
$topic_tracking_info = $tracking_topics = array();
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
|
||||
}
|
||||
}
|
||||
unset($topic_forum_list);
|
||||
|
||||
foreach ($topic_list as $topic_id)
|
||||
{
|
||||
@ -737,14 +760,14 @@ class ucp_main
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false);
|
||||
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list);
|
||||
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,11 +719,11 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||
{
|
||||
if ($user->data['is_registered'] && $config['load_db_lastread'])
|
||||
{
|
||||
$topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']);
|
||||
$topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']));
|
||||
}
|
||||
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
{
|
||||
$topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']);
|
||||
$topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']);
|
||||
|
||||
if (!$user->data['is_registered'])
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ $template->assign_vars(array(
|
||||
$icons = $cache->obtain_icons();
|
||||
|
||||
// Grab all topic data
|
||||
$rowset = $announcement_list = $topic_list = $global_announce_list = array();
|
||||
$rowset = $announcement_list = $topic_list = $global_announce_forums = array();
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 't.*',
|
||||
@ -383,18 +383,40 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
||||
$rowset[$row['topic_id']] = $row;
|
||||
$announcement_list[] = $row['topic_id'];
|
||||
|
||||
if ($row['topic_type'] == POST_GLOBAL)
|
||||
{
|
||||
$global_announce_list[$row['topic_id']] = true;
|
||||
}
|
||||
else
|
||||
if ($forum_id == $row['forum_id'])
|
||||
{
|
||||
$topics_count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
$global_announce_forums[] = $row['forum_id'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$forum_tracking_info = array();
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
{
|
||||
$forum_tracking_info[$forum_id] = $forum_data['mark_time'];
|
||||
|
||||
if (!empty($global_announce_forums) && $config['load_db_lastread'])
|
||||
{
|
||||
$sql = 'SELECT forum_id, mark_time
|
||||
FROM ' . FORUMS_TRACK_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . '
|
||||
AND user_id = ' . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forum_tracking_info[$row['forum_id']] = $row['mark_time'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user is trying to reach late pages, start searching from the end
|
||||
$store_reverse = false;
|
||||
$sql_limit = $config['topics_per_page'];
|
||||
@ -552,45 +574,44 @@ if (sizeof($topic_list))
|
||||
$mark_forum_read = true;
|
||||
$mark_time_forum = 0;
|
||||
|
||||
// Active topics?
|
||||
if ($s_display_active && sizeof($active_forum_ary))
|
||||
// Generate topic forum list...
|
||||
$topic_forum_list = array();
|
||||
foreach ($rowset as $t_id => $row)
|
||||
{
|
||||
// Generate topic forum list...
|
||||
$topic_forum_list = array();
|
||||
foreach ($rowset as $t_id => $row)
|
||||
if (isset($forum_tracking_info[$row['forum_id']]))
|
||||
{
|
||||
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
|
||||
$topic_forum_list[$row['forum_id']]['topics'][] = $t_id;
|
||||
$row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']];
|
||||
}
|
||||
|
||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false);
|
||||
}
|
||||
}
|
||||
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false);
|
||||
}
|
||||
}
|
||||
|
||||
unset($topic_forum_list);
|
||||
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0;
|
||||
$topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id;
|
||||
}
|
||||
else
|
||||
|
||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']));
|
||||
}
|
||||
}
|
||||
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
{
|
||||
foreach ($topic_forum_list as $f_id => $topic_row)
|
||||
{
|
||||
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);
|
||||
}
|
||||
}
|
||||
|
||||
unset($topic_forum_list);
|
||||
|
||||
if (!$s_display_active)
|
||||
{
|
||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||
{
|
||||
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list);
|
||||
$mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark'];
|
||||
}
|
||||
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
{
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list);
|
||||
|
||||
if (!$user->data['is_registered'])
|
||||
{
|
||||
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user