diff options
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r-- | phpBB/viewtopic.php | 113 |
1 files changed, 25 insertions, 88 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 01cd6a28a8..e441ac49b0 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -152,26 +152,12 @@ if ($view && !$post_id) else { $topic_id = $row['topic_id']; - - // Check for global announcement correctness? - if (!$row['forum_id'] && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if ($row['forum_id']) - { - $forum_id = $row['forum_id']; - } + $forum_id = $row['forum_id']; } } } - // Check for global announcement correctness? - if ((!isset($row) || !$row['forum_id']) && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if (isset($row) && $row['forum_id']) + if (isset($row) && $row['forum_id']) { $forum_id = $row['forum_id']; } @@ -186,13 +172,6 @@ $sql_array = array( '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) { @@ -247,26 +226,8 @@ else $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'; - -if (!$forum_id) -{ - // If it is a global announcement make sure to set the forum id to a postable forum - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . ' - AND f.forum_type = ' . FORUM_POST . ')'; -} -else -{ - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . " - AND f.forum_id = $forum_id)"; -} - -$sql_array['WHERE'] .= ')'; +$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; -// 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 -// is done so navigation, forum name, etc. remain consistent with where -// user clicked to view a global topic $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $topic_data = $db->sql_fetchrow($result); @@ -626,7 +587,7 @@ $template->assign_vars(array( '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), + 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $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 == 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]) : '', @@ -728,9 +689,9 @@ if (!empty($topic_data['poll_start'])) // Cookie based guest tracking ... I don't like this but hum ho // it's oft requested. This relies on "nice" users who don't feel // the need to delete cookies to mess with results. - if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id])) + if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, phpbb_request_interface::COOKIE)) { - $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]); + $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, phpbb_request_interface::COOKIE)); $cur_voted_id = array_map('intval', $cur_voted_id); } } @@ -889,7 +850,7 @@ if (!empty($topic_data['poll_start'])) 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'], 'POLL_OPTION_PERCENT' => $option_pct_txt, 'POLL_OPTION_PCT' => round($option_pct * 100), - 'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)), + 'POLL_OPTION_WIDTH' => round($option_pct * 250), 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false) ); } @@ -902,7 +863,7 @@ if (!empty($topic_data['poll_start'])) 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), - 'L_MAX_VOTES' => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']), + 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '', 'S_HAS_POLL' => true, @@ -991,7 +952,7 @@ if (!sizeof($post_list)) // We need to grab it because we do reverse ordering sometimes $max_post_time = 0; -$sql = $db->sql_build_query('SELECT', array( +$sql_ary = array( 'SELECT' => 'u.*, z.friend, z.foe, p.*', 'FROM' => array( @@ -1002,14 +963,15 @@ $sql = $db->sql_build_query('SELECT', array( 'LEFT_JOIN' => array( array( 'FROM' => array(ZEBRA_TABLE => 'z'), - 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id' - ) + 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', + ), ), 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' - AND u.user_id = p.poster_id' -)); + AND u.user_id = p.poster_id', +); +$sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst); @@ -1359,7 +1321,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) continue; } - $row =& $rowset[$post_list[$i]]; + $row = $rowset[$post_list[$i]]; $poster_id = $row['user_id']; // End signature parsing, only if needed @@ -1429,8 +1391,6 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) unset($post_storage_list); } - $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL']; - if ($row['post_edit_reason']) { // User having edited the post also being the post author? @@ -1443,7 +1403,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $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'], false, true), $row['post_edit_count']); + $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); } else { @@ -1462,7 +1422,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $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'], false, true), $row['post_edit_count']); + $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); } } else @@ -1567,7 +1527,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '#p' . $row['post_id'], + 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', @@ -1643,34 +1603,13 @@ if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($use } } -// 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]) { - markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time); + markread('topic', $forum_id, $topic_id, $max_post_time); // Update forum info - $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); + $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); } else { @@ -1760,19 +1699,19 @@ if ($s_can_vote || $s_quick_reply) // We overwrite $_REQUEST['f'] if there is no forum specified // to be able to display the correct online list. // One downside is that the user currently viewing this topic/post is not taken into account. -if (empty($_REQUEST['f'])) +if (!request_var('f', 0)) { - $_REQUEST['f'] = $forum_id; + $request->overwrite('f', $forum_id); } // We need to do the same with the topic_id. See #53025. -if (empty($_REQUEST['t']) && !empty($topic_id)) +if (!request_var('t', 0) && !empty($topic_id)) { - $_REQUEST['t'] = $topic_id; + $request->overwrite('t', $topic_id); } // Output the page -page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id); +page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id); $template->set_filenames(array( 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') @@ -1780,5 +1719,3 @@ $template->set_filenames(array( make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); page_footer(); - -?>
\ No newline at end of file |