root / tags / milestone_3 / phpBB / viewforum.php
History | View | Annotate | Download (18.7 kB)
| 1 | <?php
|
|---|---|
| 2 | /**
|
| 3 | * |
| 4 | * @package phpBB3 |
| 5 | * @version $Id: viewforum.php 5247 2005-10-02 18:47:06Z acydburn $ |
| 6 | * @copyright (c) 2005 phpBB Group |
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | /**
|
| 12 | */ |
| 13 | define('IN_PHPBB', true); |
| 14 | $phpbb_root_path = './'; |
| 15 | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | include($phpbb_root_path . 'common.'.$phpEx); |
| 17 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 18 | |
| 19 | // Start session
|
| 20 | $user->session_begin();
|
| 21 | $auth->acl($user->data); |
| 22 | |
| 23 | // Start initial var setup
|
| 24 | $forum_id = request_var('f', 0); |
| 25 | $mark_read = request_var('mark', ''); |
| 26 | $start = request_var('start', 0); |
| 27 | |
| 28 | $sort_days = request_var('st', ((!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0)); |
| 29 | $sort_key = request_var('sk', ((!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't')); |
| 30 | $sort_dir = request_var('sd', ((!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd')); |
| 31 | |
| 32 | // Check if the user has actually sent a forum ID with his/her request
|
| 33 | // If not give them a nice error page.
|
| 34 | if (!$forum_id) |
| 35 | {
|
| 36 | trigger_error('NO_FORUM'); |
| 37 | } |
| 38 | |
| 39 | // Grab appropriate forum data
|
| 40 | if (!$user->data['is_registered']) |
| 41 | {
|
| 42 | $sql = 'SELECT * |
| 43 | FROM ' . FORUMS_TABLE . ' |
| 44 | WHERE forum_id = ' . $forum_id; |
| 45 | } |
| 46 | else
|
| 47 | {
|
| 48 | if ($config['load_db_lastread']) |
| 49 | {
|
| 50 | $sql_lastread = 'LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' |
| 51 | AND ft.forum_id = f.forum_id)';
|
| 52 | $lastread_select = ', ft.mark_time '; |
| 53 | } |
| 54 | else
|
| 55 | {
|
| 56 | $sql_lastread = $lastread_select = ''; |
| 57 | $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array(); |
| 58 | } |
| 59 | |
| 60 | $sql_from = ($sql_lastread) ? '((' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ")) $sql_lastread)" : '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . '))'; |
| 61 | |
| 62 | $sql = "SELECT f.*, fw.notify_status $lastread_select |
| 63 | FROM $sql_from |
| 64 | WHERE f.forum_id = $forum_id"; |
| 65 | } |
| 66 | $result = $db->sql_query($sql); |
| 67 | |
| 68 | if (!($forum_data = $db->sql_fetchrow($result))) |
| 69 | {
|
| 70 | trigger_error('NO_FORUM'); |
| 71 | } |
| 72 | $db->sql_freeresult($result); |
| 73 | |
| 74 | if (!$user->data['is_registered'] && $config['load_db_lastread']) |
| 75 | {
|
| 76 | $forum_data['mark_time'] = 0; |
| 77 | } |
| 78 | |
| 79 | // Is this forum a link? ... User got here either because the
|
| 80 | // number of clicks is being tracked or they guessed the id
|
| 81 | if ($forum_data['forum_link']) |
| 82 | {
|
| 83 | // Does it have click tracking enabled?
|
| 84 | if ($forum_data['forum_flags'] & 1) |
| 85 | {
|
| 86 | $sql = 'UPDATE ' . FORUMS_TABLE . ' |
| 87 | SET forum_posts = forum_posts + 1 |
| 88 | WHERE forum_id = ' . $forum_id; |
| 89 | $db->sql_query($sql); |
| 90 | } |
| 91 | |
| 92 | redirect(str_replace('&', '&', $forum_data['forum_link'])); |
| 93 | } |
| 94 | |
| 95 | // Configure style, language, etc.
|
| 96 | $user->setup('viewforum', $forum_data['forum_style']); |
| 97 | |
| 98 | // Forum is passworded ... check whether access has been granted to this
|
| 99 | // user this session, if not show login box
|
| 100 | if ($forum_data['forum_password']) |
| 101 | {
|
| 102 | login_forum_box($forum_data);
|
| 103 | } |
| 104 | |
| 105 | // Redirect to login upon emailed notification links
|
| 106 | if (isset($_GET['e']) && !$user->data['is_registered']) |
| 107 | {
|
| 108 | login_box('', $user->lang['LOGIN_NOTIFY_FORUM']); |
| 109 | } |
| 110 | |
| 111 | // Permissions check
|
| 112 | if (!$auth->acl_get('f_read', $forum_id)) |
| 113 | {
|
| 114 | if ($user->data['user_id'] != ANONYMOUS) |
| 115 | {
|
| 116 | trigger_error($user->lang['SORRY_AUTH_READ']); |
| 117 | } |
| 118 | |
| 119 | login_box('', $user->lang['LOGIN_VIEWFORUM']); |
| 120 | } |
| 121 | |
| 122 | // Build navigation links
|
| 123 | generate_forum_nav($forum_data);
|
| 124 | |
| 125 | // Forum Rules
|
| 126 | generate_forum_rules($forum_data);
|
| 127 | |
| 128 | // Do we have subforums?
|
| 129 | $active_forum_ary = $moderators = array(); |
| 130 | |
| 131 | if ($forum_data['left_id'] != $forum_data['right_id'] - 1) |
| 132 | {
|
| 133 | $active_forum_ary = display_forums($forum_data); |
| 134 | } |
| 135 | else
|
| 136 | {
|
| 137 | $template->assign_var('S_HAS_SUBFORUM', false); |
| 138 | } |
| 139 | get_moderators($moderators, $forum_id); |
| 140 | |
| 141 | // Output forum listing if it is postable
|
| 142 | if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)) |
| 143 | {
|
| 144 | // Handle marking posts
|
| 145 | if ($mark_read == 'topics') |
| 146 | {
|
| 147 | if ($user->data['is_registered']) |
| 148 | {
|
| 149 | markread('mark', $forum_id); |
| 150 | } |
| 151 | |
| 152 | meta_refresh(3, "viewforum.$phpEx$SID&f=$forum_id"); |
| 153 | |
| 154 | $message = $user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . "viewforum.$phpEx$SID&f=$forum_id" . '">', '</a> '); |
| 155 | trigger_error($message); |
| 156 | } |
| 157 | |
| 158 | // Is a forum specific topic count required?
|
| 159 | if ($forum_data['forum_topics_per_page']) |
| 160 | {
|
| 161 | $config['topics_per_page'] = $forum_data['forum_topics_per_page']; |
| 162 | } |
| 163 | |
| 164 | // Do the forum Prune thang - cron type job ...
|
| 165 | if ($forum_data['prune_next'] < time() && $forum_data['enable_prune']) |
| 166 | {
|
| 167 | include_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); |
| 168 | |
| 169 | if ($forum_data['prune_days']) |
| 170 | {
|
| 171 | auto_prune($forum_id, 'posted', $forum_data['forum_flags'], $forum_data['prune_days'], $forum_data['prune_freq']); |
| 172 | } |
| 173 | if ($forum_data['prune_viewed']) |
| 174 | {
|
| 175 | auto_prune($forum_id, 'viewed', $forum_data['forum_flags'], $forum_data['prune_viewed'], $forum_data['prune_freq']); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Forum rules amd subscription info
|
| 180 | $s_watching_forum = $s_watching_forum_img = array(); |
| 181 | $s_watching_forum['link'] = $s_watching_forum['title'] = ''; |
| 182 | if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) |
| 183 | {
|
| 184 | $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; |
| 185 | watch_topic_forum('forum', $s_watching_forum, $s_watching_forum_img, $user->data['user_id'], $forum_id, $notify_status); |
| 186 | } |
| 187 | |
| 188 | $s_forum_rules = ''; |
| 189 | gen_forum_auth_level('forum', $forum_id); |
| 190 | |
| 191 | // Topic ordering options
|
| 192 | $limit_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 364 => $user->lang['1_YEAR']); |
| 193 | |
| 194 | $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); |
| 195 | $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); |
| 196 | |
| 197 | $sort_key = (!in_array($sort_key, array('a', 't', 'r', 's', 'v'))) ? 't' : $sort_key; |
| 198 | |
| 199 | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
| 200 | 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); |
| 201 | |
| 202 | // Limit topics to certain time frame, obtain correct topic count
|
| 203 | if ($sort_days) |
| 204 | {
|
| 205 | $min_post_time = time() - ($sort_days * 86400); |
| 206 | |
| 207 | $sql = 'SELECT COUNT(topic_id) AS num_topics |
| 208 | FROM ' . TOPICS_TABLE . " |
| 209 | WHERE forum_id = $forum_id |
| 210 | AND topic_type <> " . POST_ANNOUNCE . " |
| 211 | AND topic_last_post_time >= $min_post_time |
| 212 | " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); |
| 213 | $result = $db->sql_query($sql); |
| 214 | |
| 215 | if (isset($_POST['sort'])) |
| 216 | {
|
| 217 | $start = 0; |
| 218 | } |
| 219 | $topics_count = ($row = $db->sql_fetchrow($result)) ? $row['num_topics'] : 0; |
| 220 | $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time"; |
| 221 | } |
| 222 | else
|
| 223 | {
|
| 224 | if ($auth->acl_get('m_approve', $forum_id)) |
| 225 | {
|
| 226 | $topics_count = ($forum_data['forum_topics_real']) ? $forum_data['forum_topics_real'] : 1; |
| 227 | } |
| 228 | else
|
| 229 | {
|
| 230 | $topics_count = ($forum_data['forum_topics']) ? $forum_data['forum_topics'] : 1; |
| 231 | } |
| 232 | |
| 233 | $sql_limit_time = ''; |
| 234 | } |
| 235 | |
| 236 | // Basic pagewide vars
|
| 237 | $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; |
| 238 | |
| 239 | $template->assign_vars(array( |
| 240 | 'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&f=$forum_id&$u_sort_param", $topics_count, $config['topics_per_page'], $start), |
| 241 | 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), |
| 242 | 'TOTAL_TOPICS' => ($forum_data['forum_flags'] & 16) ? false : (($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count)), |
| 243 | 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode(', ', $moderators[$forum_id]) : '', |
| 244 | |
| 245 | 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('btn_locked', $post_alt) : $user->img('btn_post', $post_alt), |
| 246 | 'FOLDER_IMG' => $user->img('folder', 'NO_NEW_POSTS'), |
| 247 | 'FOLDER_NEW_IMG' => $user->img('folder_new', 'NEW_POSTS'), |
| 248 | 'FOLDER_HOT_IMG' => $user->img('folder_hot', 'NO_NEW_POSTS_HOT'), |
| 249 | 'FOLDER_HOT_NEW_IMG' => $user->img('folder_hot_new', 'NEW_POSTS_HOT'), |
| 250 | 'FOLDER_LOCKED_IMG' => $user->img('folder_locked', 'NO_NEW_POSTS_LOCKED'), |
| 251 | 'FOLDER_LOCKED_NEW_IMG' => $user->img('folder_locked_new', 'NEW_POSTS_LOCKED'), |
| 252 | 'FOLDER_STICKY_IMG' => $user->img('folder_sticky', 'POST_STICKY'), |
| 253 | 'FOLDER_STICKY_NEW_IMG' => $user->img('folder_sticky_new', 'POST_STICKY'), |
| 254 | 'FOLDER_ANNOUNCE_IMG' => $user->img('folder_announce', 'POST_ANNOUNCEMENT'), |
| 255 | 'FOLDER_ANNOUNCE_NEW_IMG'=> $user->img('folder_announce_new', 'POST_ANNOUNCEMENT'), |
| 256 | 'FOLDER_MOVED_IMG' => $user->img('folder_moved', 'TOPIC_MOVED'), |
| 257 | |
| 258 | 'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'), |
| 259 | 'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'), |
| 260 | |
| 261 | 'GOTO_PAGE_IMG' => $user->img('icon_post', 'GOTO_PAGE'), |
| 262 | |
| 263 | 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], |
| 264 | |
| 265 | 'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, |
| 266 | 'S_DISPLAY_ACTIVE' => ($forum_data['forum_type'] == FORUM_CAT && $forum_data['forum_flags'] & 16) ? true : false, |
| 267 | 'S_SELECT_SORT_DIR' => $s_sort_dir, |
| 268 | 'S_SELECT_SORT_KEY' => $s_sort_key, |
| 269 | 'S_SELECT_SORT_DAYS' => $s_limit_days, |
| 270 | 'S_TOPIC_ICONS' => ($forum_data['forum_type'] == FORUM_CAT && $forum_data['forum_flags'] & 16) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), |
| 271 | 'S_WATCH_FORUM_LINK' => $s_watching_forum['link'], |
| 272 | 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], |
| 273 | 'S_FORUM_ACTION' => "viewforum.$phpEx$SID&f=$forum_id&start=$start", |
| 274 | 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('f_search', $forum_id)) ? true : false, |
| 275 | 'S_SEARCHBOX_ACTION' => "search.$phpEx$SID&search_forum[]=$forum_id", |
| 276 | |
| 277 | 'U_MCP' => ($auth->acl_gets('m_', $forum_id)) ? "mcp.$phpEx?sid=$user->session_id&f=$forum_id&mode=forum_view" : '', |
| 278 | 'U_POST_NEW_TOPIC' => "posting.$phpEx$SID&mode=post&f=$forum_id", |
| 279 | 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=$forum_id&$u_sort_param&start=$start", |
| 280 | 'U_MARK_TOPICS' => "viewforum.$phpEx$SID&f=$forum_id&mark=topics") |
| 281 | ); |
| 282 | |
| 283 | // Grab icons
|
| 284 | $icons = array(); |
| 285 | $cache->obtain_icons($icons); |
| 286 | |
| 287 | // Grab all topic data
|
| 288 | $rowset = $announcement_list = $topic_list = array(); |
| 289 | |
| 290 | $sql_from = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['is_registered']) ? '(' . TOPICS_TABLE . ' t LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . '))' : TOPICS_TABLE . ' t '; |
| 291 | $sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'; |
| 292 | $sql_select = (($config['load_db_lastread'] || $config['load_db_track']) && $user->data['is_registered']) ? ', tt.mark_type, tt.mark_time' : ''; |
| 293 | |
| 294 | if ($forum_data['forum_type'] == FORUM_POST) |
| 295 | {
|
| 296 | // Obtain announcements ... removed sort ordering, sort by time in all cases
|
| 297 | $sql = "SELECT t.* $sql_select |
| 298 | FROM $sql_from |
| 299 | WHERE t.forum_id IN ($forum_id, 0) |
| 300 | AND t.topic_type IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ') |
| 301 | ORDER BY t.topic_time DESC';
|
| 302 | $result = $db->sql_query($sql); |
| 303 | |
| 304 | while ($row = $db->sql_fetchrow($result)) |
| 305 | {
|
| 306 | $rowset[$row['topic_id']] = $row; |
| 307 | $announcement_list[] = $row['topic_id']; |
| 308 | } |
| 309 | $db->sql_freeresult($result); |
| 310 | } |
| 311 | |
| 312 | // If the user is trying to reach late pages, start searching from the end
|
| 313 | $store_reverse = false; |
| 314 | $sql_limit = $config['topics_per_page']; |
| 315 | if ($start > $topics_count / 2) |
| 316 | {
|
| 317 | $store_reverse = true; |
| 318 | |
| 319 | if ($start + $config['topics_per_page'] > $topics_count) |
| 320 | {
|
| 321 | $sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start)); |
| 322 | } |
| 323 | |
| 324 | // Select the sort order
|
| 325 | $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
| 326 | $sql_start = max(0, $topics_count - $sql_limit - $start); |
| 327 | } |
| 328 | else
|
| 329 | {
|
| 330 | // Select the sort order
|
| 331 | $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
| 332 | $sql_start = $start; |
| 333 | } |
| 334 | |
| 335 | // Obtain other topics
|
| 336 | $sql_where = ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary)) ? "= $forum_id" : 'IN (' . implode(', ', $active_forum_ary['forum_id']) . ')'; |
| 337 | |
| 338 | $sql = "SELECT t.* $sql_select |
| 339 | FROM $sql_from |
| 340 | WHERE t.forum_id $sql_where |
| 341 | AND t.topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ") |
| 342 | $sql_approved |
| 343 | $sql_limit_time |
| 344 | ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; |
| 345 | $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); |
| 346 | |
| 347 | while ($row = $db->sql_fetchrow($result)) |
| 348 | {
|
| 349 | $rowset[$row['topic_id']] = $row; |
| 350 | $topic_list[] = $row['topic_id']; |
| 351 | } |
| 352 | $db->sql_freeresult($result); |
| 353 | |
| 354 | $topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list); |
| 355 | |
| 356 | // Okay, lets dump out the page ...
|
| 357 | if (sizeof($topic_list)) |
| 358 | {
|
| 359 | if ($config['load_db_lastread']) |
| 360 | {
|
| 361 | $mark_time_forum = $forum_data['mark_time']; |
| 362 | } |
| 363 | else
|
| 364 | {
|
| 365 | $mark_time_forum = (isset($tracking_topics[$forum_id][0])) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $config['board_startdate'] : 0; |
| 366 | } |
| 367 | |
| 368 | $mark_forum_read = true; |
| 369 | |
| 370 | $s_type_switch = 0; |
| 371 | foreach ($topic_list as $topic_id) |
| 372 | {
|
| 373 | $row = &$rowset[$topic_id]; |
| 374 | |
| 375 | if ($config['load_db_lastread']) |
| 376 | {
|
| 377 | $mark_time_topic = ($user->data['is_registered']) ? $row['mark_time'] : 0; |
| 378 | } |
| 379 | else
|
| 380 | {
|
| 381 | $topic_id36 = base_convert($topic_id, 10, 36); |
| 382 | $forum_id36 = ($row['topic_type'] == POST_GLOBAL) ? 0 : $forum_id; |
| 383 | $mark_time_topic = (isset($tracking_topics[$forum_id36][$topic_id36])) ? base_convert($tracking_topics[$forum_id36][$topic_id36], 36, 10) + $config['board_startdate'] : 0; |
| 384 | } |
| 385 | |
| 386 | // This will allow the style designer to output a different header
|
| 387 | // or even seperate the list of announcements from sticky and normal
|
| 388 | // topics
|
| 389 | $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; |
| 390 | |
| 391 | // Replies
|
| 392 | $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; |
| 393 | |
| 394 | if ($row['topic_status'] == ITEM_MOVED) |
| 395 | {
|
| 396 | $topic_id = $row['topic_moved_id']; |
| 397 | } |
| 398 | |
| 399 | // Get folder img, topic status/type related informations
|
| 400 | $folder_img = $folder_alt = $topic_type = ''; |
| 401 | $unread_topic = topic_status($row, $replies, $mark_time_topic, $mark_time_forum, $folder_img, $folder_alt, $topic_type); |
| 402 | |
| 403 | $newest_post_img = ($unread_topic) ? "<a href=\"viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&view=unread#unread\">" . $user->img('icon_post_newest', 'VIEW_NEWEST_POST') . '</a> ' : ''; |
| 404 | |
| 405 | // Generate all the URIs ...
|
| 406 | $view_topic_url = "viewtopic.$phpEx$SID&f=" . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id"; |
| 407 | |
| 408 | // Send vars to template
|
| 409 | $template->assign_block_vars('topicrow', array( |
| 410 | 'FORUM_ID' => $forum_id, |
| 411 | 'TOPIC_ID' => $topic_id, |
| 412 | 'TOPIC_AUTHOR' => topic_topic_author($row), |
| 413 | 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), |
| 414 | 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), |
| 415 | 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), |
| 416 | 'LAST_POST_AUTHOR' => ($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] : $user->lang['GUEST'], |
| 417 | 'PAGINATION' => topic_generate_pagination($replies, "viewtopic.$phpEx$SID&f=" . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id"), |
| 418 | 'REPLIES' => $replies, |
| 419 | 'VIEWS' => $row['topic_views'], |
| 420 | 'TOPIC_TITLE' => censor_text($row['topic_title']), |
| 421 | 'TOPIC_TYPE' => $topic_type, |
| 422 | |
| 423 | 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), |
| 424 | 'NEWEST_POST_IMG' => $newest_post_img, |
| 425 | 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), |
| 426 | 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), |
| 427 | 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', |
| 428 | 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', |
| 429 | 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', |
| 430 | 'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', |
| 431 | |
| 432 | 'S_TOPIC_TYPE' => $row['topic_type'], |
| 433 | 'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false, |
| 434 | 'S_UNREAD_TOPIC' => $unread_topic, |
| 435 | |
| 436 | 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false, |
| 437 | 'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false, |
| 438 | |
| 439 | 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'], |
| 440 | 'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '', |
| 441 | 'U_VIEW_TOPIC' => $view_topic_url, |
| 442 | 'U_MCP_REPORT' => "mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id", |
| 443 | 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id", |
| 444 | |
| 445 | 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test) |
| 446 | ); |
| 447 | |
| 448 | $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; |
| 449 | |
| 450 | if ($mark_time_topic < $row['topic_last_post_time'] && $mark_time_forum < $row['topic_last_post_time']) |
| 451 | {
|
| 452 | $mark_forum_read = false; |
| 453 | } |
| 454 | |
| 455 | unset($rowset[$topic_id]); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | // This is rather a fudge but it's the best I can think of without requiring information
|
| 460 | // on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find
|
| 461 | // any it updates the forum last read cookie. This requires that the user visit the forum
|
| 462 | // after reading a topic
|
| 463 | if ($forum_data['forum_type'] == FORUM_POST && $user->data['is_registered'] && sizeof($topic_list) && $mark_forum_read) |
| 464 | {
|
| 465 | markread('mark', $forum_id); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | |
| 470 | // Dump out the page header and load viewforum template
|
| 471 | page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']); |
| 472 | |
| 473 | $template->set_filenames(array( |
| 474 | 'body' => 'viewforum_body.html') |
| 475 | ); |
| 476 | make_jumpbox("viewforum.$phpEx$SID", $forum_id); |
| 477 | |
| 478 | page_footer(); |
| 479 | |
| 480 | ?> |

