Line 27 | Line 27 |
---|
$topic_id = request_var('t', 0); $post_id = request_var('p', 0); $voted_id = request_var('vote_id', array('' => 0));
|
$topic_id = request_var('t', 0); $post_id = request_var('p', 0); $voted_id = request_var('vote_id', array('' => 0));
|
| $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;
|
$start = request_var('start', 0); $view = request_var('view', '');
|
$start = request_var('start', 0); $view = request_var('view', '');
|
$sort_days = request_var('st', ((!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0)); $sort_key = request_var('sk', ((!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't')); $sort_dir = request_var('sd', ((!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'));
| $default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0; $default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'; $default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';
$sort_days = request_var('st', $default_sort_days); $sort_key = request_var('sk', $default_sort_key); $sort_dir = request_var('sd', $default_sort_dir);
|
$update = request_var('update', false);
|
$update = request_var('update', false);
|
| $s_can_vote = false;
|
/** * @todo normalize? */
| /** * @todo normalize? */
|
Line 78 | Line 86 |
---|
WHERE topic_id = $topic_id " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " AND post_time > $topic_last_read
|
WHERE topic_id = $topic_id " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " AND post_time > $topic_last_read
|
| AND forum_id = $forum_id
|
ORDER BY post_time ASC"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result);
| ORDER BY post_time ASC"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result);
|
Line 137 | Line 146 |
---|
if (!$row) {
|
if (!$row) {
|
$user->setup('viewtopic');
| $sql = 'SELECT forum_style FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); $forum_style = (int) $db->sql_fetchfield('forum_style'); $db->sql_freeresult($result);
$user->setup('viewtopic', $forum_style);
|
trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); } else
| trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); } else
|
Line 174 | Line 190 |
---|
$sql_array = array( 'SELECT' => 't.*, f.*',
|
$sql_array = array( 'SELECT' => 't.*, f.*',
|
'FROM' => array( FORUMS_TABLE => 'f', )
| 'FROM' => array(FORUMS_TABLE => 'f'),
|
);
|
);
|
| // Firebird handles two columns of the same name a little differently, this // addresses that by forcing the forum_id to come from the forums table. if ($db->sql_layer === 'firebird') { $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT']; }
// The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id'; $sql_array['FROM'][POSTS_TABLE] = 'p'; }
// Topics table need to be the last in the chain $sql_array['FROM'][TOPICS_TABLE] = 't';
|
if ($user->data['is_registered']) {
| if ($user->data['is_registered']) {
|
Line 220 | Line 251 |
---|
} else {
|
} else {
|
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : ''); $sql_array['FROM'][POSTS_TABLE] = 'p';
| $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
|
}
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
| }
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
|
Line 239 | Line 269 |
---|
}
$sql_array['WHERE'] .= ')';
|
}
$sql_array['WHERE'] .= ')';
|
$sql_array['FROM'][TOPICS_TABLE] = 't';
| |
// Join to forum table on topic forum_id unless topic forum_id is zero // whereupon we join on the forum_id passed as a parameter ... this
| // Join to forum table on topic forum_id unless topic forum_id is zero // whereupon we join on the forum_id passed as a parameter ... this
|
Line 250 | Line 279 |
---|
$topic_data = $db->sql_fetchrow($result); $db->sql_freeresult($result);
|
$topic_data = $db->sql_fetchrow($result); $db->sql_freeresult($result);
|
| // link to unapproved post or incorrect link
|
if (!$topic_data) { // If post_id was submitted, we try at least to display the topic as a last resort...
|
if (!$topic_data) { // If post_id was submitted, we try at least to display the topic as a last resort...
|
if ($post_id && $forum_id && $topic_id)
| if ($post_id && $topic_id)
|
{
|
{
|
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"));
| redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : '')));
|
}
trigger_error('NO_TOPIC'); }
|
}
trigger_error('NO_TOPIC'); }
|
| $forum_id = (int) $topic_data['forum_id'];
|
// This is for determining where we are (page) if ($post_id) {
|
// This is for determining where we are (page) if ($post_id) {
|
| // are we where we are supposed to be? if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id'])) { // If post_id was submitted, we try at least to display the topic as a last resort... if ($topic_id) { redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); }
trigger_error('NO_TOPIC'); }
|
if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) { $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
| if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) { $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
|
Line 279 | Line 321 |
---|
} else {
|
} else {
|
$sql = 'SELECT COUNT(p1.post_id) AS prev_posts FROM ' . POSTS_TABLE . ' p1, ' . POSTS_TABLE . " p2 WHERE p1.topic_id = {$topic_data['topic_id']} AND p2.post_id = {$post_id} " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . ' AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');
| $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '');
if ($sort_dir == 'd') { $sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))"; } else { $sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))"; }
|
$result = $db->sql_query($sql); $row = $db->sql_fetchrow($result);
| $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result);
|
Line 294 | Line 343 |
---|
} }
|
} }
|
$forum_id = (int) $topic_data['forum_id'];
| |
$topic_id = (int) $topic_data['topic_id'];
|
$topic_id = (int) $topic_data['topic_id'];
|
| |
// $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
| // $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
|
Line 385 | Line 432 |
---|
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
$sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
| $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id')); $join_user_sql = array('a' => true, 't' => false, 's' => false);
|
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
| gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
|
// Obtain correct post count and ordering SQL if user has // requested anything different
| // Obtain correct post count and ordering SQL if user has // requested anything different
|
Line 422 | Line 471 |
---|
$highlight_match = $highlight = ''; if ($hilit_words) {
|
$highlight_match = $highlight = ''; if ($hilit_words) {
|
foreach (explode(' ', trim($hilit_words)) as $word) { if (trim($word)) { $word = str_replace('\*', '\w+?', preg_quote($word, '#')); $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word); $highlight_match .= (($highlight_match != '') ? '|' : '') . $word; } }
$highlight = urlencode($hilit_words);
| $highlight_match = phpbb_clean_search_string($hilit_words); $highlight = urlencode($highlight_match); $highlight_match = str_replace('\*', '\w+?', preg_quote($highlight_match, '#')); $highlight_match = preg_replace('#(?<=^|\s)\\\\w\*\?(?=\s|$)#', '\w+?', $highlight_match); $highlight_match = str_replace(' ', '|', $highlight_match);
|
}
// Make sure $start is set to the last page if it exceeds the amount
|
}
// Make sure $start is set to the last page if it exceeds the amount
|
if ($start < 0 || $start > $total_posts)
| if ($start < 0 || $start >= $total_posts)
|
{ $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; }
// General Viewtopic URL for return links
|
{ $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; }
// General Viewtopic URL for return links
|
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start&$u_sort_param" . (($highlight_match) ? "&hilit=$highlight" : ''));
| $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : ''));
|
// Are we watching this topic? $s_watching_topic = array(
| // Are we watching this topic? $s_watching_topic = array(
|
Line 451 | Line 494 |
---|
'is_watching' => false, );
|
'is_watching' => false, );
|
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'])
| if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'])
|
{
|
{
|
watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);
| $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null; watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
|
// Reset forum notification if forum notify is set if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
| // Reset forum notification if forum notify is set if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
|
Line 465 | Line 509 |
---|
// Bookmarks if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
|
// Bookmarks if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
|
| { if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))
|
{ if (!$topic_data['bookmarked']) {
| { if (!$topic_data['bookmarked']) {
|
Line 481 | Line 527 |
---|
AND topic_id = $topic_id"; $db->sql_query($sql); }
|
AND topic_id = $topic_id"; $db->sql_query($sql); }
|
| $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); } else { $message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); }
|
meta_refresh(3, $viewtopic_url);
|
meta_refresh(3, $viewtopic_url);
|
$message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
| |
trigger_error($message); }
| trigger_error($message); }
|
Line 523 | Line 573 |
---|
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
// If we've got a hightlight set pass it on to pagination.
|
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
// If we've got a hightlight set pass it on to pagination.
|
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&$u_sort_param" . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
| $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
|
// Navigation links generate_forum_nav($topic_data);
| // Navigation links generate_forum_nav($topic_data);
|
Line 533 | Line 583 |
---|
// Moderators $forum_moderators = array();
|
// Moderators $forum_moderators = array();
|
| if ($config['load_moderators']) {
|
get_moderators($forum_moderators, $forum_id);
|
get_moderators($forum_moderators, $forum_id);
|
| }
|
// This is only used for print view so ... $server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';
// Replace naughty words in title $topic_data['topic_title'] = censor_text($topic_data['topic_title']);
|
// This is only used for print view so ... $server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';
// Replace naughty words in title $topic_data['topic_title'] = censor_text($topic_data['topic_title']);
|
| $s_search_hidden_fields = array( 't' => $topic_id, 'sf' => 'msgonly', ); if ($_SID) { $s_search_hidden_fields['sid'] = $_SID; }
if (!empty($_EXTRA_URL)) { foreach ($_EXTRA_URL as $url_param) { $url_param = explode('=', $url_param, 2); $s_search_hidden_fields[$url_param[0]] = $url_param[1]; } }
|
// Send vars to template $template->assign_vars(array(
| // Send vars to template $template->assign_vars(array(
|
Line 557 | Line 628 |
---|
'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
|
'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
|
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id&start=$start&$u_sort_param", true, $user->session_id) : '',
| 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '',
|
'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
| 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
|
Line 581 | Line 652 |
---|
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'),
|
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'),
|
'S_IS_LOCKED' =>($topic_data['topic_status'] == ITEM_UNLOCKED) ? false : true,
| 'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true,
|
'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
|
'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
|
'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start"),
| 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")),
|
'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
|
'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
|
'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id),
| 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id),
|
'S_VIEWTOPIC' => true, 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
|
'S_VIEWTOPIC' => true, 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
|
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id),
| 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields),
|
'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
|
'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
|
| 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,
|
'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path,
| 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", 'U_FORUM' => $server_path,
|
Line 610 | Line 683 |
---|
'L_WATCH_TOPIC' => $s_watching_topic['title'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'],
|
'L_WATCH_TOPIC' => $s_watching_topic['title'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'],
|
'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1' : '',
| 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") : '',
|
'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&f=$forum_id") : '', 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id") : '',
|
'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&f=$forum_id") : '', 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id") : '',
|
'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&f=$forum_id&t=$topic_id") : '')
| 'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) : '')
|
);
// Does this topic contain a poll?
| );
// Does this topic contain a poll?
|
Line 663 | Line 736 |
---|
} }
|
} }
|
$s_can_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $forum_id)) || ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change'])) &&
| // Can not vote at all if no vote permission $s_can_vote = ($auth->acl_get('f_vote', $forum_id) &&
|
(($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) && $topic_data['topic_status'] != ITEM_LOCKED &&
|
(($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) && $topic_data['topic_status'] != ITEM_LOCKED &&
|
$topic_data['forum_status'] != ITEM_LOCKED) ? true : false;
| $topic_data['forum_status'] != ITEM_LOCKED && (!sizeof($cur_voted_id) || ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
|
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
if ($update && $s_can_vote) {
|
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
if ($update && $s_can_vote) {
|
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
| if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))
|
{
|
{
|
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start");
| $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start"));
|
meta_refresh(5, $redirect_url); if (!sizeof($voted_id))
| meta_refresh(5, $redirect_url); if (!sizeof($voted_id))
|
Line 686 | Line 761 |
---|
{ $message = 'TOO_MANY_VOTE_OPTIONS'; }
|
{ $message = 'TOO_MANY_VOTE_OPTIONS'; }
|
else
| else if (in_array(VOTE_CONVERTED, $cur_voted_id))
|
{ $message = 'VOTE_CONVERTED';
|
{ $message = 'VOTE_CONVERTED';
|
| } else { $message = 'FORM_INVALID';
|
}
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
| }
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
|
Line 754 | Line 833 |
---|
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now $db->sql_query($sql);
|
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now $db->sql_query($sql);
|
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start");
| $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start"));
|
meta_refresh(5, $redirect_url); trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
| meta_refresh(5, $redirect_url); trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
|
Line 803 | Line 882 |
---|
foreach ($poll_info as $poll_option) { $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
|
foreach ($poll_info as $poll_option) { $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
|
$option_pct_txt = sprintf("%.1d%%", ($option_pct * 100));
| $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
|
$template->assign_block_vars('poll_option', array( 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
| $template->assign_block_vars('poll_option', array( 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
|
Line 842 | Line 921 |
---|
// If the user is trying to reach the second half of the topic, fetch it starting from the end $store_reverse = false; $sql_limit = $config['posts_per_page'];
|
// If the user is trying to reach the second half of the topic, fetch it starting from the end $store_reverse = false; $sql_limit = $config['posts_per_page'];
|
| $sql_sort_order = $direction = '';
|
if ($start > $total_posts / 2) {
| if ($start > $total_posts / 2) {
|
Line 853 | Line 933 |
---|
}
// Select the sort order
|
}
// Select the sort order
|
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
| $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
|
$sql_start = max(0, $total_posts - $sql_limit - $start); } else { // Select the sort order
|
$sql_start = max(0, $total_posts - $sql_limit - $start); } else { // Select the sort order
|
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
| $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
$sql_start = $start;
|
$sql_start = $start;
|
| }
if (is_array($sort_by_sql[$sort_key])) { $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; } else { $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
|
}
// Container for user details, only process once
| }
// Container for user details, only process once
|
Line 871 | Line 960 |
---|
// Go ahead and pull all data for this topic $sql = 'SELECT p.post_id
|
// Go ahead and pull all data for this topic $sql = 'SELECT p.post_id
|
FROM ' . POSTS_TABLE . ' p' . (($sort_by_sql[$sort_key][0] == 'u') ? ', ' . USERS_TABLE . ' u': '') . "
| FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
WHERE p.topic_id = $topic_id " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
|
WHERE p.topic_id = $topic_id " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
|
" . (($sort_by_sql[$sort_key][0] == 'u') ? 'AND u.user_id = p.poster_id': '') . "
| " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
$limit_posts_time ORDER BY $sql_sort_order"; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
| $limit_posts_time ORDER BY $sql_sort_order"; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
Line 882 | Line 971 |
---|
$i = ($store_reverse) ? $sql_limit - 1 : 0; while ($row = $db->sql_fetchrow($result)) {
|
$i = ($store_reverse) ? $sql_limit - 1 : 0; while ($row = $db->sql_fetchrow($result)) {
|
$post_list[$i] = $row['post_id'];
| $post_list[$i] = (int) $row['post_id'];
|
($store_reverse) ? $i-- : $i++; } $db->sql_freeresult($result);
| ($store_reverse) ? $i-- : $i++; } $db->sql_freeresult($result);
|
Line 924 | Line 1013 |
---|
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
| $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
|
// Posts are stored in the $rowset array while $attach_list, $user_cache // and the global bbcode_bitfield are built
| // Posts are stored in the $rowset array while $attach_list, $user_cache // and the global bbcode_bitfield are built
|
Line 936 | Line 1025 |
---|
$max_post_time = $row['post_time']; }
|
$max_post_time = $row['post_time']; }
|
$poster_id = $row['poster_id'];
| $poster_id = (int) $row['poster_id'];
|
// Does post have an attachment? If so, add it to the list if ($row['post_attachment'] && $config['allow_attachments']) {
|
// Does post have an attachment? If so, add it to the list if ($row['post_attachment'] && $config['allow_attachments']) {
|
$attach_list[] = $row['post_id'];
| $attach_list[] = (int) $row['post_id'];
|
if ($row['post_approved']) {
| if ($row['post_approved']) {
|
Line 964 | Line 1053 |
---|
'post_edit_time' => $row['post_edit_time'], 'post_edit_reason' => $row['post_edit_reason'], 'post_edit_user' => $row['post_edit_user'],
|
'post_edit_time' => $row['post_edit_time'], 'post_edit_reason' => $row['post_edit_reason'], 'post_edit_user' => $row['post_edit_user'],
|
| 'post_edit_locked' => $row['post_edit_locked'],
|
// Make sure the icon actually exists 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
| // Make sure the icon actually exists 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
|
Line 1005 | Line 1095 |
---|
'sig_bbcode_bitfield' => '',
'online' => false,
|
'sig_bbcode_bitfield' => '',
'online' => false,
|
'avatar' => '',
| 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
|
'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '',
| 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '',
|
Line 1029 | Line 1119 |
---|
'warnings' => 0, 'allow_pm' => 0, );
|
'warnings' => 0, 'allow_pm' => 0, );
|
| get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
} else {
| } else {
|
Line 1072 | Line 1164 |
---|
'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '',
|
'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '',
|
'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'search_author=' . urlencode($row['username']) .'&sr=posts') : '',
| 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '',
'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
|
);
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
);
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
| if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
{ $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); }
| { $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); }
|
Line 1088 | Line 1185 |
---|
if (!empty($row['user_icq'])) {
|
if (!empty($row['user_icq'])) {
|
$user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'];
| $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/';
|
$user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />'; } else
| $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />'; } else
|
Line 1123 | Line 1220 |
---|
// Load custom profile fields if ($config['load_cpf_viewtopic'])
|
// Load custom profile fields if ($config['load_cpf_viewtopic'])
|
| { if (!class_exists('custom_profile'))
|
{ include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
|
{ include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
|
| }
|
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
|
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
|
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $id_cache);
| $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. $profile_fields_cache = array(); foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) { $profile_fields_cache[$profile_user_id] = array(); foreach ($profile_fields as $used_ident => $profile_field) { if ($profile_field['data']['field_show_on_vt']) { $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field; } } } unset($profile_fields_tmp);
|
}
// Generate online information for user
| }
// Generate online information for user
|
Line 1329 | Line 1444 |
---|
$display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']); }
|
$display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']); }
|
$l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time']), $row['post_edit_count']);
| $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
|
} else {
| } else {
|
Line 1348 | Line 1463 |
---|
$display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']); }
|
$display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']); }
|
$l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time']), $row['post_edit_count']);
| $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
|
} } else
| } } else
|
Line 1362 | Line 1477 |
---|
// It is safe to grab the username from the user cache array, we are at the last // post and only the topic poster and last poster are allowed to bump. // Admins and mods are bound to the above rules too...
|
// It is safe to grab the username from the user cache array, we are at the last // post and only the topic poster and last poster are allowed to bump. // Admins and mods are bound to the above rules too...
|
$l_bumped_by = '<br /><br />' . sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time']));
| $l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true));
|
} else {
| } else {
|
Line 1384 | Line 1499 |
---|
{ $s_first_unread = $first_unread = true; }
|
{ $s_first_unread = $first_unread = true; }
|
| $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) && $topic_data['topic_status'] != ITEM_LOCKED && !$row['post_edit_locked'] && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']) )));
$quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id)) );
$delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ( $user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $topic_data['topic_status'] != ITEM_LOCKED && $topic_data['topic_last_post_id'] == $row['post_id'] && ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) && // we do not want to allow removal of the last post if a moderator locked it! !$row['post_edit_locked'] )));
|
// $postrow = array(
|
// $postrow = array(
|
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
| 'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
'RANK_TITLE' => $user_cache[$poster_id]['rank_title'], 'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
| 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'], 'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
|
Line 1402 | Line 1539 |
---|
'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'], 'POSTER_AGE' => $user_cache[$poster_id]['age'],
|
'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'], 'POSTER_AGE' => $user_cache[$poster_id]['age'],
|
'POST_DATE' => $user->format_date($row['post_time']),
| 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
|
'POST_SUBJECT' => $row['post_subject'], 'MESSAGE' => $message, 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
| 'POST_SUBJECT' => $row['post_subject'], 'MESSAGE' => $message, 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
|
Line 1410 | Line 1547 |
---|
'EDIT_REASON' => $row['post_edit_reason'], 'BUMPED_MESSAGE' => $l_bumped_by,
|
'EDIT_REASON' => $row['post_edit_reason'], 'BUMPED_MESSAGE' => $l_bumped_by,
|
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
| 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
|
'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
| 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
|
Line 1418 | Line 1555 |
---|
'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
|
'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
|
'U_EDIT' => (!$user->data['is_registered']) ? '' : ((($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_edit', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : ''), 'U_QUOTE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',
| 'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '', 'U_QUOTE' => ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',
|
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',
|
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',
|
'U_DELETE' => (!$user->data['is_registered']) ? '' : ((($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $topic_data['topic_last_post_id'] == $row['post_id'] && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : ''),
| 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '',
|
'U_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'],
| 'U_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'],
|
Line 1444 | Line 1581 |
---|
'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
'POST_ID' => $row['post_id'],
|
'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
'POST_ID' => $row['post_id'],
|
| 'POST_NUMBER' => $i + $start + 1,
|
'POSTER_ID' => $poster_id,
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
| 'POSTER_ID' => $poster_id,
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
|
Line 1494 | Line 1632 |
---|
} unset($rowset, $user_cache);
|
} unset($rowset, $user_cache);
|
// Update topic view and if necessary attachment view counters ... but only if this is the first 'page view' if (isset($user->data['session_page']) && strpos($user->data['session_page'], '&t=' . $topic_id) === false)
| // Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view' if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created'])))
|
{ $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
| { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
|
Line 1510 | Line 1648 |
---|
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); $db->sql_query($sql); }
|
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); $db->sql_query($sql); }
|
| }
// Get last post time for all global announcements // to keep proper forums tracking if ($topic_data['topic_type'] == POST_GLOBAL) { $sql = 'SELECT topic_last_post_time as forum_last_post_time FROM ' . TOPICS_TABLE . ' WHERE forum_id = 0 ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, 1); $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result);
$sql = 'SELECT mark_time as forum_mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE forum_id = 0 AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time'); $db->sql_freeresult($result);
|
}
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) {
|
}
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) {
|
markread('topic', $forum_id, $topic_id, $max_post_time);
| markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time);
|
// Update forum info
|
// Update forum info
|
$all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
| $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
|
} else {
| } else {
|
Line 1559 | Line 1718 |
---|
)); } }
|
)); } }
|
| // let's set up quick_reply $s_quick_reply = false; if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id)) { // Quick reply enabled forum $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false; }
if ($s_can_vote || $s_quick_reply) { add_form_key('posting');
if ($s_quick_reply) { $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig'); $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id); $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id); $s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']);
$qr_hidden_fields = array( 'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], 'lastclick' => (int) time(), 'topic_id' => (int) $topic_data['topic_id'], 'forum_id' => (int) $forum_id, );
// Originally we use checkboxes and check with isset(), so we only provide them if they would be checked (!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true; (!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true; (!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true; ($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true; ($s_notify) ? $qr_hidden_fields['notify'] = 1 : true; ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true;
$template->assign_vars(array( 'S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']), )); } } // now I have the urge to wash my hands :(
|
// We overwrite $_REQUEST['f'] if there is no forum specified // to be able to display the correct online list.
| // We overwrite $_REQUEST['f'] if there is no forum specified // to be able to display the correct online list.
|
Line 1566 | Line 1770 |
---|
if (empty($_REQUEST['f'])) { $_REQUEST['f'] = $forum_id;
|
if (empty($_REQUEST['f'])) { $_REQUEST['f'] = $forum_id;
|
| }
// We need to do the same with the topic_id. See #53025. if (empty($_REQUEST['t']) && !empty($topic_id)) { $_REQUEST['t'] = $topic_id;
|
}
// Output the page
|
}
// Output the page
|
page_header($user->lang['VIEW_TOPIC'] .' - ' . $topic_data['topic_title']);
| page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id);
|
$template->set_filenames(array( 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
| $template->set_filenames(array( 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
|