mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- introducing read/unread images in the MCP, if you view something through the MCP it will not update the "read" status of a post/topic/forum [includes Bug #6796]
git-svn-id: file:///svn/phpbb/trunk@6936 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
14e209a487
commit
aa8ebc7bf3
7 changed files with 194 additions and 30 deletions
|
@ -99,8 +99,18 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||||
|
|
||||||
$topic_rows = array();
|
$topic_rows = array();
|
||||||
|
|
||||||
$sql = 'SELECT t.*
|
if ($config['load_db_lastread'])
|
||||||
FROM ' . TOPICS_TABLE . " t
|
{
|
||||||
|
$read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
|
||||||
|
$read_tracking_select = ', tt.mark_time';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$read_tracking_join = $read_tracking_select = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT t.*$read_tracking_select
|
||||||
|
FROM " . TOPICS_TABLE . " t $read_tracking_join
|
||||||
WHERE (t.forum_id = $forum_id OR t.forum_id = 0)
|
WHERE (t.forum_id = $forum_id OR t.forum_id = 0)
|
||||||
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
|
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
|
||||||
$limit_time_sql
|
$limit_time_sql
|
||||||
|
@ -109,19 +119,40 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$topic_rows[] = $row;
|
$topic_rows[$row['topic_id']] = $row;
|
||||||
|
$topic_list[] = $row['topic_id'];
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
foreach ($topic_rows as $row)
|
$topic_tracking_info = array();
|
||||||
|
// Get topic tracking 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());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($topic_rows as $topic_id => $row)
|
||||||
{
|
{
|
||||||
$topic_title = '';
|
$topic_title = '';
|
||||||
|
|
||||||
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
||||||
|
|
||||||
|
if ($row['topic_status'] == ITEM_MOVED)
|
||||||
|
{
|
||||||
|
$unread_topic = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get folder img, topic status/type related information
|
// Get folder img, topic status/type related information
|
||||||
$folder_img = $folder_alt = $topic_type = '';
|
$folder_img = $folder_alt = $topic_type = '';
|
||||||
topic_status($row, $replies, false, $folder_img, $folder_alt, $topic_type);
|
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
|
||||||
|
|
||||||
$topic_title = censor_text($row['topic_title']);
|
$topic_title = censor_text($row['topic_title']);
|
||||||
|
|
||||||
|
@ -159,6 +190,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||||
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
|
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
|
||||||
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
|
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
|
||||||
'S_POSTS_UNAPPROVED' => $posts_unapproved,
|
'S_POSTS_UNAPPROVED' => $posts_unapproved,
|
||||||
|
'S_UNREAD_TOPIC' => $unread_topic,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($row['topic_status'] == ITEM_MOVED)
|
if ($row['topic_status'] == ITEM_MOVED)
|
||||||
|
|
|
@ -145,7 +145,7 @@ class mcp_main
|
||||||
|
|
||||||
$forum_id = request_var('f', 0);
|
$forum_id = request_var('f', 0);
|
||||||
|
|
||||||
$forum_info = get_forum_data($forum_id, 'm_');
|
$forum_info = get_forum_data($forum_id, 'm_', true);
|
||||||
|
|
||||||
if (!sizeof($forum_info))
|
if (!sizeof($forum_info))
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@ function mcp_post_details($id, $mode, $action)
|
||||||
$start = request_var('start', 0);
|
$start = request_var('start', 0);
|
||||||
|
|
||||||
// Get post data
|
// Get post data
|
||||||
$post_info = get_post_data(array($post_id));
|
$post_info = get_post_data(array($post_id), false, true);
|
||||||
|
|
||||||
if (!sizeof($post_info))
|
if (!sizeof($post_info))
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,21 @@ function mcp_post_details($id, $mode, $action)
|
||||||
// Set some vars
|
// Set some vars
|
||||||
$users_ary = $usernames_ary = array();
|
$users_ary = $usernames_ary = array();
|
||||||
$post_id = $post_info['post_id'];
|
$post_id = $post_info['post_id'];
|
||||||
|
$topic_tracking_info = array();
|
||||||
|
|
||||||
|
// Get topic tracking info
|
||||||
|
if ($config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
||||||
|
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
||||||
|
unset($tmp_topic_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
||||||
|
|
||||||
// Process message, leave it uncensored
|
// Process message, leave it uncensored
|
||||||
$message = $post_info['post_text'];
|
$message = $post_info['post_text'];
|
||||||
|
@ -128,6 +143,8 @@ function mcp_post_details($id, $mode, $action)
|
||||||
'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
|
'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
|
||||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
||||||
|
|
||||||
|
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
||||||
|
|
||||||
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_info['forum_id']}&p=$post_id") . "#p$post_id\">", '</a>'),
|
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_info['forum_id']}&p=$post_id") . "#p$post_id\">", '</a>'),
|
||||||
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'),
|
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'),
|
||||||
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
||||||
|
|
|
@ -82,7 +82,7 @@ class mcp_queue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_info = get_post_data(array($post_id), 'm_approve');
|
$post_info = get_post_data(array($post_id), 'm_approve', true);
|
||||||
|
|
||||||
if (!sizeof($post_info))
|
if (!sizeof($post_info))
|
||||||
{
|
{
|
||||||
|
@ -99,6 +99,21 @@ class mcp_queue
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$topic_tracking_info = array();
|
||||||
|
// Get topic tracking info
|
||||||
|
if ($config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
||||||
|
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
||||||
|
unset($tmp_topic_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
||||||
|
|
||||||
// Process message, leave it uncensored
|
// Process message, leave it uncensored
|
||||||
$message = $post_info['post_text'];
|
$message = $post_info['post_text'];
|
||||||
$message = str_replace("\n", '<br />', $message);
|
$message = str_replace("\n", '<br />', $message);
|
||||||
|
@ -130,6 +145,8 @@ class mcp_queue
|
||||||
'U_VIEW_POST' => $post_url,
|
'U_VIEW_POST' => $post_url,
|
||||||
'U_VIEW_TOPIC' => $topic_url,
|
'U_VIEW_TOPIC' => $topic_url,
|
||||||
|
|
||||||
|
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
||||||
|
|
||||||
'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start=$start\">", '</a>'),
|
'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start=$start\">", '</a>'),
|
||||||
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),
|
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),
|
||||||
'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'),
|
'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'),
|
||||||
|
|
|
@ -83,7 +83,7 @@ class mcp_reports
|
||||||
$post_id = $report['post_id'];
|
$post_id = $report['post_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_info = get_post_data(array($post_id), 'm_report');
|
$post_info = get_post_data(array($post_id), 'm_report', true);
|
||||||
|
|
||||||
if (!sizeof($post_info))
|
if (!sizeof($post_info))
|
||||||
{
|
{
|
||||||
|
@ -107,13 +107,27 @@ class mcp_reports
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$topic_tracking_info = array();
|
||||||
|
// Get topic tracking info
|
||||||
|
if ($config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
||||||
|
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
||||||
|
unset($tmp_topic_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
||||||
|
|
||||||
// Process message, leave it uncensored
|
// Process message, leave it uncensored
|
||||||
$message = $post_info['post_text'];
|
$message = $post_info['post_text'];
|
||||||
$message = str_replace("\n", '<br />', $message);
|
$message = str_replace("\n", '<br />', $message);
|
||||||
if ($post_info['bbcode_bitfield'])
|
if ($post_info['bbcode_bitfield'])
|
||||||
{
|
{
|
||||||
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||||
|
|
||||||
$bbcode = new bbcode($post_info['bbcode_bitfield']);
|
$bbcode = new bbcode($post_info['bbcode_bitfield']);
|
||||||
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +153,7 @@ class mcp_reports
|
||||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
||||||
|
|
||||||
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
||||||
|
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
||||||
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
||||||
|
|
||||||
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'),
|
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'),
|
||||||
|
|
|
@ -21,7 +21,7 @@ function mcp_topic_view($id, $mode, $action)
|
||||||
$user->add_lang('viewtopic');
|
$user->add_lang('viewtopic');
|
||||||
|
|
||||||
$topic_id = request_var('t', 0);
|
$topic_id = request_var('t', 0);
|
||||||
$topic_info = get_topic_data(array($topic_id));
|
$topic_info = get_topic_data(array($topic_id), false, true);
|
||||||
|
|
||||||
if (!sizeof($topic_info))
|
if (!sizeof($topic_info))
|
||||||
{
|
{
|
||||||
|
@ -118,6 +118,20 @@ function mcp_topic_view($id, $mode, $action)
|
||||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$topic_tracking_info = array();
|
||||||
|
|
||||||
|
// Get topic tracking info
|
||||||
|
if ($config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$tmp_topic_data = array($topic_id => $topic_info);
|
||||||
|
$topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time']));
|
||||||
|
unset($tmp_topic_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rowset as $i => $row)
|
foreach ($rowset as $i => $row)
|
||||||
{
|
{
|
||||||
$has_unapproved_posts = false;
|
$has_unapproved_posts = false;
|
||||||
|
@ -138,6 +152,8 @@ function mcp_topic_view($id, $mode, $action)
|
||||||
$has_unapproved_posts = true;
|
$has_unapproved_posts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||||
|
|
||||||
$template->assign_block_vars('postrow', array(
|
$template->assign_block_vars('postrow', array(
|
||||||
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||||
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||||
|
@ -150,7 +166,7 @@ function mcp_topic_view($id, $mode, $action)
|
||||||
'POST_ID' => $row['post_id'],
|
'POST_ID' => $row['post_id'],
|
||||||
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'),
|
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'),
|
||||||
|
|
||||||
'MINI_POST_IMG' => ($row['post_time'] > $user->data['user_lastvisit'] && $user->data['is_registered']) ? $user->img('icon_post_target_unread', $user->lang['NEW_POST']) : $user->img('icon_post_target', $user->lang['POST']),
|
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
||||||
|
|
||||||
'S_POST_REPORTED' => ($row['post_reported']) ? true : false,
|
'S_POST_REPORTED' => ($row['post_reported']) ? true : false,
|
||||||
'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
|
'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
|
||||||
|
|
|
@ -262,9 +262,9 @@ function extra_url()
|
||||||
/**
|
/**
|
||||||
* Get simple topic data
|
* Get simple topic data
|
||||||
*/
|
*/
|
||||||
function get_topic_data($topic_ids, $acl_list = false)
|
function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
|
||||||
{
|
{
|
||||||
global $auth, $db;
|
global $auth, $db, $config, $user;
|
||||||
static $rowset = array();
|
static $rowset = array();
|
||||||
|
|
||||||
$topics = array();
|
$topics = array();
|
||||||
|
@ -274,15 +274,53 @@ function get_topic_data($topic_ids, $acl_list = false)
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cache might not contain read tracking info, so we can't use it if read
|
||||||
|
// tracking information is requested
|
||||||
|
if (!$read_tracking)
|
||||||
|
{
|
||||||
$cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
|
$cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
|
||||||
$topic_ids = array_diff($topic_ids, array_keys($rowset));
|
$topic_ids = array_diff($topic_ids, array_keys($rowset));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cache_topic_ids = array();
|
||||||
|
}
|
||||||
|
|
||||||
if (sizeof($topic_ids))
|
if (sizeof($topic_ids))
|
||||||
{
|
{
|
||||||
$sql = 'SELECT f.*, t.*
|
$sql_array = array(
|
||||||
FROM ' . TOPICS_TABLE . ' t
|
'SELECT' => 't.*, f.*',
|
||||||
LEFT JOIN ' . FORUMS_TABLE . ' f ON t.forum_id = f.forum_id
|
|
||||||
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
|
'FROM' => array(
|
||||||
|
TOPICS_TABLE => 't',
|
||||||
|
),
|
||||||
|
|
||||||
|
'LEFT_JOIN' => array(
|
||||||
|
array(
|
||||||
|
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||||
|
'ON' => 'f.forum_id = t.forum_id'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($read_tracking && $config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||||
|
|
||||||
|
$sql_array['LEFT_JOIN'][] = array(
|
||||||
|
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||||
|
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql_array['LEFT_JOIN'][] = array(
|
||||||
|
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||||
|
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -319,9 +357,9 @@ function get_topic_data($topic_ids, $acl_list = false)
|
||||||
/**
|
/**
|
||||||
* Get simple post data
|
* Get simple post data
|
||||||
*/
|
*/
|
||||||
function get_post_data($post_ids, $acl_list = false)
|
function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
|
||||||
{
|
{
|
||||||
global $db, $auth;
|
global $db, $auth, $config, $user;
|
||||||
|
|
||||||
$rowset = array();
|
$rowset = array();
|
||||||
|
|
||||||
|
@ -330,7 +368,7 @@ function get_post_data($post_ids, $acl_list = false)
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $db->sql_build_query('SELECT', array(
|
$sql_array = array(
|
||||||
'SELECT' => 'p.*, u.*, t.*, f.*',
|
'SELECT' => 'p.*, u.*, t.*, f.*',
|
||||||
|
|
||||||
'FROM' => array(
|
'FROM' => array(
|
||||||
|
@ -349,8 +387,26 @@ function get_post_data($post_ids, $acl_list = false)
|
||||||
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
|
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
|
||||||
AND u.user_id = p.poster_id
|
AND u.user_id = p.poster_id
|
||||||
AND t.topic_id = p.topic_id',
|
AND t.topic_id = p.topic_id',
|
||||||
));
|
);
|
||||||
|
|
||||||
|
if ($read_tracking && $config['load_db_lastread'])
|
||||||
|
{
|
||||||
|
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||||
|
|
||||||
|
$sql_array['LEFT_JOIN'][] = array(
|
||||||
|
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||||
|
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql_array['LEFT_JOIN'][] = array(
|
||||||
|
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||||
|
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
unset($sql_array);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
@ -381,9 +437,9 @@ function get_post_data($post_ids, $acl_list = false)
|
||||||
/**
|
/**
|
||||||
* Get simple forum data
|
* Get simple forum data
|
||||||
*/
|
*/
|
||||||
function get_forum_data($forum_id, $acl_list = 'f_list')
|
function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
|
||||||
{
|
{
|
||||||
global $auth, $db;
|
global $auth, $db, $user, $config;
|
||||||
|
|
||||||
$rowset = array();
|
$rowset = array();
|
||||||
|
|
||||||
|
@ -397,9 +453,20 @@ function get_forum_data($forum_id, $acl_list = 'f_list')
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT *
|
if ($read_tracking && $config['load_db_lastread'])
|
||||||
FROM ' . FORUMS_TABLE . '
|
{
|
||||||
WHERE ' . $db->sql_in_set('forum_id', $forum_id);
|
$read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
|
||||||
|
AND ft.forum_id = f.forum_id)';
|
||||||
|
$read_tracking_select = ', ft.mark_time';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$read_tracking_join = $read_tracking_select = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT * $read_tracking_select
|
||||||
|
FROM " . FORUMS_TABLE . " f$read_tracking_join
|
||||||
|
WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
Loading…
Add table
Reference in a new issue