root / trunk / phpBB / viewtopic.php
History | View | Annotate | Download (65.2 kB)
| 1 | 2 | thefinn | <?php
|
|---|---|---|---|
| 2 | 8146 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package phpBB3 |
| 5 | 8146 | acydburn | * @copyright (c) 2005 phpBB Group |
| 6 | 11653 | git-gate | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
| 7 | 5114 | acydburn | * |
| 8 | 5114 | acydburn | */ |
| 9 | 2 | thefinn | |
| 10 | 5114 | acydburn | /**
|
| 11 | 5883 | acydburn | * @ignore |
| 12 | 5114 | acydburn | */ |
| 13 | 2305 | psotfx | define('IN_PHPBB', true); |
| 14 | 7954 | acydburn | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 15 | 4441 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | 6002 | acydburn | include($phpbb_root_path . 'common.' . $phpEx); |
| 17 | 5247 | acydburn | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 18 | 6517 | acydburn | include($phpbb_root_path . 'includes/bbcode.' . $phpEx); |
| 19 | 2 | thefinn | |
| 20 | 3953 | psotfx | // Start session management
|
| 21 | 5247 | acydburn | $user->session_begin();
|
| 22 | 3953 | psotfx | $auth->acl($user->data); |
| 23 | 3953 | psotfx | |
| 24 | 3538 | psotfx | // Initial var setup
|
| 25 | 4578 | psotfx | $forum_id = request_var('f', 0); |
| 26 | 4578 | psotfx | $topic_id = request_var('t', 0); |
| 27 | 4578 | psotfx | $post_id = request_var('p', 0); |
| 28 | 5412 | davidmj | $voted_id = request_var('vote_id', array('' => 0)); |
| 29 | 1215 | dougk_ff7 | |
| 30 | 9712 | Kellanved | $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id; |
| 31 | 9712 | Kellanved | |
| 32 | 9712 | Kellanved | |
| 33 | 4578 | psotfx | $start = request_var('start', 0); |
| 34 | 4578 | psotfx | $view = request_var('view', ''); |
| 35 | 5068 | acydburn | |
| 36 | 8751 | Kellanved | $default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0; |
| 37 | 8751 | Kellanved | $default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'; |
| 38 | 8751 | Kellanved | $default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'; |
| 39 | 5068 | acydburn | |
| 40 | 8751 | Kellanved | $sort_days = request_var('st', $default_sort_days); |
| 41 | 8751 | Kellanved | $sort_key = request_var('sk', $default_sort_key); |
| 42 | 8751 | Kellanved | $sort_dir = request_var('sd', $default_sort_dir); |
| 43 | 8751 | Kellanved | |
| 44 | 4578 | psotfx | $update = request_var('update', false); |
| 45 | 4441 | psotfx | |
| 46 | 9688 | Kellanved | $s_can_vote = false; |
| 47 | 7920 | acydburn | /**
|
| 48 | 7920 | acydburn | * @todo normalize? |
| 49 | 7920 | acydburn | */ |
| 50 | 6002 | acydburn | $hilit_words = request_var('hilit', '', true); |
| 51 | 3538 | psotfx | |
| 52 | 3538 | psotfx | // Do we have a topic or post id?
|
| 53 | 4004 | psotfx | if (!$topic_id && !$post_id) |
| 54 | 81 | thefinn | {
|
| 55 | 3538 | psotfx | trigger_error('NO_TOPIC'); |
| 56 | 81 | thefinn | } |
| 57 | 2 | thefinn | |
| 58 | 2995 | psotfx | // Find topic id if user requested a newer or older topic
|
| 59 | 4441 | psotfx | if ($view && !$post_id) |
| 60 | 301 | thefinn | {
|
| 61 | 5137 | acydburn | if (!$forum_id) |
| 62 | 5137 | acydburn | {
|
| 63 | 6002 | acydburn | $sql = 'SELECT forum_id |
| 64 | 6002 | acydburn | FROM ' . TOPICS_TABLE . " |
| 65 | 5137 | acydburn | WHERE topic_id = $topic_id"; |
| 66 | 5137 | acydburn | $result = $db->sql_query($sql); |
| 67 | 5824 | acydburn | $forum_id = (int) $db->sql_fetchfield('forum_id'); |
| 68 | 5824 | acydburn | $db->sql_freeresult($result); |
| 69 | 5824 | acydburn | |
| 70 | 5824 | acydburn | if (!$forum_id) |
| 71 | 5137 | acydburn | {
|
| 72 | 5137 | acydburn | trigger_error('NO_TOPIC'); |
| 73 | 5137 | acydburn | } |
| 74 | 5137 | acydburn | } |
| 75 | 5137 | acydburn | |
| 76 | 4441 | psotfx | if ($view == 'unread') |
| 77 | 301 | thefinn | {
|
| 78 | 5272 | acydburn | // Get topic tracking info
|
| 79 | 5272 | acydburn | $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); |
| 80 | 3953 | psotfx | |
| 81 | 5272 | acydburn | $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; |
| 82 | 5272 | acydburn | |
| 83 | 6513 | acydburn | $sql = 'SELECT post_id, topic_id, forum_id |
| 84 | 6513 | acydburn | FROM ' . POSTS_TABLE . " |
| 85 | 6513 | acydburn | WHERE topic_id = $topic_id |
| 86 | 6513 | acydburn | " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " |
| 87 | 6513 | acydburn | AND post_time > $topic_last_read |
| 88 | 9983 | Kellanved | AND forum_id = $forum_id |
| 89 | 6513 | acydburn | ORDER BY post_time ASC";
|
| 90 | 5137 | acydburn | $result = $db->sql_query_limit($sql, 1); |
| 91 | 5824 | acydburn | $row = $db->sql_fetchrow($result); |
| 92 | 5824 | acydburn | $db->sql_freeresult($result); |
| 93 | 3953 | psotfx | |
| 94 | 5824 | acydburn | if (!$row) |
| 95 | 5137 | acydburn | {
|
| 96 | 6513 | acydburn | $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id |
| 97 | 6513 | acydburn | FROM ' . TOPICS_TABLE . ' |
| 98 | 6513 | acydburn | WHERE topic_id = ' . $topic_id; |
| 99 | 6513 | acydburn | $result = $db->sql_query($sql); |
| 100 | 6513 | acydburn | $row = $db->sql_fetchrow($result); |
| 101 | 6513 | acydburn | $db->sql_freeresult($result); |
| 102 | 6513 | acydburn | } |
| 103 | 6513 | acydburn | |
| 104 | 6513 | acydburn | if (!$row) |
| 105 | 6513 | acydburn | {
|
| 106 | 5137 | acydburn | // Setup user environment so we can process lang string
|
| 107 | 5137 | acydburn | $user->setup('viewtopic'); |
| 108 | 1093 | psotfx | |
| 109 | 6513 | acydburn | trigger_error('NO_TOPIC'); |
| 110 | 5137 | acydburn | } |
| 111 | 3953 | psotfx | |
| 112 | 5272 | acydburn | $post_id = $row['post_id']; |
| 113 | 5137 | acydburn | $topic_id = $row['topic_id']; |
| 114 | 1093 | psotfx | } |
| 115 | 4441 | psotfx | else if ($view == 'next' || $view == 'previous') |
| 116 | 1093 | psotfx | {
|
| 117 | 4441 | psotfx | $sql_condition = ($view == 'next') ? '>' : '<'; |
| 118 | 4441 | psotfx | $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; |
| 119 | 302 | thefinn | |
| 120 | 8023 | davidmj | $sql = 'SELECT forum_id, topic_last_post_time |
| 121 | 8023 | davidmj | FROM ' . TOPICS_TABLE . ' |
| 122 | 8023 | davidmj | WHERE topic_id = ' . $topic_id; |
| 123 | 8023 | davidmj | $result = $db->sql_query($sql); |
| 124 | 8023 | davidmj | $row = $db->sql_fetchrow($result); |
| 125 | 8023 | davidmj | $db->sql_freeresult($result); |
| 126 | 8023 | davidmj | |
| 127 | 5824 | acydburn | if (!$row) |
| 128 | 566 | psotfx | {
|
| 129 | 5858 | acydburn | $user->setup('viewtopic'); |
| 130 | 8228 | kellanved | // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
|
| 131 | 6002 | acydburn | trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); |
| 132 | 566 | psotfx | } |
| 133 | 566 | psotfx | else
|
| 134 | 566 | psotfx | {
|
| 135 | 8228 | kellanved | $sql = 'SELECT topic_id, forum_id |
| 136 | 8228 | kellanved | FROM ' . TOPICS_TABLE . ' |
| 137 | 8228 | kellanved | WHERE forum_id = ' . $row['forum_id'] . " |
| 138 | 8228 | kellanved | AND topic_moved_id = 0 |
| 139 | 8228 | kellanved | AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} |
| 140 | 8228 | kellanved | " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . " |
| 141 | 8228 | kellanved | ORDER BY topic_last_post_time $sql_ordering"; |
| 142 | 8228 | kellanved | $result = $db->sql_query_limit($sql, 1); |
| 143 | 8228 | kellanved | $row = $db->sql_fetchrow($result); |
| 144 | 8228 | kellanved | $db->sql_freeresult($result); |
| 145 | 6151 | naderman | |
| 146 | 8228 | kellanved | if (!$row) |
| 147 | 5137 | acydburn | {
|
| 148 | 8228 | kellanved | $user->setup('viewtopic'); |
| 149 | 8228 | kellanved | trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); |
| 150 | 5137 | acydburn | } |
| 151 | 8228 | kellanved | else
|
| 152 | 5137 | acydburn | {
|
| 153 | 8228 | kellanved | $topic_id = $row['topic_id']; |
| 154 | 11100 | git-gate | $forum_id = $row['forum_id']; |
| 155 | 5137 | acydburn | } |
| 156 | 566 | psotfx | } |
| 157 | 566 | psotfx | } |
| 158 | 5137 | acydburn | |
| 159 | 11100 | git-gate | if (isset($row) && $row['forum_id']) |
| 160 | 5137 | acydburn | {
|
| 161 | 5137 | acydburn | $forum_id = $row['forum_id']; |
| 162 | 5137 | acydburn | } |
| 163 | 301 | thefinn | } |
| 164 | 566 | psotfx | |
| 165 | 566 | psotfx | // This rather complex gaggle of code handles querying for topics but
|
| 166 | 566 | psotfx | // also allows for direct linking to a post (and the calculation of which
|
| 167 | 566 | psotfx | // page the post is on and the correct display of viewtopic)
|
| 168 | 5885 | davidmj | $sql_array = array( |
| 169 | 5957 | acydburn | 'SELECT' => 't.*, f.*', |
| 170 | 5471 | acydburn | |
| 171 | 8851 | acydburn | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 172 | 5885 | davidmj | ); |
| 173 | 5885 | davidmj | |
| 174 | 8971 | acydburn | // The FROM-Order is quite important here, else t.* columns can not be correctly bound.
|
| 175 | 8851 | acydburn | if ($post_id) |
| 176 | 8851 | acydburn | {
|
| 177 | 11362 | git-gate | $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id'; |
| 178 | 8851 | acydburn | $sql_array['FROM'][POSTS_TABLE] = 'p'; |
| 179 | 8851 | acydburn | } |
| 180 | 8851 | acydburn | |
| 181 | 8851 | acydburn | // Topics table need to be the last in the chain
|
| 182 | 8851 | acydburn | $sql_array['FROM'][TOPICS_TABLE] = 't'; |
| 183 | 8851 | acydburn | |
| 184 | 5117 | acydburn | if ($user->data['is_registered']) |
| 185 | 3007 | ludovic_arnaud | {
|
| 186 | 5885 | davidmj | $sql_array['SELECT'] .= ', tw.notify_status'; |
| 187 | 6002 | acydburn | $sql_array['LEFT_JOIN'] = array(); |
| 188 | 6002 | acydburn | |
| 189 | 6002 | acydburn | $sql_array['LEFT_JOIN'][] = array( |
| 190 | 5885 | davidmj | 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'), |
| 191 | 5885 | davidmj | 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id' |
| 192 | 5885 | davidmj | ); |
| 193 | 5272 | acydburn | |
| 194 | 5272 | acydburn | if ($config['allow_bookmarks']) |
| 195 | 5272 | acydburn | {
|
| 196 | 7497 | acydburn | $sql_array['SELECT'] .= ', bm.topic_id as bookmarked'; |
| 197 | 6002 | acydburn | $sql_array['LEFT_JOIN'][] = array( |
| 198 | 5885 | davidmj | 'FROM' => array(BOOKMARKS_TABLE => 'bm'), |
| 199 | 5885 | davidmj | 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id' |
| 200 | 5885 | davidmj | ); |
| 201 | 5272 | acydburn | } |
| 202 | 5272 | acydburn | |
| 203 | 5272 | acydburn | if ($config['load_db_lastread']) |
| 204 | 5272 | acydburn | {
|
| 205 | 5885 | davidmj | $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time'; |
| 206 | 6151 | naderman | |
| 207 | 6002 | acydburn | $sql_array['LEFT_JOIN'][] = array( |
| 208 | 5885 | davidmj | 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), |
| 209 | 5885 | davidmj | 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id' |
| 210 | 5885 | davidmj | ); |
| 211 | 6002 | acydburn | |
| 212 | 6002 | acydburn | $sql_array['LEFT_JOIN'][] = array( |
| 213 | 5885 | davidmj | 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), |
| 214 | 5885 | davidmj | 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id' |
| 215 | 5885 | davidmj | ); |
| 216 | 5272 | acydburn | } |
| 217 | 3007 | ludovic_arnaud | } |
| 218 | 3007 | ludovic_arnaud | |
| 219 | 5885 | davidmj | if (!$post_id) |
| 220 | 5885 | davidmj | {
|
| 221 | 5885 | davidmj | $sql_array['WHERE'] = "t.topic_id = $topic_id"; |
| 222 | 5885 | davidmj | } |
| 223 | 5885 | davidmj | else
|
| 224 | 5885 | davidmj | {
|
| 225 | 9983 | Kellanved | $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; |
| 226 | 5885 | davidmj | } |
| 227 | 5854 | davidmj | |
| 228 | 11100 | git-gate | $sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; |
| 229 | 6135 | acydburn | |
| 230 | 5885 | davidmj | $sql = $db->sql_build_query('SELECT', $sql_array); |
| 231 | 2673 | psotfx | $result = $db->sql_query($sql); |
| 232 | 6002 | acydburn | $topic_data = $db->sql_fetchrow($result); |
| 233 | 6002 | acydburn | $db->sql_freeresult($result); |
| 234 | 355 | psotfx | |
| 235 | 9983 | Kellanved | // link to unapproved post or incorrect link
|
| 236 | 6002 | acydburn | if (!$topic_data) |
| 237 | 81 | thefinn | {
|
| 238 | 4679 | acydburn | // If post_id was submitted, we try at least to display the topic as a last resort...
|
| 239 | 9431 | acydburn | if ($post_id && $topic_id) |
| 240 | 4679 | acydburn | {
|
| 241 | 9431 | acydburn | redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); |
| 242 | 4679 | acydburn | } |
| 243 | 5858 | acydburn | |
| 244 | 3538 | psotfx | trigger_error('NO_TOPIC'); |
| 245 | 81 | thefinn | } |
| 246 | 566 | psotfx | |
| 247 | 9983 | Kellanved | $forum_id = (int) $topic_data['forum_id']; |
| 248 | 5906 | davidmj | // This is for determining where we are (page)
|
| 249 | 5906 | davidmj | if ($post_id) |
| 250 | 5906 | davidmj | {
|
| 251 | 9983 | Kellanved | // are we where we are supposed to be?
|
| 252 | 9985 | Kellanved | if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id'])) |
| 253 | 9983 | Kellanved | {
|
| 254 | 9983 | Kellanved | // If post_id was submitted, we try at least to display the topic as a last resort...
|
| 255 | 9985 | Kellanved | if ($topic_id) |
| 256 | 9983 | Kellanved | {
|
| 257 | 9983 | Kellanved | redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : ''))); |
| 258 | 9983 | Kellanved | } |
| 259 | 9983 | Kellanved | |
| 260 | 9983 | Kellanved | trigger_error('NO_TOPIC'); |
| 261 | 9983 | Kellanved | } |
| 262 | 6411 | acydburn | if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) |
| 263 | 6411 | acydburn | {
|
| 264 | 6411 | acydburn | $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a'; |
| 265 | 6002 | acydburn | |
| 266 | 6411 | acydburn | if ($sort_dir == $check_sort) |
| 267 | 6411 | acydburn | {
|
| 268 | 7447 | acydburn | $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; |
| 269 | 6411 | acydburn | } |
| 270 | 6411 | acydburn | else
|
| 271 | 6411 | acydburn | {
|
| 272 | 7447 | acydburn | $topic_data['prev_posts'] = 0; |
| 273 | 6411 | acydburn | } |
| 274 | 6411 | acydburn | } |
| 275 | 6411 | acydburn | else
|
| 276 | 6411 | acydburn | {
|
| 277 | 11332 | git-gate | $sql = 'SELECT COUNT(p.post_id) AS prev_posts |
| 278 | 11332 | git-gate | FROM ' . POSTS_TABLE . " p |
| 279 | 11332 | git-gate | WHERE p.topic_id = {$topic_data['topic_id']} |
| 280 | 11362 | git-gate | " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : ''); |
| 281 | 6411 | acydburn | |
| 282 | 11362 | git-gate | if ($sort_dir == 'd') |
| 283 | 11362 | git-gate | {
|
| 284 | 11362 | git-gate | $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']}))"; |
| 285 | 11362 | git-gate | } |
| 286 | 11362 | git-gate | else
|
| 287 | 11362 | git-gate | {
|
| 288 | 11362 | git-gate | $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']}))"; |
| 289 | 11362 | git-gate | } |
| 290 | 11362 | git-gate | |
| 291 | 6411 | acydburn | $result = $db->sql_query($sql); |
| 292 | 6411 | acydburn | $row = $db->sql_fetchrow($result); |
| 293 | 6411 | acydburn | $db->sql_freeresult($result); |
| 294 | 6411 | acydburn | |
| 295 | 7447 | acydburn | $topic_data['prev_posts'] = $row['prev_posts'] - 1; |
| 296 | 6411 | acydburn | } |
| 297 | 5906 | davidmj | } |
| 298 | 5906 | davidmj | |
| 299 | 9984 | Kellanved | $topic_id = (int) $topic_data['topic_id']; |
| 300 | 5027 | acydburn | //
|
| 301 | 5272 | acydburn | $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; |
| 302 | 4925 | acydburn | |
| 303 | 4577 | acydburn | // Check sticky/announcement time limit
|
| 304 | 5272 | acydburn | if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) |
| 305 | 4577 | acydburn | {
|
| 306 | 4947 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . ' |
| 307 | 4577 | acydburn | SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 |
| 308 | 4577 | acydburn | WHERE topic_id = ' . $topic_id; |
| 309 | 4577 | acydburn | $db->sql_query($sql); |
| 310 | 5027 | acydburn | |
| 311 | 5272 | acydburn | $topic_data['topic_type'] = POST_NORMAL; |
| 312 | 5272 | acydburn | $topic_data['topic_time_limit'] = 0; |
| 313 | 4577 | acydburn | } |
| 314 | 4577 | acydburn | |
| 315 | 3953 | psotfx | // Setup look and feel
|
| 316 | 5272 | acydburn | $user->setup('viewtopic', $topic_data['forum_style']); |
| 317 | 3869 | psotfx | |
| 318 | 5272 | acydburn | if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id)) |
| 319 | 3969 | psotfx | {
|
| 320 | 4204 | psotfx | trigger_error('NO_TOPIC'); |
| 321 | 3969 | psotfx | } |
| 322 | 3969 | psotfx | |
| 323 | 377 | psotfx | // Start auth check
|
| 324 | 3712 | psotfx | if (!$auth->acl_get('f_read', $forum_id)) |
| 325 | 377 | psotfx | {
|
| 326 | 3650 | psotfx | if ($user->data['user_id'] != ANONYMOUS) |
| 327 | 2079 | psotfx | {
|
| 328 | 6002 | acydburn | trigger_error('SORRY_AUTH_READ'); |
| 329 | 2079 | psotfx | } |
| 330 | 421 | thefinn | |
| 331 | 4970 | psotfx | login_box('', $user->lang['LOGIN_VIEWFORUM']); |
| 332 | 377 | psotfx | } |
| 333 | 377 | psotfx | |
| 334 | 4204 | psotfx | // Forum is passworded ... check whether access has been granted to this
|
| 335 | 4204 | psotfx | // user this session, if not show login box
|
| 336 | 5272 | acydburn | if ($topic_data['forum_password']) |
| 337 | 4167 | psotfx | {
|
| 338 | 4204 | psotfx | login_forum_box($topic_data);
|
| 339 | 4167 | psotfx | } |
| 340 | 4167 | psotfx | |
| 341 | 4912 | acydburn | // Redirect to login or to the correct post upon emailed notification links
|
| 342 | 4912 | acydburn | if (isset($_GET['e'])) |
| 343 | 4577 | acydburn | {
|
| 344 | 5078 | psotfx | $jump_to = request_var('e', 0); |
| 345 | 5078 | psotfx | |
| 346 | 6015 | acydburn | $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); |
| 347 | 4915 | acydburn | |
| 348 | 4912 | acydburn | if ($user->data['user_id'] == ANONYMOUS) |
| 349 | 4912 | acydburn | {
|
| 350 | 6002 | acydburn | login_box($redirect_url . "&p=$post_id&e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']); |
| 351 | 4912 | acydburn | } |
| 352 | 5078 | psotfx | |
| 353 | 5078 | psotfx | if ($jump_to > 0) |
| 354 | 4912 | acydburn | {
|
| 355 | 4912 | acydburn | // We direct the already logged in user to the correct post...
|
| 356 | 6015 | acydburn | redirect($redirect_url . ((!$post_id) ? "&p=$jump_to" : "&p=$post_id") . "#p$jump_to"); |
| 357 | 4912 | acydburn | } |
| 358 | 4577 | acydburn | } |
| 359 | 4577 | acydburn | |
| 360 | 3538 | psotfx | // What is start equal to?
|
| 361 | 5272 | acydburn | if ($post_id) |
| 362 | 2079 | psotfx | {
|
| 363 | 7447 | acydburn | $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page']; |
| 364 | 2079 | psotfx | } |
| 365 | 2079 | psotfx | |
| 366 | 5272 | acydburn | // Get topic tracking info
|
| 367 | 5272 | acydburn | if (!isset($topic_tracking_info)) |
| 368 | 5272 | acydburn | {
|
| 369 | 6256 | acydburn | $topic_tracking_info = array(); |
| 370 | 6256 | acydburn | |
| 371 | 5272 | acydburn | // Get topic tracking info
|
| 372 | 5272 | acydburn | if ($config['load_db_lastread'] && $user->data['is_registered']) |
| 373 | 5272 | acydburn | {
|
| 374 | 5272 | acydburn | $tmp_topic_data = array($topic_id => $topic_data); |
| 375 | 5272 | acydburn | $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time'])); |
| 376 | 5272 | acydburn | unset($tmp_topic_data); |
| 377 | 5272 | acydburn | } |
| 378 | 6256 | acydburn | else if ($config['load_anon_lastread'] || $user->data['is_registered']) |
| 379 | 5272 | acydburn | {
|
| 380 | 5272 | acydburn | $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); |
| 381 | 5272 | acydburn | } |
| 382 | 5272 | acydburn | } |
| 383 | 5272 | acydburn | |
| 384 | 2673 | psotfx | // Post ordering options
|
| 385 | 5705 | naderman | $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']); |
| 386 | 3538 | psotfx | |
| 387 | 3286 | psotfx | $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); |
| 388 | 9523 | Kellanved | $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id')); |
| 389 | 9523 | Kellanved | $join_user_sql = array('a' => true, 't' => false, 's' => false); |
| 390 | 862 | psotfx | |
| 391 | 3961 | psotfx | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
| 392 | 3538 | psotfx | |
| 393 | 8751 | Kellanved | 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); |
| 394 | 8751 | Kellanved | |
| 395 | 3566 | psotfx | // Obtain correct post count and ordering SQL if user has
|
| 396 | 3566 | psotfx | // requested anything different
|
| 397 | 3561 | ludovic_arnaud | if ($sort_days) |
| 398 | 2673 | psotfx | {
|
| 399 | 3561 | ludovic_arnaud | $min_post_time = time() - ($sort_days * 86400); |
| 400 | 2110 | psotfx | |
| 401 | 3561 | ludovic_arnaud | $sql = 'SELECT COUNT(post_id) AS num_posts |
| 402 | 3561 | ludovic_arnaud | FROM ' . POSTS_TABLE . " |
| 403 | 3561 | ludovic_arnaud | WHERE topic_id = $topic_id |
| 404 | 3561 | ludovic_arnaud | AND post_time >= $min_post_time |
| 405 | 5025 | acydburn | " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1'); |
| 406 | 3561 | ludovic_arnaud | $result = $db->sql_query($sql); |
| 407 | 6002 | acydburn | $total_posts = (int) $db->sql_fetchfield('num_posts'); |
| 408 | 6002 | acydburn | $db->sql_freeresult($result); |
| 409 | 862 | psotfx | |
| 410 | 6002 | acydburn | $limit_posts_time = "AND p.post_time >= $min_post_time "; |
| 411 | 6002 | acydburn | |
| 412 | 4031 | psotfx | if (isset($_POST['sort'])) |
| 413 | 4031 | psotfx | {
|
| 414 | 4031 | psotfx | $start = 0; |
| 415 | 4031 | psotfx | } |
| 416 | 862 | psotfx | } |
| 417 | 3567 | psotfx | else
|
| 418 | 3567 | psotfx | {
|
| 419 | 3567 | psotfx | $total_posts = $topic_replies + 1; |
| 420 | 3567 | psotfx | $limit_posts_time = ''; |
| 421 | 3567 | psotfx | } |
| 422 | 3561 | ludovic_arnaud | |
| 423 | 4912 | acydburn | // Was a highlight request part of the URI?
|
| 424 | 4912 | acydburn | $highlight_match = $highlight = ''; |
| 425 | 4912 | acydburn | if ($hilit_words) |
| 426 | 4522 | psotfx | {
|
| 427 | 4912 | acydburn | foreach (explode(' ', trim($hilit_words)) as $word) |
| 428 | 4912 | acydburn | {
|
| 429 | 4912 | acydburn | if (trim($word)) |
| 430 | 4912 | acydburn | {
|
| 431 | 7559 | naderman | $word = str_replace('\*', '\w+?', preg_quote($word, '#')); |
| 432 | 7559 | naderman | $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word); |
| 433 | 7559 | naderman | $highlight_match .= (($highlight_match != '') ? '|' : '') . $word; |
| 434 | 4912 | acydburn | } |
| 435 | 4912 | acydburn | } |
| 436 | 4912 | acydburn | |
| 437 | 5034 | acydburn | $highlight = urlencode($hilit_words); |
| 438 | 4522 | psotfx | } |
| 439 | 862 | psotfx | |
| 440 | 6165 | acydburn | // Make sure $start is set to the last page if it exceeds the amount
|
| 441 | 9022 | toonarmy | if ($start < 0 || $start >= $total_posts) |
| 442 | 6165 | acydburn | {
|
| 443 | 6165 | acydburn | $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; |
| 444 | 6165 | acydburn | } |
| 445 | 6165 | acydburn | |
| 446 | 4912 | acydburn | // General Viewtopic URL for return links
|
| 447 | 10633 | git-gate | $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" : '')); |
| 448 | 4912 | acydburn | |
| 449 | 4522 | psotfx | // Are we watching this topic?
|
| 450 | 8350 | acydburn | $s_watching_topic = array( |
| 451 | 8350 | acydburn | 'link' => '', |
| 452 | 8350 | acydburn | 'title' => '', |
| 453 | 8350 | acydburn | 'is_watching' => false, |
| 454 | 8350 | acydburn | ); |
| 455 | 7736 | acydburn | |
| 456 | 11515 | git-gate | if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify']) |
| 457 | 4522 | psotfx | {
|
| 458 | 11515 | git-gate | $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null; |
| 459 | 11515 | git-gate | watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']); |
| 460 | 8595 | acydburn | |
| 461 | 8595 | acydburn | // Reset forum notification if forum notify is set
|
| 462 | 8595 | acydburn | if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) |
| 463 | 8595 | acydburn | {
|
| 464 | 8595 | acydburn | $s_watching_forum = $s_watching_topic; |
| 465 | 8595 | acydburn | watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0); |
| 466 | 8595 | acydburn | } |
| 467 | 4522 | psotfx | } |
| 468 | 4522 | psotfx | |
| 469 | 4912 | acydburn | // Bookmarks
|
| 470 | 5117 | acydburn | if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0)) |
| 471 | 4912 | acydburn | {
|
| 472 | 8944 | acydburn | if (check_link_hash(request_var('hash', ''), "topic_$topic_id")) |
| 473 | 4912 | acydburn | {
|
| 474 | 8775 | Kellanved | if (!$topic_data['bookmarked']) |
| 475 | 8775 | Kellanved | {
|
| 476 | 8775 | Kellanved | $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
| 477 | 8775 | Kellanved | 'user_id' => $user->data['user_id'], |
| 478 | 8775 | Kellanved | 'topic_id' => $topic_id, |
| 479 | 8775 | Kellanved | )); |
| 480 | 8775 | Kellanved | $db->sql_query($sql); |
| 481 | 8775 | Kellanved | } |
| 482 | 8775 | Kellanved | else
|
| 483 | 8775 | Kellanved | {
|
| 484 | 8775 | Kellanved | $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . " |
| 485 | 8775 | Kellanved | WHERE user_id = {$user->data['user_id']} |
| 486 | 8775 | Kellanved | AND topic_id = $topic_id"; |
| 487 | 8775 | Kellanved | $db->sql_query($sql); |
| 488 | 8775 | Kellanved | } |
| 489 | 8775 | Kellanved | $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); |
| 490 | 4912 | acydburn | } |
| 491 | 4912 | acydburn | else
|
| 492 | 4912 | acydburn | {
|
| 493 | 8775 | Kellanved | $message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); |
| 494 | 4912 | acydburn | } |
| 495 | 4912 | acydburn | meta_refresh(3, $viewtopic_url); |
| 496 | 5078 | psotfx | |
| 497 | 4912 | acydburn | trigger_error($message); |
| 498 | 4912 | acydburn | } |
| 499 | 4912 | acydburn | |
| 500 | 4150 | psotfx | // Grab ranks
|
| 501 | 6572 | acydburn | $ranks = $cache->obtain_ranks(); |
| 502 | 81 | thefinn | |
| 503 | 3357 | psotfx | // Grab icons
|
| 504 | 6572 | acydburn | $icons = $cache->obtain_icons(); |
| 505 | 2673 | psotfx | |
| 506 | 4912 | acydburn | // Grab extensions
|
| 507 | 4912 | acydburn | $extensions = array(); |
| 508 | 5272 | acydburn | if ($topic_data['topic_attachment']) |
| 509 | 1830 | psotfx | {
|
| 510 | 6816 | acydburn | $extensions = $cache->obtain_attach_extensions($forum_id); |
| 511 | 1830 | psotfx | } |
| 512 | 1830 | psotfx | |
| 513 | 3538 | psotfx | // Forum rules listing
|
| 514 | 2673 | psotfx | $s_forum_rules = ''; |
| 515 | 5765 | acydburn | gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); |
| 516 | 1452 | bartvb | |
| 517 | 3538 | psotfx | // Quick mod tools
|
| 518 | 6149 | acydburn | $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; |
| 519 | 5986 | naderman | |
| 520 | 2708 | psotfx | $topic_mod = ''; |
| 521 | 6317 | acydburn | $topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : ''; |
| 522 | 3876 | ludovic_arnaud | $topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : ''; |
| 523 | 6894 | acydburn | $topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : ''; |
| 524 | 3712 | psotfx | $topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : ''; |
| 525 | 7261 | naderman | $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : ''; |
| 526 | 7261 | naderman | $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : ''; |
| 527 | 5779 | naderman | $topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : ''; |
| 528 | 6351 | acydburn | $topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : ''; |
| 529 | 5986 | naderman | $topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : ''; |
| 530 | 5986 | naderman | $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : ''; |
| 531 | 5986 | naderman | $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : ''; |
| 532 | 5460 | grahamje | $topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : ''; |
| 533 | 1452 | bartvb | |
| 534 | 2673 | psotfx | // If we've got a hightlight set pass it on to pagination.
|
| 535 | 8751 | Kellanved | $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); |
| 536 | 2673 | psotfx | |
| 537 | 3359 | ludovic_arnaud | // Navigation links
|
| 538 | 3359 | ludovic_arnaud | generate_forum_nav($topic_data);
|
| 539 | 3347 | psotfx | |
| 540 | 4903 | acydburn | // Forum Rules
|
| 541 | 4903 | acydburn | generate_forum_rules($topic_data);
|
| 542 | 4903 | acydburn | |
| 543 | 3063 | psotfx | // Moderators
|
| 544 | 3063 | psotfx | $forum_moderators = array(); |
| 545 | 9640 | acydburn | if ($config['load_moderators']) |
| 546 | 9640 | acydburn | {
|
| 547 | 9640 | acydburn | get_moderators($forum_moderators, $forum_id); |
| 548 | 9640 | acydburn | } |
| 549 | 3063 | psotfx | |
| 550 | 3347 | psotfx | // This is only used for print view so ...
|
| 551 | 5272 | acydburn | $server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/'; |
| 552 | 3071 | psotfx | |
| 553 | 3953 | psotfx | // Replace naughty words in title
|
| 554 | 5272 | acydburn | $topic_data['topic_title'] = censor_text($topic_data['topic_title']); |
| 555 | 3953 | psotfx | |
| 556 | 11189 | git-gate | $s_search_hidden_fields = array( |
| 557 | 11189 | git-gate | 't' => $topic_id, |
| 558 | 11189 | git-gate | 'sf' => 'msgonly', |
| 559 | 11189 | git-gate | ); |
| 560 | 11189 | git-gate | if ($_SID) |
| 561 | 11189 | git-gate | {
|
| 562 | 11189 | git-gate | $s_search_hidden_fields['sid'] = $_SID; |
| 563 | 11189 | git-gate | } |
| 564 | 11189 | git-gate | |
| 565 | 11618 | git-gate | if (!empty($_EXTRA_URL)) |
| 566 | 11618 | git-gate | {
|
| 567 | 11618 | git-gate | foreach ($_EXTRA_URL as $url_param) |
| 568 | 11618 | git-gate | {
|
| 569 | 11618 | git-gate | $url_param = explode('=', $url_param, 2); |
| 570 | 11681 | git-gate | $s_search_hidden_fields[$url_param[0]] = $url_param[1]; |
| 571 | 11618 | git-gate | } |
| 572 | 11618 | git-gate | } |
| 573 | 11618 | git-gate | |
| 574 | 1851 | psotfx | // Send vars to template
|
| 575 | 355 | psotfx | $template->assign_vars(array( |
| 576 | 2972 | psotfx | 'FORUM_ID' => $forum_id, |
| 577 | 5272 | acydburn | 'FORUM_NAME' => $topic_data['forum_name'], |
| 578 | 6188 | davidmj | 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), |
| 579 | 4870 | acydburn | 'TOPIC_ID' => $topic_id, |
| 580 | 5272 | acydburn | 'TOPIC_TITLE' => $topic_data['topic_title'], |
| 581 | 7322 | acydburn | 'TOPIC_POSTER' => $topic_data['topic_poster'], |
| 582 | 7322 | acydburn | |
| 583 | 7322 | acydburn | 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), |
| 584 | 7322 | acydburn | 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), |
| 585 | 7322 | acydburn | 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), |
| 586 | 7322 | acydburn | |
| 587 | 4167 | psotfx | 'PAGINATION' => $pagination, |
| 588 | 4167 | psotfx | 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), |
| 589 | 11603 | git-gate | 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), |
| 590 | 10633 | git-gate | '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) : '', |
| 591 | 4892 | acydburn | 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '', |
| 592 | 770 | psotfx | |
| 593 | 6237 | acydburn | 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), |
| 594 | 6237 | acydburn | 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), |
| 595 | 6237 | acydburn | 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), |
| 596 | 6237 | acydburn | 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), |
| 597 | 6237 | acydburn | 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), |
| 598 | 6237 | acydburn | 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), |
| 599 | 6237 | acydburn | 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), |
| 600 | 6237 | acydburn | 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), |
| 601 | 6237 | acydburn | 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), |
| 602 | 6237 | acydburn | 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), |
| 603 | 6237 | acydburn | 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), |
| 604 | 6237 | acydburn | 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), |
| 605 | 6237 | acydburn | 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), |
| 606 | 6237 | acydburn | 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), |
| 607 | 6237 | acydburn | 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), |
| 608 | 6237 | acydburn | 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') , |
| 609 | 6237 | acydburn | 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), |
| 610 | 6237 | acydburn | 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), |
| 611 | 6237 | acydburn | 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), |
| 612 | 6237 | acydburn | 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), |
| 613 | 3640 | ludovic_arnaud | |
| 614 | 9846 | rxu | 'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true, |
| 615 | 3538 | psotfx | 'S_SELECT_SORT_DIR' => $s_sort_dir, |
| 616 | 3538 | psotfx | 'S_SELECT_SORT_KEY' => $s_sort_key, |
| 617 | 3538 | psotfx | 'S_SELECT_SORT_DAYS' => $s_limit_days, |
| 618 | 6199 | grahamje | 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, |
| 619 | 10633 | git-gate | 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), |
| 620 | 8310 | acydburn | 'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '', |
| 621 | 10633 | git-gate | '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), |
| 622 | 3600 | ludovic_arnaud | |
| 623 | 8205 | acydburn | 'S_VIEWTOPIC' => true, |
| 624 | 7361 | naderman | 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, |
| 625 | 11189 | git-gate | 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), |
| 626 | 11251 | git-gate | 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), |
| 627 | 659 | psotfx | |
| 628 | 7884 | acydburn | 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, |
| 629 | 7884 | acydburn | 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, |
| 630 | 9965 | acydburn | 'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false, |
| 631 | 7884 | acydburn | |
| 632 | 4473 | psotfx | 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", |
| 633 | 3071 | psotfx | 'U_FORUM' => $server_path, |
| 634 | 4912 | acydburn | 'U_VIEW_TOPIC' => $viewtopic_url, |
| 635 | 6015 | acydburn | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), |
| 636 | 6015 | acydburn | 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=previous"), |
| 637 | 6015 | acydburn | 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=next"), |
| 638 | 4912 | acydburn | 'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&view=print' : '', |
| 639 | 6015 | acydburn | 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") : '', |
| 640 | 3747 | psotfx | |
| 641 | 4947 | psotfx | 'U_WATCH_TOPIC' => $s_watching_topic['link'], |
| 642 | 4947 | psotfx | 'L_WATCH_TOPIC' => $s_watching_topic['title'], |
| 643 | 7736 | acydburn | 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], |
| 644 | 4892 | acydburn | |
| 645 | 8775 | Kellanved | 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") : '', |
| 646 | 5272 | acydburn | 'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], |
| 647 | 4947 | psotfx | |
| 648 | 7884 | acydburn | '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") : '', |
| 649 | 7884 | acydburn | '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") : '', |
| 650 | 8775 | Kellanved | '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")) : '') |
| 651 | 579 | psotfx | ); |
| 652 | 237 | psotfx | |
| 653 | 2853 | psotfx | // Does this topic contain a poll?
|
| 654 | 5412 | davidmj | if (!empty($topic_data['poll_start'])) |
| 655 | 987 | psotfx | {
|
| 656 | 4981 | acydburn | $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid |
| 657 | 4981 | acydburn | FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p |
| 658 | 5078 | psotfx | WHERE o.topic_id = $topic_id |
| 659 | 5272 | acydburn | AND p.post_id = {$topic_data['topic_first_post_id']} |
| 660 | 4981 | acydburn | AND p.topic_id = o.topic_id |
| 661 | 4981 | acydburn | ORDER BY o.poll_option_id";
|
| 662 | 2673 | psotfx | $result = $db->sql_query($sql); |
| 663 | 987 | psotfx | |
| 664 | 4184 | acydburn | $poll_info = array(); |
| 665 | 2997 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 666 | 987 | psotfx | {
|
| 667 | 2983 | psotfx | $poll_info[] = $row; |
| 668 | 2983 | psotfx | } |
| 669 | 2983 | psotfx | $db->sql_freeresult($result); |
| 670 | 5078 | psotfx | |
| 671 | 4455 | psotfx | $cur_voted_id = array(); |
| 672 | 5117 | acydburn | if ($user->data['is_registered']) |
| 673 | 3953 | psotfx | {
|
| 674 | 4051 | psotfx | $sql = 'SELECT poll_option_id |
| 675 | 4057 | acydburn | FROM ' . POLL_VOTES_TABLE . ' |
| 676 | 4057 | acydburn | WHERE topic_id = ' . $topic_id . ' |
| 677 | 4057 | acydburn | AND vote_user_id = ' . $user->data['user_id']; |
| 678 | 3953 | psotfx | $result = $db->sql_query($sql); |
| 679 | 987 | psotfx | |
| 680 | 4192 | ludovic_arnaud | while ($row = $db->sql_fetchrow($result)) |
| 681 | 3920 | psotfx | {
|
| 682 | 4455 | psotfx | $cur_voted_id[] = $row['poll_option_id']; |
| 683 | 3920 | psotfx | } |
| 684 | 3953 | psotfx | $db->sql_freeresult($result); |
| 685 | 3920 | psotfx | } |
| 686 | 3953 | psotfx | else
|
| 687 | 3920 | psotfx | {
|
| 688 | 3953 | psotfx | // Cookie based guest tracking ... I don't like this but hum ho
|
| 689 | 3953 | psotfx | // it's oft requested. This relies on "nice" users who don't feel
|
| 690 | 4749 | psotfx | // the need to delete cookies to mess with results.
|
| 691 | 10892 | git-gate | if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, phpbb_request_interface::COOKIE)) |
| 692 | 3920 | psotfx | {
|
| 693 | 10892 | git-gate | $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, phpbb_request_interface::COOKIE)); |
| 694 | 6002 | acydburn | $cur_voted_id = array_map('intval', $cur_voted_id); |
| 695 | 3920 | psotfx | } |
| 696 | 3953 | psotfx | } |
| 697 | 987 | psotfx | |
| 698 | 9470 | acydburn | // Can not vote at all if no vote permission
|
| 699 | 9470 | acydburn | $s_can_vote = ($auth->acl_get('f_vote', $forum_id) && |
| 700 | 5412 | davidmj | (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) && |
| 701 | 5272 | acydburn | $topic_data['topic_status'] != ITEM_LOCKED && |
| 702 | 9567 | toonarmy | $topic_data['forum_status'] != ITEM_LOCKED && |
| 703 | 9567 | toonarmy | (!sizeof($cur_voted_id) || |
| 704 | 9567 | toonarmy | ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false; |
| 705 | 5078 | psotfx | $s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false; |
| 706 | 3953 | psotfx | |
| 707 | 4455 | psotfx | if ($update && $s_can_vote) |
| 708 | 3953 | psotfx | {
|
| 709 | 8350 | acydburn | |
| 710 | 9688 | Kellanved | if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting')) |
| 711 | 3920 | psotfx | {
|
| 712 | 10633 | git-gate | $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); |
| 713 | 3953 | psotfx | |
| 714 | 6002 | acydburn | meta_refresh(5, $redirect_url); |
| 715 | 8216 | kellanved | if (!sizeof($voted_id)) |
| 716 | 8216 | kellanved | {
|
| 717 | 8216 | kellanved | $message = 'NO_VOTE_OPTION'; |
| 718 | 8216 | kellanved | } |
| 719 | 8216 | kellanved | else if (sizeof($voted_id) > $topic_data['poll_max_options']) |
| 720 | 8216 | kellanved | {
|
| 721 | 8216 | kellanved | $message = 'TOO_MANY_VOTE_OPTIONS'; |
| 722 | 8216 | kellanved | } |
| 723 | 9688 | Kellanved | else if (in_array(VOTE_CONVERTED, $cur_voted_id)) |
| 724 | 8216 | kellanved | {
|
| 725 | 8216 | kellanved | $message = 'VOTE_CONVERTED'; |
| 726 | 8216 | kellanved | } |
| 727 | 9688 | Kellanved | else
|
| 728 | 9688 | Kellanved | {
|
| 729 | 9688 | Kellanved | $message = 'FORM_INVALID'; |
| 730 | 9688 | Kellanved | } |
| 731 | 8350 | acydburn | |
| 732 | 6002 | acydburn | $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'); |
| 733 | 3953 | psotfx | trigger_error($message); |
| 734 | 3920 | psotfx | } |
| 735 | 3920 | psotfx | |
| 736 | 3920 | psotfx | foreach ($voted_id as $option) |
| 737 | 3920 | psotfx | {
|
| 738 | 4455 | psotfx | if (in_array($option, $cur_voted_id)) |
| 739 | 4455 | psotfx | {
|
| 740 | 4455 | psotfx | continue;
|
| 741 | 4455 | psotfx | } |
| 742 | 4455 | psotfx | |
| 743 | 6002 | acydburn | $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' |
| 744 | 4947 | psotfx | SET poll_option_total = poll_option_total + 1 |
| 745 | 6002 | acydburn | WHERE poll_option_id = ' . (int) $option . ' |
| 746 | 6002 | acydburn | AND topic_id = ' . (int) $topic_id; |
| 747 | 3920 | psotfx | $db->sql_query($sql); |
| 748 | 3953 | psotfx | |
| 749 | 5117 | acydburn | if ($user->data['is_registered']) |
| 750 | 3953 | psotfx | {
|
| 751 | 6002 | acydburn | $sql_ary = array( |
| 752 | 6002 | acydburn | 'topic_id' => (int) $topic_id, |
| 753 | 6002 | acydburn | 'poll_option_id' => (int) $option, |
| 754 | 6002 | acydburn | 'vote_user_id' => (int) $user->data['user_id'], |
| 755 | 6002 | acydburn | 'vote_user_ip' => (string) $user->ip, |
| 756 | 6002 | acydburn | ); |
| 757 | 6151 | naderman | |
| 758 | 6930 | acydburn | $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); |
| 759 | 3953 | psotfx | $db->sql_query($sql); |
| 760 | 3953 | psotfx | } |
| 761 | 3920 | psotfx | } |
| 762 | 3920 | psotfx | |
| 763 | 4455 | psotfx | foreach ($cur_voted_id as $option) |
| 764 | 4455 | psotfx | {
|
| 765 | 4455 | psotfx | if (!in_array($option, $voted_id)) |
| 766 | 4455 | psotfx | {
|
| 767 | 6002 | acydburn | $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' |
| 768 | 4947 | psotfx | SET poll_option_total = poll_option_total - 1 |
| 769 | 6002 | acydburn | WHERE poll_option_id = ' . (int) $option . ' |
| 770 | 6002 | acydburn | AND topic_id = ' . (int) $topic_id; |
| 771 | 4455 | psotfx | $db->sql_query($sql); |
| 772 | 4455 | psotfx | |
| 773 | 5117 | acydburn | if ($user->data['is_registered']) |
| 774 | 4455 | psotfx | {
|
| 775 | 6002 | acydburn | $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . ' |
| 776 | 6002 | acydburn | WHERE topic_id = ' . (int) $topic_id . ' |
| 777 | 6002 | acydburn | AND poll_option_id = ' . (int) $option . ' |
| 778 | 6002 | acydburn | AND vote_user_id = ' . (int) $user->data['user_id']; |
| 779 | 4455 | psotfx | $db->sql_query($sql); |
| 780 | 4455 | psotfx | } |
| 781 | 4455 | psotfx | } |
| 782 | 4455 | psotfx | } |
| 783 | 4455 | psotfx | |
| 784 | 5117 | acydburn | if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot']) |
| 785 | 3953 | psotfx | {
|
| 786 | 4904 | acydburn | $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000); |
| 787 | 3953 | psotfx | } |
| 788 | 3953 | psotfx | |
| 789 | 4947 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . ' |
| 790 | 4947 | psotfx | SET poll_last_vote = ' . time() . " |
| 791 | 3920 | psotfx | WHERE topic_id = $topic_id"; |
| 792 | 5078 | psotfx | //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
|
| 793 | 3920 | psotfx | $db->sql_query($sql); |
| 794 | 3953 | psotfx | |
| 795 | 10633 | git-gate | $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); |
| 796 | 3953 | psotfx | |
| 797 | 6002 | acydburn | meta_refresh(5, $redirect_url); |
| 798 | 6002 | acydburn | trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>')); |
| 799 | 3920 | psotfx | } |
| 800 | 3920 | psotfx | |
| 801 | 2983 | psotfx | $poll_total = 0; |
| 802 | 2983 | psotfx | foreach ($poll_info as $poll_option) |
| 803 | 2983 | psotfx | {
|
| 804 | 2983 | psotfx | $poll_total += $poll_option['poll_option_total']; |
| 805 | 2983 | psotfx | } |
| 806 | 987 | psotfx | |
| 807 | 4981 | acydburn | if ($poll_info[0]['bbcode_bitfield']) |
| 808 | 4981 | acydburn | {
|
| 809 | 4981 | acydburn | $poll_bbcode = new bbcode(); |
| 810 | 5973 | acydburn | } |
| 811 | 5973 | acydburn | else
|
| 812 | 5973 | acydburn | {
|
| 813 | 5973 | acydburn | $poll_bbcode = false; |
| 814 | 5973 | acydburn | } |
| 815 | 4981 | acydburn | |
| 816 | 5973 | acydburn | for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++) |
| 817 | 5973 | acydburn | {
|
| 818 | 6256 | acydburn | $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']); |
| 819 | 6256 | acydburn | |
| 820 | 5973 | acydburn | if ($poll_bbcode !== false) |
| 821 | 4981 | acydburn | {
|
| 822 | 4981 | acydburn | $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']); |
| 823 | 4981 | acydburn | } |
| 824 | 6256 | acydburn | |
| 825 | 8050 | naderman | $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']); |
| 826 | 5973 | acydburn | $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']); |
| 827 | 5973 | acydburn | } |
| 828 | 4981 | acydburn | |
| 829 | 6256 | acydburn | $topic_data['poll_title'] = censor_text($topic_data['poll_title']); |
| 830 | 6256 | acydburn | |
| 831 | 5973 | acydburn | if ($poll_bbcode !== false) |
| 832 | 5973 | acydburn | {
|
| 833 | 5412 | davidmj | $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']); |
| 834 | 4981 | acydburn | } |
| 835 | 8050 | naderman | |
| 836 | 8050 | naderman | $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']); |
| 837 | 5973 | acydburn | $topic_data['poll_title'] = smiley_text($topic_data['poll_title']); |
| 838 | 5078 | psotfx | |
| 839 | 5973 | acydburn | unset($poll_bbcode); |
| 840 | 5973 | acydburn | |
| 841 | 2983 | psotfx | foreach ($poll_info as $poll_option) |
| 842 | 2983 | psotfx | {
|
| 843 | 3061 | psotfx | $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0; |
| 844 | 9010 | toonarmy | $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); |
| 845 | 987 | psotfx | |
| 846 | 2983 | psotfx | $template->assign_block_vars('poll_option', array( |
| 847 | 2983 | psotfx | 'POLL_OPTION_ID' => $poll_option['poll_option_id'], |
| 848 | 2983 | psotfx | 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'], |
| 849 | 2983 | psotfx | 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'], |
| 850 | 3953 | psotfx | 'POLL_OPTION_PERCENT' => $option_pct_txt, |
| 851 | 5073 | acydburn | 'POLL_OPTION_PCT' => round($option_pct * 100), |
| 852 | 11429 | git-gate | 'POLL_OPTION_WIDTH' => round($option_pct * 250), |
| 853 | 4455 | psotfx | 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false) |
| 854 | 2983 | psotfx | ); |
| 855 | 2983 | psotfx | } |
| 856 | 987 | psotfx | |
| 857 | 6307 | grahamje | $poll_end = $topic_data['poll_length'] + $topic_data['poll_start']; |
| 858 | 6307 | grahamje | |
| 859 | 2983 | psotfx | $template->assign_vars(array( |
| 860 | 5412 | davidmj | 'POLL_QUESTION' => $topic_data['poll_title'], |
| 861 | 2983 | psotfx | 'TOTAL_VOTES' => $poll_total, |
| 862 | 2983 | psotfx | 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), |
| 863 | 2983 | psotfx | 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), |
| 864 | 2117 | psotfx | |
| 865 | 11603 | git-gate | 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $topic_data['poll_max_options']), |
| 866 | 6307 | grahamje | 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '', |
| 867 | 3920 | psotfx | |
| 868 | 4947 | psotfx | 'S_HAS_POLL' => true, |
| 869 | 4947 | psotfx | 'S_CAN_VOTE' => $s_can_vote, |
| 870 | 3953 | psotfx | 'S_DISPLAY_RESULTS' => $s_display_results, |
| 871 | 5412 | davidmj | 'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false, |
| 872 | 4912 | acydburn | 'S_POLL_ACTION' => $viewtopic_url, |
| 873 | 987 | psotfx | |
| 874 | 4912 | acydburn | 'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll') |
| 875 | 2983 | psotfx | ); |
| 876 | 3961 | psotfx | |
| 877 | 6307 | grahamje | unset($poll_end, $poll_info, $voted_id); |
| 878 | 987 | psotfx | } |
| 879 | 987 | psotfx | |
| 880 | 4471 | ludovic_arnaud | // If the user is trying to reach the second half of the topic, fetch it starting from the end
|
| 881 | 5272 | acydburn | $store_reverse = false; |
| 882 | 4675 | ludovic_arnaud | $sql_limit = $config['posts_per_page']; |
| 883 | 9523 | Kellanved | $sql_sort_order = $direction = ''; |
| 884 | 4675 | ludovic_arnaud | |
| 885 | 4471 | ludovic_arnaud | if ($start > $total_posts / 2) |
| 886 | 4471 | ludovic_arnaud | {
|
| 887 | 5272 | acydburn | $store_reverse = true; |
| 888 | 4471 | ludovic_arnaud | |
| 889 | 4471 | ludovic_arnaud | if ($start + $config['posts_per_page'] > $total_posts) |
| 890 | 4471 | ludovic_arnaud | {
|
| 891 | 4675 | ludovic_arnaud | $sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start)); |
| 892 | 4471 | ludovic_arnaud | } |
| 893 | 4471 | ludovic_arnaud | |
| 894 | 4675 | ludovic_arnaud | // Select the sort order
|
| 895 | 9523 | Kellanved | $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
| 896 | 4675 | ludovic_arnaud | $sql_start = max(0, $total_posts - $sql_limit - $start); |
| 897 | 4471 | ludovic_arnaud | } |
| 898 | 4522 | psotfx | else
|
| 899 | 4522 | psotfx | {
|
| 900 | 4522 | psotfx | // Select the sort order
|
| 901 | 9523 | Kellanved | $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
| 902 | 4675 | ludovic_arnaud | $sql_start = $start; |
| 903 | 4522 | psotfx | } |
| 904 | 10035 | acydburn | |
| 905 | 9523 | Kellanved | if (is_array($sort_by_sql[$sort_key])) |
| 906 | 9523 | Kellanved | {
|
| 907 | 9523 | Kellanved | $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; |
| 908 | 9523 | Kellanved | } |
| 909 | 9523 | Kellanved | else
|
| 910 | 9523 | Kellanved | {
|
| 911 | 9523 | Kellanved | $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; |
| 912 | 9523 | Kellanved | } |
| 913 | 4471 | ludovic_arnaud | |
| 914 | 4522 | psotfx | // Container for user details, only process once
|
| 915 | 4767 | acydburn | $post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array(); |
| 916 | 4859 | acydburn | $has_attachments = $display_notice = false; |
| 917 | 6380 | naderman | $bbcode_bitfield = ''; |
| 918 | 6209 | davidmj | $i = $i_total = 0; |
| 919 | 4522 | psotfx | |
| 920 | 3856 | ludovic_arnaud | // Go ahead and pull all data for this topic
|
| 921 | 4675 | ludovic_arnaud | $sql = 'SELECT p.post_id |
| 922 | 9523 | Kellanved | FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " |
| 923 | 3856 | ludovic_arnaud | WHERE p.topic_id = $topic_id |
| 924 | 4675 | ludovic_arnaud | " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . " |
| 925 | 9523 | Kellanved | " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " |
| 926 | 3856 | ludovic_arnaud | $limit_posts_time |
| 927 | 4675 | ludovic_arnaud | ORDER BY $sql_sort_order"; |
| 928 | 4675 | ludovic_arnaud | $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); |
| 929 | 3856 | ludovic_arnaud | |
| 930 | 4675 | ludovic_arnaud | $i = ($store_reverse) ? $sql_limit - 1 : 0; |
| 931 | 4675 | ludovic_arnaud | while ($row = $db->sql_fetchrow($result)) |
| 932 | 3856 | ludovic_arnaud | {
|
| 933 | 9399 | toonarmy | $post_list[$i] = (int) $row['post_id']; |
| 934 | 6002 | acydburn | ($store_reverse) ? $i-- : $i++; |
| 935 | 4675 | ludovic_arnaud | } |
| 936 | 5108 | acydburn | $db->sql_freeresult($result); |
| 937 | 4675 | ludovic_arnaud | |
| 938 | 5272 | acydburn | if (!sizeof($post_list)) |
| 939 | 4675 | ludovic_arnaud | {
|
| 940 | 6320 | acydburn | if ($sort_days) |
| 941 | 6320 | acydburn | {
|
| 942 | 6320 | acydburn | trigger_error('NO_POSTS_TIME_FRAME'); |
| 943 | 6320 | acydburn | } |
| 944 | 6320 | acydburn | else
|
| 945 | 6320 | acydburn | {
|
| 946 | 6320 | acydburn | trigger_error('NO_TOPIC'); |
| 947 | 6320 | acydburn | } |
| 948 | 3856 | ludovic_arnaud | } |
| 949 | 3856 | ludovic_arnaud | |
| 950 | 5272 | acydburn | // Holding maximum post time for marking topic read
|
| 951 | 5272 | acydburn | // We need to grab it because we do reverse ordering sometimes
|
| 952 | 5272 | acydburn | $max_post_time = 0; |
| 953 | 5272 | acydburn | |
| 954 | 11585 | git-gate | $sql_ary = array( |
| 955 | 6002 | acydburn | 'SELECT' => 'u.*, z.friend, z.foe, p.*', |
| 956 | 5885 | davidmj | |
| 957 | 5885 | davidmj | 'FROM' => array( |
| 958 | 5885 | davidmj | USERS_TABLE => 'u', |
| 959 | 5885 | davidmj | POSTS_TABLE => 'p', |
| 960 | 5885 | davidmj | ), |
| 961 | 5885 | davidmj | |
| 962 | 5885 | davidmj | 'LEFT_JOIN' => array( |
| 963 | 5885 | davidmj | array(
|
| 964 | 5885 | davidmj | 'FROM' => array(ZEBRA_TABLE => 'z'), |
| 965 | 11585 | git-gate | 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id', |
| 966 | 11585 | git-gate | ), |
| 967 | 5885 | davidmj | ), |
| 968 | 5885 | davidmj | |
| 969 | 6271 | acydburn | 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' |
| 970 | 11585 | git-gate | AND u.user_id = p.poster_id',
|
| 971 | 11585 | git-gate | ); |
| 972 | 5885 | davidmj | |
| 973 | 11585 | git-gate | $sql = $db->sql_build_query('SELECT', $sql_ary); |
| 974 | 4675 | ludovic_arnaud | $result = $db->sql_query($sql); |
| 975 | 4675 | ludovic_arnaud | |
| 976 | 11307 | git-gate | $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst); |
| 977 | 6151 | naderman | |
| 978 | 3868 | ludovic_arnaud | // Posts are stored in the $rowset array while $attach_list, $user_cache
|
| 979 | 3868 | ludovic_arnaud | // and the global bbcode_bitfield are built
|
| 980 | 4675 | ludovic_arnaud | while ($row = $db->sql_fetchrow($result)) |
| 981 | 3856 | ludovic_arnaud | {
|
| 982 | 5272 | acydburn | // Set max_post_time
|
| 983 | 5272 | acydburn | if ($row['post_time'] > $max_post_time) |
| 984 | 5272 | acydburn | {
|
| 985 | 5272 | acydburn | $max_post_time = $row['post_time']; |
| 986 | 5272 | acydburn | } |
| 987 | 5272 | acydburn | |
| 988 | 9399 | toonarmy | $poster_id = (int) $row['poster_id']; |
| 989 | 3856 | ludovic_arnaud | |
| 990 | 4139 | acydburn | // Does post have an attachment? If so, add it to the list
|
| 991 | 4139 | acydburn | if ($row['post_attachment'] && $config['allow_attachments']) |
| 992 | 4139 | acydburn | {
|
| 993 | 9399 | toonarmy | $attach_list[] = (int) $row['post_id']; |
| 994 | 4947 | psotfx | |
| 995 | 4269 | psotfx | if ($row['post_approved']) |
| 996 | 4139 | acydburn | {
|
| 997 | 5272 | acydburn | $has_attachments = true; |
| 998 | 4139 | acydburn | } |
| 999 | 4139 | acydburn | } |
| 1000 | 4139 | acydburn | |
| 1001 | 4675 | ludovic_arnaud | $rowset[$row['post_id']] = array( |
| 1002 | 6589 | acydburn | 'hide_post' => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, |
| 1003 | 6589 | acydburn | |
| 1004 | 4675 | ludovic_arnaud | 'post_id' => $row['post_id'], |
| 1005 | 4675 | ludovic_arnaud | 'post_time' => $row['post_time'], |
| 1006 | 4675 | ludovic_arnaud | 'user_id' => $row['user_id'], |
| 1007 | 6589 | acydburn | 'username' => $row['username'], |
| 1008 | 6589 | acydburn | 'user_colour' => $row['user_colour'], |
| 1009 | 4675 | ludovic_arnaud | 'topic_id' => $row['topic_id'], |
| 1010 | 4675 | ludovic_arnaud | 'forum_id' => $row['forum_id'], |
| 1011 | 4675 | ludovic_arnaud | 'post_subject' => $row['post_subject'], |
| 1012 | 4675 | ludovic_arnaud | 'post_edit_count' => $row['post_edit_count'], |
| 1013 | 4675 | ludovic_arnaud | 'post_edit_time' => $row['post_edit_time'], |
| 1014 | 4767 | acydburn | 'post_edit_reason' => $row['post_edit_reason'], |
| 1015 | 4767 | acydburn | 'post_edit_user' => $row['post_edit_user'], |
| 1016 | 8924 | toonarmy | 'post_edit_locked' => $row['post_edit_locked'], |
| 1017 | 6143 | ludovic_arnaud | |
| 1018 | 6143 | ludovic_arnaud | // Make sure the icon actually exists
|
| 1019 | 6143 | ludovic_arnaud | 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, |
| 1020 | 4675 | ludovic_arnaud | 'post_attachment' => $row['post_attachment'], |
| 1021 | 4675 | ludovic_arnaud | 'post_approved' => $row['post_approved'], |
| 1022 | 4675 | ludovic_arnaud | 'post_reported' => $row['post_reported'], |
| 1023 | 6589 | acydburn | 'post_username' => $row['post_username'], |
| 1024 | 4675 | ludovic_arnaud | 'post_text' => $row['post_text'], |
| 1025 | 4675 | ludovic_arnaud | 'bbcode_uid' => $row['bbcode_uid'], |
| 1026 | 4675 | ludovic_arnaud | 'bbcode_bitfield' => $row['bbcode_bitfield'], |
| 1027 | 4675 | ludovic_arnaud | 'enable_smilies' => $row['enable_smilies'], |
| 1028 | 4947 | psotfx | 'enable_sig' => $row['enable_sig'], |
| 1029 | 4947 | psotfx | 'friend' => $row['friend'], |
| 1030 | 6589 | acydburn | 'foe' => $row['foe'], |
| 1031 | 4675 | ludovic_arnaud | ); |
| 1032 | 3868 | ludovic_arnaud | |
| 1033 | 3953 | psotfx | // Define the global bbcode bitfield, will be used to load bbcodes
|
| 1034 | 6263 | davidmj | $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); |
| 1035 | 3953 | psotfx | |
| 1036 | 4499 | ludovic_arnaud | // Is a signature attached? Are we going to display it?
|
| 1037 | 4577 | acydburn | if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) |
| 1038 | 4499 | ludovic_arnaud | {
|
| 1039 | 6263 | davidmj | $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']); |
| 1040 | 4499 | ludovic_arnaud | } |
| 1041 | 4499 | ludovic_arnaud | |
| 1042 | 3856 | ludovic_arnaud | // Cache various user specific data ... so we don't have to recompute
|
| 1043 | 3856 | ludovic_arnaud | // this each time the same user appears on this page
|
| 1044 | 3856 | ludovic_arnaud | if (!isset($user_cache[$poster_id])) |
| 1045 | 3856 | ludovic_arnaud | {
|
| 1046 | 3856 | ludovic_arnaud | if ($poster_id == ANONYMOUS) |
| 1047 | 3538 | psotfx | {
|
| 1048 | 3856 | ludovic_arnaud | $user_cache[$poster_id] = array( |
| 1049 | 4892 | acydburn | 'joined' => '', |
| 1050 | 4892 | acydburn | 'posts' => '', |
| 1051 | 4892 | acydburn | 'from' => '', |
| 1052 | 4892 | acydburn | |
| 1053 | 4892 | acydburn | 'sig' => '', |
| 1054 | 4892 | acydburn | 'sig_bbcode_uid' => '', |
| 1055 | 4892 | acydburn | 'sig_bbcode_bitfield' => '', |
| 1056 | 4892 | acydburn | |
| 1057 | 5633 | acydburn | 'online' => false, |
| 1058 | 8872 | acydburn | 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', |
| 1059 | 5633 | acydburn | 'rank_title' => '', |
| 1060 | 5633 | acydburn | 'rank_image' => '', |
| 1061 | 5633 | acydburn | 'rank_image_src' => '', |
| 1062 | 5633 | acydburn | 'sig' => '', |
| 1063 | 5633 | acydburn | 'profile' => '', |
| 1064 | 5633 | acydburn | 'pm' => '', |
| 1065 | 5633 | acydburn | 'email' => '', |
| 1066 | 5633 | acydburn | 'www' => '', |
| 1067 | 5633 | acydburn | 'icq_status_img' => '', |
| 1068 | 5633 | acydburn | 'icq' => '', |
| 1069 | 5633 | acydburn | 'aim' => '', |
| 1070 | 5633 | acydburn | 'msn' => '', |
| 1071 | 5633 | acydburn | 'yim' => '', |
| 1072 | 5633 | acydburn | 'jabber' => '', |
| 1073 | 5633 | acydburn | 'search' => '', |
| 1074 | 6151 | naderman | 'age' => '', |
| 1075 | 6151 | naderman | |
| 1076 | 6600 | acydburn | 'username' => $row['username'], |
| 1077 | 6600 | acydburn | 'user_colour' => $row['user_colour'], |
| 1078 | 6600 | acydburn | |
| 1079 | 5633 | acydburn | 'warnings' => 0, |
| 1080 | 6662 | acydburn | 'allow_pm' => 0, |
| 1081 | 3856 | ludovic_arnaud | ); |
| 1082 | 8872 | acydburn | |
| 1083 | 9082 | acydburn | 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']); |
| 1084 | 3856 | ludovic_arnaud | } |
| 1085 | 3856 | ludovic_arnaud | else
|
| 1086 | 3856 | ludovic_arnaud | {
|
| 1087 | 3953 | psotfx | $user_sig = ''; |
| 1088 | 4578 | psotfx | |
| 1089 | 7256 | acydburn | // We add the signature to every posters entry because enable_sig is post dependant
|
| 1090 | 7256 | acydburn | if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) |
| 1091 | 3538 | psotfx | {
|
| 1092 | 3953 | psotfx | $user_sig = $row['user_sig']; |
| 1093 | 3538 | psotfx | } |
| 1094 | 4441 | psotfx | |
| 1095 | 4269 | psotfx | $id_cache[] = $poster_id; |
| 1096 | 6002 | acydburn | |
| 1097 | 3856 | ludovic_arnaud | $user_cache[$poster_id] = array( |
| 1098 | 5701 | acydburn | 'joined' => $user->format_date($row['user_regdate']), |
| 1099 | 5216 | bartvb | 'posts' => $row['user_posts'], |
| 1100 | 5358 | subblue | 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, |
| 1101 | 4051 | psotfx | 'from' => (!empty($row['user_from'])) ? $row['user_from'] : '', |
| 1102 | 3953 | psotfx | |
| 1103 | 4051 | psotfx | 'sig' => $user_sig, |
| 1104 | 6930 | acydburn | 'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '', |
| 1105 | 6930 | acydburn | 'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '', |
| 1106 | 3953 | psotfx | |
| 1107 | 4947 | psotfx | 'viewonline' => $row['user_allow_viewonline'], |
| 1108 | 6662 | acydburn | 'allow_pm' => $row['user_allow_pm'], |
| 1109 | 4269 | psotfx | |
| 1110 | 7330 | acydburn | 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', |
| 1111 | 6151 | naderman | 'age' => '', |
| 1112 | 3868 | ludovic_arnaud | |
| 1113 | 6190 | acydburn | 'rank_title' => '', |
| 1114 | 6190 | acydburn | 'rank_image' => '', |
| 1115 | 6190 | acydburn | 'rank_image_src' => '', |
| 1116 | 6190 | acydburn | |
| 1117 | 6600 | acydburn | 'username' => $row['username'], |
| 1118 | 6600 | acydburn | 'user_colour' => $row['user_colour'], |
| 1119 | 6600 | acydburn | |
| 1120 | 4920 | acydburn | 'online' => false, |
| 1121 | 6015 | acydburn | 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"), |
| 1122 | 4051 | psotfx | 'www' => $row['user_website'], |
| 1123 | 7242 | acydburn | 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '', |
| 1124 | 7242 | acydburn | 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', |
| 1125 | 8092 | acydburn | 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', |
| 1126 | 7242 | acydburn | 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', |
| 1127 | 8835 | toonarmy | 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '', |
| 1128 | 9790 | toonarmy | |
| 1129 | 9790 | toonarmy | 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), |
| 1130 | 9790 | toonarmy | 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), |
| 1131 | 9790 | toonarmy | 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), |
| 1132 | 9790 | toonarmy | 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), |
| 1133 | 3856 | ludovic_arnaud | ); |
| 1134 | 3538 | psotfx | |
| 1135 | 6829 | acydburn | 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']); |
| 1136 | 136 | psotfx | |
| 1137 | 10761 | git-gate | if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) |
| 1138 | 2714 | psotfx | {
|
| 1139 | 6015 | acydburn | $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']); |
| 1140 | 2714 | psotfx | } |
| 1141 | 2714 | psotfx | else
|
| 1142 | 2714 | psotfx | {
|
| 1143 | 3286 | psotfx | $user_cache[$poster_id]['email'] = ''; |
| 1144 | 2714 | psotfx | } |
| 1145 | 2714 | psotfx | |
| 1146 | 2997 | psotfx | if (!empty($row['user_icq'])) |
| 1147 | 2714 | psotfx | {
|
| 1148 | 11091 | git-gate | $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/'; |
| 1149 | 6002 | acydburn | $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="" />'; |
| 1150 | 2714 | psotfx | } |
| 1151 | 2714 | psotfx | else
|
| 1152 | 2714 | psotfx | {
|
| 1153 | 3286 | psotfx | $user_cache[$poster_id]['icq_status_img'] = ''; |
| 1154 | 3286 | psotfx | $user_cache[$poster_id]['icq'] = ''; |
| 1155 | 2714 | psotfx | } |
| 1156 | 6151 | naderman | |
| 1157 | 7909 | acydburn | if ($config['allow_birthdays'] && !empty($row['user_birthday'])) |
| 1158 | 6151 | naderman | {
|
| 1159 | 6151 | naderman | list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday'])); |
| 1160 | 6151 | naderman | |
| 1161 | 6151 | naderman | if ($bday_year) |
| 1162 | 6151 | naderman | {
|
| 1163 | 6321 | naderman | $diff = $now['mon'] - $bday_month; |
| 1164 | 6241 | naderman | if ($diff == 0) |
| 1165 | 6241 | naderman | {
|
| 1166 | 6321 | naderman | $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; |
| 1167 | 6241 | naderman | } |
| 1168 | 6241 | naderman | else
|
| 1169 | 6241 | naderman | {
|
| 1170 | 6241 | naderman | $diff = ($diff < 0) ? 1 : 0; |
| 1171 | 6241 | naderman | } |
| 1172 | 6256 | acydburn | |
| 1173 | 6321 | naderman | $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff); |
| 1174 | 6151 | naderman | } |
| 1175 | 6151 | naderman | } |
| 1176 | 1320 | psotfx | } |
| 1177 | 3856 | ludovic_arnaud | } |
| 1178 | 3868 | ludovic_arnaud | } |
| 1179 | 3868 | ludovic_arnaud | $db->sql_freeresult($result); |
| 1180 | 1320 | psotfx | |
| 1181 | 4984 | acydburn | // Load custom profile fields
|
| 1182 | 4984 | acydburn | if ($config['load_cpf_viewtopic']) |
| 1183 | 4892 | acydburn | {
|
| 1184 | 9418 | acydburn | if (!class_exists('custom_profile')) |
| 1185 | 9418 | acydburn | {
|
| 1186 | 9418 | acydburn | include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
| 1187 | 9418 | acydburn | } |
| 1188 | 4892 | acydburn | $cp = new custom_profile(); |
| 1189 | 4984 | acydburn | |
| 1190 | 4984 | acydburn | // Grab all profile fields from users in id cache for later use - similar to the poster cache
|
| 1191 | 9916 | Kellanved | $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache); |
| 1192 | 9965 | acydburn | |
| 1193 | 9916 | Kellanved | // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
|
| 1194 | 9916 | Kellanved | $profile_fields_cache = array(); |
| 1195 | 9916 | Kellanved | foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) |
| 1196 | 9916 | Kellanved | {
|
| 1197 | 9916 | Kellanved | $profile_fields_cache[$profile_user_id] = array(); |
| 1198 | 9916 | Kellanved | foreach ($profile_fields as $used_ident => $profile_field) |
| 1199 | 9916 | Kellanved | {
|
| 1200 | 9916 | Kellanved | if ($profile_field['data']['field_show_on_vt']) |
| 1201 | 9916 | Kellanved | {
|
| 1202 | 9916 | Kellanved | $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field; |
| 1203 | 9916 | Kellanved | } |
| 1204 | 9916 | Kellanved | } |
| 1205 | 9916 | Kellanved | } |
| 1206 | 9916 | Kellanved | unset($profile_fields_tmp); |
| 1207 | 4892 | acydburn | } |
| 1208 | 4892 | acydburn | |
| 1209 | 4269 | psotfx | // Generate online information for user
|
| 1210 | 4269 | psotfx | if ($config['load_onlinetrack'] && sizeof($id_cache)) |
| 1211 | 3868 | ludovic_arnaud | {
|
| 1212 | 4973 | psotfx | $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline |
| 1213 | 4947 | psotfx | FROM ' . SESSIONS_TABLE . ' |
| 1214 | 6271 | acydburn | WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . ' |
| 1215 | 4269 | psotfx | GROUP BY session_user_id';
|
| 1216 | 3868 | ludovic_arnaud | $result = $db->sql_query($sql); |
| 1217 | 3868 | ludovic_arnaud | |
| 1218 | 4269 | psotfx | $update_time = $config['load_online_time'] * 60; |
| 1219 | 3868 | ludovic_arnaud | while ($row = $db->sql_fetchrow($result)) |
| 1220 | 3868 | ludovic_arnaud | {
|
| 1221 | 7755 | kellanved | $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; |
| 1222 | 3868 | ludovic_arnaud | } |
| 1223 | 5415 | davidmj | $db->sql_freeresult($result); |
| 1224 | 4269 | psotfx | } |
| 1225 | 4269 | psotfx | unset($id_cache); |
| 1226 | 3868 | ludovic_arnaud | |
| 1227 | 4269 | psotfx | // Pull attachment data
|
| 1228 | 4920 | acydburn | if (sizeof($attach_list)) |
| 1229 | 4269 | psotfx | {
|
| 1230 | 6351 | acydburn | if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) |
| 1231 | 3868 | ludovic_arnaud | {
|
| 1232 | 4947 | psotfx | $sql = 'SELECT * |
| 1233 | 4637 | acydburn | FROM ' . ATTACHMENTS_TABLE . ' |
| 1234 | 6271 | acydburn | WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' |
| 1235 | 4883 | acydburn | AND in_message = 0 |
| 1236 | 6628 | acydburn | ORDER BY filetime DESC, post_msg_id ASC';
|
| 1237 | 4269 | psotfx | $result = $db->sql_query($sql); |
| 1238 | 4269 | psotfx | |
| 1239 | 4269 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 1240 | 3868 | ludovic_arnaud | {
|
| 1241 | 4883 | acydburn | $attachments[$row['post_msg_id']][] = $row; |
| 1242 | 4269 | psotfx | } |
| 1243 | 4269 | psotfx | $db->sql_freeresult($result); |
| 1244 | 3868 | ludovic_arnaud | |
| 1245 | 4473 | psotfx | // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags
|
| 1246 | 4920 | acydburn | if (!sizeof($attachments)) |
| 1247 | 4269 | psotfx | {
|
| 1248 | 4947 | psotfx | $sql = 'UPDATE ' . POSTS_TABLE . ' |
| 1249 | 4947 | psotfx | SET post_attachment = 0 |
| 1250 | 6271 | acydburn | WHERE ' . $db->sql_in_set('post_id', $attach_list); |
| 1251 | 4269 | psotfx | $db->sql_query($sql); |
| 1252 | 4269 | psotfx | |
| 1253 | 4269 | psotfx | // We need to update the topic indicator too if the complete topic is now without an attachment
|
| 1254 | 4920 | acydburn | if (sizeof($rowset) != $total_posts) |
| 1255 | 3868 | ludovic_arnaud | {
|
| 1256 | 4269 | psotfx | // Not all posts are displayed so we query the db to find if there's any attachment for this topic
|
| 1257 | 4883 | acydburn | $sql = 'SELECT a.post_msg_id as post_id |
| 1258 | 4269 | psotfx | FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p |
| 1259 | 4269 | psotfx | WHERE p.topic_id = $topic_id |
| 1260 | 4269 | psotfx | AND p.post_approved = 1 |
| 1261 | 4883 | acydburn | AND p.topic_id = a.topic_id";
|
| 1262 | 4269 | psotfx | $result = $db->sql_query_limit($sql, 1); |
| 1263 | 6002 | acydburn | $row = $db->sql_fetchrow($result); |
| 1264 | 6002 | acydburn | $db->sql_freeresult($result); |
| 1265 | 4269 | psotfx | |
| 1266 | 6002 | acydburn | if (!$row) |
| 1267 | 4269 | psotfx | {
|
| 1268 | 4947 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . " |
| 1269 | 4947 | psotfx | SET topic_attachment = 0 |
| 1270 | 4269 | psotfx | WHERE topic_id = $topic_id"; |
| 1271 | 4269 | psotfx | $db->sql_query($sql); |
| 1272 | 4269 | psotfx | } |
| 1273 | 4269 | psotfx | } |
| 1274 | 4269 | psotfx | else
|
| 1275 | 4269 | psotfx | {
|
| 1276 | 4947 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . " |
| 1277 | 4947 | psotfx | SET topic_attachment = 0 |
| 1278 | 3920 | psotfx | WHERE topic_id = $topic_id"; |
| 1279 | 3920 | psotfx | $db->sql_query($sql); |
| 1280 | 3868 | ludovic_arnaud | } |
| 1281 | 3868 | ludovic_arnaud | } |
| 1282 | 4762 | acydburn | else if ($has_attachments && !$topic_data['topic_attachment']) |
| 1283 | 3868 | ludovic_arnaud | {
|
| 1284 | 4269 | psotfx | // Topic has approved attachments but its flag is wrong
|
| 1285 | 4947 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . " |
| 1286 | 4947 | psotfx | SET topic_attachment = 1 |
| 1287 | 3920 | psotfx | WHERE topic_id = $topic_id"; |
| 1288 | 3920 | psotfx | $db->sql_query($sql); |
| 1289 | 4762 | acydburn | |
| 1290 | 4762 | acydburn | $topic_data['topic_attachment'] = 1; |
| 1291 | 3868 | ludovic_arnaud | } |
| 1292 | 3868 | ludovic_arnaud | } |
| 1293 | 4269 | psotfx | else
|
| 1294 | 3868 | ludovic_arnaud | {
|
| 1295 | 4859 | acydburn | $display_notice = true; |
| 1296 | 3868 | ludovic_arnaud | } |
| 1297 | 3868 | ludovic_arnaud | } |
| 1298 | 3868 | ludovic_arnaud | |
| 1299 | 4167 | psotfx | // Instantiate BBCode if need be
|
| 1300 | 6256 | acydburn | if ($bbcode_bitfield !== '') |
| 1301 | 3868 | ludovic_arnaud | {
|
| 1302 | 6263 | davidmj | $bbcode = new bbcode(base64_encode($bbcode_bitfield)); |
| 1303 | 3868 | ludovic_arnaud | } |
| 1304 | 3868 | ludovic_arnaud | |
| 1305 | 4473 | psotfx | $i_total = sizeof($rowset) - 1; |
| 1306 | 4473 | psotfx | $prev_post_id = ''; |
| 1307 | 4167 | psotfx | |
| 1308 | 4870 | acydburn | $template->assign_vars(array( |
| 1309 | 4920 | acydburn | 'S_NUM_POSTS' => sizeof($post_list)) |
| 1310 | 4870 | acydburn | ); |
| 1311 | 4870 | acydburn | |
| 1312 | 4167 | psotfx | // Output the posts
|
| 1313 | 6479 | acydburn | $first_unread = $post_unread = false; |
| 1314 | 4920 | acydburn | for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) |
| 1315 | 3868 | ludovic_arnaud | {
|
| 1316 | 7034 | acydburn | // A non-existing rowset only happens if there was no user present for the entered poster_id
|
| 1317 | 7034 | acydburn | // This could be a broken posts table.
|
| 1318 | 7034 | acydburn | if (!isset($rowset[$post_list[$i]])) |
| 1319 | 7034 | acydburn | {
|
| 1320 | 7034 | acydburn | continue;
|
| 1321 | 7034 | acydburn | } |
| 1322 | 7034 | acydburn | |
| 1323 | 11361 | git-gate | $row = $rowset[$post_list[$i]]; |
| 1324 | 4062 | psotfx | $poster_id = $row['user_id']; |
| 1325 | 3868 | ludovic_arnaud | |
| 1326 | 3868 | ludovic_arnaud | // End signature parsing, only if needed
|
| 1327 | 7256 | acydburn | if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) |
| 1328 | 3868 | ludovic_arnaud | {
|
| 1329 | 6256 | acydburn | $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']); |
| 1330 | 6256 | acydburn | |
| 1331 | 3868 | ludovic_arnaud | if ($user_cache[$poster_id]['sig_bbcode_bitfield']) |
| 1332 | 3868 | ludovic_arnaud | {
|
| 1333 | 4150 | psotfx | $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']); |
| 1334 | 3868 | ludovic_arnaud | } |
| 1335 | 3869 | psotfx | |
| 1336 | 8050 | naderman | $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']); |
| 1337 | 5108 | acydburn | $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']); |
| 1338 | 5313 | acydburn | $user_cache[$poster_id]['sig_parsed'] = true; |
| 1339 | 3868 | ludovic_arnaud | } |
| 1340 | 3868 | ludovic_arnaud | |
| 1341 | 3856 | ludovic_arnaud | // Parse the message and subject
|
| 1342 | 6256 | acydburn | $message = censor_text($row['post_text']); |
| 1343 | 3347 | psotfx | |
| 1344 | 3856 | ludovic_arnaud | // Second parse bbcode here
|
| 1345 | 3856 | ludovic_arnaud | if ($row['bbcode_bitfield']) |
| 1346 | 3856 | ludovic_arnaud | {
|
| 1347 | 4150 | psotfx | $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); |
| 1348 | 3856 | ludovic_arnaud | } |
| 1349 | 303 | thefinn | |
| 1350 | 8050 | naderman | $message = bbcode_nl2br($message); |
| 1351 | 5108 | acydburn | $message = smiley_text($message); |
| 1352 | 987 | psotfx | |
| 1353 | 6803 | acydburn | if (!empty($attachments[$row['post_id']])) |
| 1354 | 4984 | acydburn | {
|
| 1355 | 6803 | acydburn | parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); |
| 1356 | 4984 | acydburn | } |
| 1357 | 4984 | acydburn | |
| 1358 | 8045 | naderman | // Replace naughty words such as farty pants
|
| 1359 | 8045 | naderman | $row['post_subject'] = censor_text($row['post_subject']); |
| 1360 | 8045 | naderman | |
| 1361 | 3856 | ludovic_arnaud | // Highlight active words (primarily for search)
|
| 1362 | 3856 | ludovic_arnaud | if ($highlight_match) |
| 1363 | 3856 | ludovic_arnaud | {
|
| 1364 | 6550 | davidmj | $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message); |
| 1365 | 8045 | naderman | $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $row['post_subject']); |
| 1366 | 3856 | ludovic_arnaud | } |
| 1367 | 3347 | psotfx | |
| 1368 | 3856 | ludovic_arnaud | // Editing information
|
| 1369 | 4767 | acydburn | if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason']) |
| 1370 | 3856 | ludovic_arnaud | {
|
| 1371 | 4767 | acydburn | // Get usernames for all following posts if not already stored
|
| 1372 | 6149 | acydburn | if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])))) |
| 1373 | 4767 | acydburn | {
|
| 1374 | 4767 | acydburn | // Remove all post_ids already parsed (we do not have to check them)
|
| 1375 | 5068 | acydburn | $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i); |
| 1376 | 4767 | acydburn | |
| 1377 | 4947 | psotfx | $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour |
| 1378 | 4767 | acydburn | FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u |
| 1379 | 6271 | acydburn | WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . ' |
| 1380 | 4767 | acydburn | AND p.post_edit_count <> 0 |
| 1381 | 4767 | acydburn | AND p.post_edit_user <> 0 |
| 1382 | 6271 | acydburn | AND p.post_edit_user = u.user_id';
|
| 1383 | 4767 | acydburn | $result2 = $db->sql_query($sql); |
| 1384 | 4767 | acydburn | while ($user_edit_row = $db->sql_fetchrow($result2)) |
| 1385 | 4767 | acydburn | {
|
| 1386 | 4767 | acydburn | $post_edit_list[$user_edit_row['user_id']] = $user_edit_row; |
| 1387 | 4767 | acydburn | } |
| 1388 | 4767 | acydburn | $db->sql_freeresult($result2); |
| 1389 | 4947 | psotfx | |
| 1390 | 4767 | acydburn | unset($post_storage_list); |
| 1391 | 4767 | acydburn | } |
| 1392 | 5078 | psotfx | |
| 1393 | 5027 | acydburn | if ($row['post_edit_reason']) |
| 1394 | 5027 | acydburn | {
|
| 1395 | 6600 | acydburn | // User having edited the post also being the post author?
|
| 1396 | 6600 | acydburn | if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) |
| 1397 | 6600 | acydburn | {
|
| 1398 | 6600 | acydburn | $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); |
| 1399 | 6600 | acydburn | } |
| 1400 | 6600 | acydburn | else
|
| 1401 | 6600 | acydburn | {
|
| 1402 | 6600 | acydburn | $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']); |
| 1403 | 6600 | acydburn | } |
| 1404 | 6149 | acydburn | |
| 1405 | 11603 | git-gate | $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); |
| 1406 | 5027 | acydburn | } |
| 1407 | 5027 | acydburn | else
|
| 1408 | 5027 | acydburn | {
|
| 1409 | 6149 | acydburn | if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']])) |
| 1410 | 6149 | acydburn | {
|
| 1411 | 6149 | acydburn | $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']]; |
| 1412 | 6149 | acydburn | } |
| 1413 | 6149 | acydburn | |
| 1414 | 6600 | acydburn | // User having edited the post also being the post author?
|
| 1415 | 6600 | acydburn | if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) |
| 1416 | 6600 | acydburn | {
|
| 1417 | 6600 | acydburn | $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); |
| 1418 | 6600 | acydburn | } |
| 1419 | 6600 | acydburn | else
|
| 1420 | 6600 | acydburn | {
|
| 1421 | 6600 | acydburn | $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']); |
| 1422 | 6600 | acydburn | } |
| 1423 | 6600 | acydburn | |
| 1424 | 11603 | git-gate | $l_edited_by = $user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $user->format_date($row['post_edit_time'], false, true)); |
| 1425 | 5027 | acydburn | } |
| 1426 | 3856 | ludovic_arnaud | } |
| 1427 | 3856 | ludovic_arnaud | else
|
| 1428 | 3856 | ludovic_arnaud | {
|
| 1429 | 3856 | ludovic_arnaud | $l_edited_by = ''; |
| 1430 | 3856 | ludovic_arnaud | } |
| 1431 | 2448 | psotfx | |
| 1432 | 4634 | acydburn | // Bump information
|
| 1433 | 5534 | subblue | if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) ) |
| 1434 | 4634 | acydburn | {
|
| 1435 | 4947 | psotfx | // It is safe to grab the username from the user cache array, we are at the last
|
| 1436 | 7007 | acydburn | // post and only the topic poster and last poster are allowed to bump.
|
| 1437 | 7007 | acydburn | // Admins and mods are bound to the above rules too...
|
| 1438 | 9563 | bantu | $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)); |
| 1439 | 4634 | acydburn | } |
| 1440 | 4634 | acydburn | else
|
| 1441 | 4634 | acydburn | {
|
| 1442 | 4634 | acydburn | $l_bumped_by = ''; |
| 1443 | 4634 | acydburn | } |
| 1444 | 4634 | acydburn | |
| 1445 | 4984 | acydburn | $cp_row = array(); |
| 1446 | 4818 | acydburn | |
| 1447 | 4984 | acydburn | //
|
| 1448 | 4984 | acydburn | if ($config['load_cpf_viewtopic']) |
| 1449 | 4892 | acydburn | {
|
| 1450 | 4892 | acydburn | $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array(); |
| 1451 | 4892 | acydburn | } |
| 1452 | 4892 | acydburn | |
| 1453 | 5272 | acydburn | $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
| 1454 | 6151 | naderman | |
| 1455 | 5272 | acydburn | $s_first_unread = false; |
| 1456 | 5272 | acydburn | if (!$first_unread && $post_unread) |
| 1457 | 5272 | acydburn | {
|
| 1458 | 5272 | acydburn | $s_first_unread = $first_unread = true; |
| 1459 | 5272 | acydburn | } |
| 1460 | 5272 | acydburn | |
| 1461 | 10076 | acydburn | $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || ( |
| 1462 | 10076 | acydburn | $user->data['user_id'] == $poster_id && |
| 1463 | 10076 | acydburn | $auth->acl_get('f_edit', $forum_id) && |
| 1464 | 10076 | acydburn | !$row['post_edit_locked'] && |
| 1465 | 10076 | acydburn | ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']) |
| 1466 | 10076 | acydburn | ))); |
| 1467 | 9798 | acydburn | |
| 1468 | 10076 | acydburn | $delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ( |
| 1469 | 10076 | acydburn | $user->data['user_id'] == $poster_id && |
| 1470 | 10076 | acydburn | $auth->acl_get('f_delete', $forum_id) && |
| 1471 | 10076 | acydburn | $topic_data['topic_last_post_id'] == $row['post_id'] && |
| 1472 | 10080 | nickvergessen | ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) && |
| 1473 | 10080 | nickvergessen | // we do not want to allow removal of the last post if a moderator locked it!
|
| 1474 | 10076 | acydburn | !$row['post_edit_locked'] |
| 1475 | 10076 | acydburn | ))); |
| 1476 | 10076 | acydburn | |
| 1477 | 4984 | acydburn | //
|
| 1478 | 4892 | acydburn | $postrow = array( |
| 1479 | 9790 | toonarmy | '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']), |
| 1480 | 9790 | toonarmy | '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']), |
| 1481 | 9790 | toonarmy | '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']), |
| 1482 | 9790 | toonarmy | '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']), |
| 1483 | 6589 | acydburn | |
| 1484 | 6818 | acydburn | 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'], |
| 1485 | 6818 | acydburn | 'RANK_IMG' => $user_cache[$poster_id]['rank_image'], |
| 1486 | 6818 | acydburn | 'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'], |
| 1487 | 5633 | acydburn | 'POSTER_JOINED' => $user_cache[$poster_id]['joined'], |
| 1488 | 5633 | acydburn | 'POSTER_POSTS' => $user_cache[$poster_id]['posts'], |
| 1489 | 5633 | acydburn | 'POSTER_FROM' => $user_cache[$poster_id]['from'], |
| 1490 | 5633 | acydburn | 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'], |
| 1491 | 5345 | grahamje | 'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'], |
| 1492 | 6151 | naderman | 'POSTER_AGE' => $user_cache[$poster_id]['age'], |
| 1493 | 3920 | psotfx | |
| 1494 | 9435 | acydburn | 'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false), |
| 1495 | 6002 | acydburn | 'POST_SUBJECT' => $row['post_subject'], |
| 1496 | 6002 | acydburn | 'MESSAGE' => $message, |
| 1497 | 6002 | acydburn | 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '', |
| 1498 | 6002 | acydburn | 'EDITED_MESSAGE' => $l_edited_by, |
| 1499 | 6002 | acydburn | 'EDIT_REASON' => $row['post_edit_reason'], |
| 1500 | 6002 | acydburn | 'BUMPED_MESSAGE' => $l_bumped_by, |
| 1501 | 884 | psotfx | |
| 1502 | 10751 | git-gate | 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), |
| 1503 | 7007 | acydburn | 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', |
| 1504 | 7007 | acydburn | 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', |
| 1505 | 7007 | acydburn | 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', |
| 1506 | 6002 | acydburn | 'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'], |
| 1507 | 6237 | acydburn | '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')), |
| 1508 | 6002 | acydburn | 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false), |
| 1509 | 2708 | psotfx | |
| 1510 | 10076 | acydburn | 'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '', |
| 1511 | 6015 | acydburn | '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']}") : '', |
| 1512 | 6045 | naderman | '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) : '', |
| 1513 | 10076 | acydburn | 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '', |
| 1514 | 2708 | psotfx | |
| 1515 | 9780 | nickvergessen | 'U_PROFILE' => $user_cache[$poster_id]['profile'], |
| 1516 | 6002 | acydburn | 'U_SEARCH' => $user_cache[$poster_id]['search'], |
| 1517 | 6662 | acydburn | 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', |
| 1518 | 6002 | acydburn | 'U_EMAIL' => $user_cache[$poster_id]['email'], |
| 1519 | 6002 | acydburn | 'U_WWW' => $user_cache[$poster_id]['www'], |
| 1520 | 6002 | acydburn | 'U_ICQ' => $user_cache[$poster_id]['icq'], |
| 1521 | 6002 | acydburn | 'U_AIM' => $user_cache[$poster_id]['aim'], |
| 1522 | 6002 | acydburn | 'U_MSN' => $user_cache[$poster_id]['msn'], |
| 1523 | 6002 | acydburn | 'U_YIM' => $user_cache[$poster_id]['yim'], |
| 1524 | 6002 | acydburn | 'U_JABBER' => $user_cache[$poster_id]['jabber'], |
| 1525 | 3357 | psotfx | |
| 1526 | 6030 | grahamje | 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', |
| 1527 | 6045 | naderman | '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) : '', |
| 1528 | 6045 | naderman | '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) : '', |
| 1529 | 11100 | git-gate | 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], |
| 1530 | 5861 | acydburn | 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', |
| 1531 | 4947 | psotfx | 'U_PREV_POST_ID' => $prev_post_id, |
| 1532 | 6045 | naderman | '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) : '', |
| 1533 | 7355 | naderman | '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) : '', |
| 1534 | 2708 | psotfx | |
| 1535 | 4964 | acydburn | 'POST_ID' => $row['post_id'], |
| 1536 | 11018 | git-gate | 'POST_NUMBER' => $i + $start + 1, |
| 1537 | 7322 | acydburn | 'POSTER_ID' => $poster_id, |
| 1538 | 4964 | acydburn | |
| 1539 | 6002 | acydburn | 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, |
| 1540 | 5313 | acydburn | 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, |
| 1541 | 5649 | naderman | 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, |
| 1542 | 4947 | psotfx | 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], |
| 1543 | 4964 | acydburn | 'S_FRIEND' => ($row['friend']) ? true : false, |
| 1544 | 5272 | acydburn | 'S_UNREAD_POST' => $post_unread, |
| 1545 | 5272 | acydburn | 'S_FIRST_UNREAD' => $s_first_unread, |
| 1546 | 6589 | acydburn | 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, |
| 1547 | 7646 | acydburn | 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, |
| 1548 | 6589 | acydburn | |
| 1549 | 6589 | acydburn | 'S_IGNORE_POST' => ($row['hide_post']) ? true : false, |
| 1550 | 6589 | acydburn | 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '', |
| 1551 | 3869 | psotfx | ); |
| 1552 | 6002 | acydburn | |
| 1553 | 5137 | acydburn | if (isset($cp_row['row']) && sizeof($cp_row['row'])) |
| 1554 | 4892 | acydburn | {
|
| 1555 | 5137 | acydburn | $postrow = array_merge($postrow, $cp_row['row']); |
| 1556 | 4984 | acydburn | } |
| 1557 | 4892 | acydburn | |
| 1558 | 4984 | acydburn | // Dump vars into template
|
| 1559 | 4892 | acydburn | $template->assign_block_vars('postrow', $postrow); |
| 1560 | 4947 | psotfx | |
| 1561 | 6002 | acydburn | if (!empty($cp_row['blockrow'])) |
| 1562 | 5137 | acydburn | {
|
| 1563 | 5137 | acydburn | foreach ($cp_row['blockrow'] as $field_data) |
| 1564 | 5137 | acydburn | {
|
| 1565 | 5137 | acydburn | $template->assign_block_vars('postrow.custom_fields', $field_data); |
| 1566 | 5137 | acydburn | } |
| 1567 | 5137 | acydburn | } |
| 1568 | 5137 | acydburn | |
| 1569 | 4818 | acydburn | // Display not already displayed Attachments for this post, we already parsed them. ;)
|
| 1570 | 6002 | acydburn | if (!empty($attachments[$row['post_id']])) |
| 1571 | 3856 | ludovic_arnaud | {
|
| 1572 | 4818 | acydburn | foreach ($attachments[$row['post_id']] as $attachment) |
| 1573 | 4818 | acydburn | {
|
| 1574 | 4818 | acydburn | $template->assign_block_vars('postrow.attachment', array( |
| 1575 | 4920 | acydburn | 'DISPLAY_ATTACHMENT' => $attachment) |
| 1576 | 4818 | acydburn | ); |
| 1577 | 4818 | acydburn | } |
| 1578 | 2714 | psotfx | } |
| 1579 | 3868 | ludovic_arnaud | |
| 1580 | 4473 | psotfx | $prev_post_id = $row['post_id']; |
| 1581 | 4473 | psotfx | |
| 1582 | 5861 | acydburn | unset($rowset[$post_list[$i]]); |
| 1583 | 3868 | ludovic_arnaud | unset($attachments[$row['post_id']]); |
| 1584 | 81 | thefinn | } |
| 1585 | 6002 | acydburn | unset($rowset, $user_cache); |
| 1586 | 82 | thefinn | |
| 1587 | 8835 | toonarmy | // Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view'
|
| 1588 | 9411 | acydburn | if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created']))) |
| 1589 | 3286 | psotfx | {
|
| 1590 | 4167 | psotfx | $sql = 'UPDATE ' . TOPICS_TABLE . ' |
| 1591 | 4167 | psotfx | SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . " |
| 1592 | 3856 | ludovic_arnaud | WHERE topic_id = $topic_id"; |
| 1593 | 3807 | acydburn | $db->sql_query($sql); |
| 1594 | 3961 | psotfx | |
| 1595 | 3961 | psotfx | // Update the attachment download counts
|
| 1596 | 4167 | psotfx | if (sizeof($update_count)) |
| 1597 | 3961 | psotfx | {
|
| 1598 | 4947 | psotfx | $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' |
| 1599 | 4947 | psotfx | SET download_count = download_count + 1 |
| 1600 | 6271 | acydburn | WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); |
| 1601 | 3961 | psotfx | $db->sql_query($sql); |
| 1602 | 3961 | psotfx | } |
| 1603 | 3286 | psotfx | } |
| 1604 | 3286 | psotfx | |
| 1605 | 7257 | acydburn | // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
|
| 1606 | 7257 | acydburn | 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]) |
| 1607 | 5272 | acydburn | {
|
| 1608 | 11100 | git-gate | markread('topic', $forum_id, $topic_id, $max_post_time); |
| 1609 | 6256 | acydburn | |
| 1610 | 6256 | acydburn | // Update forum info
|
| 1611 | 11100 | git-gate | $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); |
| 1612 | 5272 | acydburn | } |
| 1613 | 6320 | acydburn | else
|
| 1614 | 6320 | acydburn | {
|
| 1615 | 6320 | acydburn | $all_marked_read = true; |
| 1616 | 6320 | acydburn | } |
| 1617 | 3953 | psotfx | |
| 1618 | 6320 | acydburn | // If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link
|
| 1619 | 7312 | acydburn | if ($all_marked_read) |
| 1620 | 6320 | acydburn | {
|
| 1621 | 7312 | acydburn | if ($post_unread) |
| 1622 | 7312 | acydburn | {
|
| 1623 | 7312 | acydburn | $template->assign_vars(array( |
| 1624 | 7312 | acydburn | 'U_VIEW_UNREAD_POST' => '#unread', |
| 1625 | 7312 | acydburn | )); |
| 1626 | 7312 | acydburn | } |
| 1627 | 7312 | acydburn | else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id]) |
| 1628 | 7312 | acydburn | {
|
| 1629 | 7312 | acydburn | $template->assign_vars(array( |
| 1630 | 7312 | acydburn | 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', |
| 1631 | 7312 | acydburn | )); |
| 1632 | 7312 | acydburn | } |
| 1633 | 6320 | acydburn | } |
| 1634 | 6320 | acydburn | else if (!$all_marked_read) |
| 1635 | 6320 | acydburn | {
|
| 1636 | 6320 | acydburn | $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false; |
| 1637 | 6320 | acydburn | |
| 1638 | 6320 | acydburn | // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread
|
| 1639 | 6320 | acydburn | if ($last_page && $post_unread) |
| 1640 | 6320 | acydburn | {
|
| 1641 | 6320 | acydburn | $template->assign_vars(array( |
| 1642 | 6320 | acydburn | 'U_VIEW_UNREAD_POST' => '#unread', |
| 1643 | 6320 | acydburn | )); |
| 1644 | 6320 | acydburn | } |
| 1645 | 6320 | acydburn | else if (!$last_page) |
| 1646 | 6320 | acydburn | {
|
| 1647 | 6320 | acydburn | $template->assign_vars(array( |
| 1648 | 6320 | acydburn | 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', |
| 1649 | 6320 | acydburn | )); |
| 1650 | 6320 | acydburn | } |
| 1651 | 6320 | acydburn | } |
| 1652 | 6320 | acydburn | |
| 1653 | 9688 | Kellanved | // let's set up quick_reply
|
| 1654 | 10558 | git-gate | $s_quick_reply = false; |
| 1655 | 10558 | git-gate | if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id)) |
| 1656 | 10558 | git-gate | {
|
| 1657 | 10558 | git-gate | // Quick reply enabled forum
|
| 1658 | 10558 | git-gate | $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false; |
| 1659 | 10558 | git-gate | } |
| 1660 | 9798 | acydburn | |
| 1661 | 9798 | acydburn | if ($s_can_vote || $s_quick_reply) |
| 1662 | 9688 | Kellanved | {
|
| 1663 | 9688 | Kellanved | add_form_key('posting');
|
| 1664 | 9798 | acydburn | |
| 1665 | 9691 | Kellanved | if ($s_quick_reply) |
| 1666 | 9688 | Kellanved | {
|
| 1667 | 9798 | acydburn | $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig'); |
| 1668 | 9798 | acydburn | $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id); |
| 1669 | 9798 | acydburn | $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id); |
| 1670 | 10558 | git-gate | $s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']); |
| 1671 | 9798 | acydburn | |
| 1672 | 9688 | Kellanved | $qr_hidden_fields = array( |
| 1673 | 9798 | acydburn | 'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], |
| 1674 | 9798 | acydburn | 'lastclick' => (int) time(), |
| 1675 | 9798 | acydburn | 'topic_id' => (int) $topic_data['topic_id'], |
| 1676 | 9798 | acydburn | 'forum_id' => (int) $forum_id, |
| 1677 | 9688 | Kellanved | ); |
| 1678 | 9798 | acydburn | |
| 1679 | 9798 | acydburn | // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
|
| 1680 | 9798 | acydburn | (!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true; |
| 1681 | 9798 | acydburn | (!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true; |
| 1682 | 9798 | acydburn | (!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true; |
| 1683 | 9798 | acydburn | ($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true; |
| 1684 | 9798 | acydburn | ($s_notify) ? $qr_hidden_fields['notify'] = 1 : true; |
| 1685 | 10179 | nickvergessen | ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true; |
| 1686 | 9798 | acydburn | |
| 1687 | 9688 | Kellanved | $template->assign_vars(array( |
| 1688 | 9798 | acydburn | 'S_QUICK_REPLY' => true, |
| 1689 | 9688 | Kellanved | 'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id"), |
| 1690 | 9688 | Kellanved | 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), |
| 1691 | 9688 | Kellanved | 'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']), |
| 1692 | 9688 | Kellanved | )); |
| 1693 | 9688 | Kellanved | } |
| 1694 | 9688 | Kellanved | } |
| 1695 | 9693 | Kellanved | // now I have the urge to wash my hands :(
|
| 1696 | 9798 | acydburn | |
| 1697 | 9798 | acydburn | |
| 1698 | 6364 | acydburn | // We overwrite $_REQUEST['f'] if there is no forum specified
|
| 1699 | 6364 | acydburn | // to be able to display the correct online list.
|
| 1700 | 6364 | acydburn | // One downside is that the user currently viewing this topic/post is not taken into account.
|
| 1701 | 10801 | git-gate | if (!request_var('f', 0)) |
| 1702 | 6364 | acydburn | {
|
| 1703 | 10801 | git-gate | $request->overwrite('f', $forum_id); |
| 1704 | 6364 | acydburn | } |
| 1705 | 6364 | acydburn | |
| 1706 | 10342 | acydburn | // We need to do the same with the topic_id. See #53025.
|
| 1707 | 10801 | git-gate | if (!request_var('t', 0) && !empty($topic_id)) |
| 1708 | 10342 | acydburn | {
|
| 1709 | 10801 | git-gate | $request->overwrite('t', $topic_id); |
| 1710 | 10342 | acydburn | } |
| 1711 | 10342 | acydburn | |
| 1712 | 2995 | psotfx | // Output the page
|
| 1713 | 10897 | git-gate | page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id); |
| 1714 | 2995 | psotfx | |
| 1715 | 2995 | psotfx | $template->set_filenames(array( |
| 1716 | 4473 | psotfx | 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html') |
| 1717 | 2995 | psotfx | ); |
| 1718 | 6015 | acydburn | make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); |
| 1719 | 2995 | psotfx | |
| 1720 | 3969 | psotfx | page_footer(); |

