mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/9684] Fix Forum/Topic-Tracking for global announcements
Should be ready for intensive testing now. PHPBB3-9684
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user