[ Index ] |
PHP Cross Reference of phpBB-3.3.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 define('IN_PHPBB', true); 18 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; 19 $phpEx = substr(strrchr(__FILE__, '.'), 1); 20 include($phpbb_root_path . 'common.' . $phpEx); 21 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 22 23 // Start session 24 $user->session_begin(); 25 $auth->acl($user->data); 26 27 // Start initial var setup 28 $forum_id = $request->variable('f', 0); 29 $mark_read = $request->variable('mark', ''); 30 $start = $request->variable('start', 0); 31 32 $default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; 33 $default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; 34 $default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; 35 36 $sort_days = $request->variable('st', $default_sort_days); 37 $sort_key = $request->variable('sk', $default_sort_key); 38 $sort_dir = $request->variable('sd', $default_sort_dir); 39 40 /* @var $pagination \phpbb\pagination */ 41 $pagination = $phpbb_container->get('pagination'); 42 43 // Check if the user has actually sent a forum ID with his/her request 44 // If not give them a nice error page. 45 if (!$forum_id) 46 { 47 trigger_error('NO_FORUM'); 48 } 49 50 $sql_from = FORUMS_TABLE . ' f'; 51 $lastread_select = ''; 52 53 // Grab appropriate forum data 54 if ($config['load_db_lastread'] && $user->data['is_registered']) 55 { 56 $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' 57 AND ft.forum_id = f.forum_id)'; 58 $lastread_select .= ', ft.mark_time'; 59 } 60 61 if ($user->data['is_registered']) 62 { 63 $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')'; 64 $lastread_select .= ', fw.notify_status'; 65 } 66 67 $sql = "SELECT f.* $lastread_select 68 FROM $sql_from 69 WHERE f.forum_id = $forum_id"; 70 $result = $db->sql_query($sql); 71 $forum_data = $db->sql_fetchrow($result); 72 $db->sql_freeresult($result); 73 74 if (!$forum_data) 75 { 76 trigger_error('NO_FORUM'); 77 } 78 79 80 // Configure style, language, etc. 81 $user->setup('viewforum', $forum_data['forum_style']); 82 83 // Redirect to login upon emailed notification links 84 if (isset($_GET['e']) && !$user->data['is_registered']) 85 { 86 login_box('', $user->lang['LOGIN_NOTIFY_FORUM']); 87 } 88 89 // Permissions check 90 if (!$auth->acl_gets('f_list', 'f_list_topics', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id))) 91 { 92 if ($user->data['user_id'] != ANONYMOUS) 93 { 94 send_status_line(403, 'Forbidden'); 95 trigger_error('SORRY_AUTH_READ'); 96 } 97 98 login_box('', $user->lang['LOGIN_VIEWFORUM']); 99 } 100 101 // Forum is passworded ... check whether access has been granted to this 102 // user this session, if not show login box 103 if ($forum_data['forum_password']) 104 { 105 login_forum_box($forum_data); 106 } 107 108 // Is this forum a link? ... User got here either because the 109 // number of clicks is being tracked or they guessed the id 110 if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link']) 111 { 112 // Does it have click tracking enabled? 113 if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) 114 { 115 $sql = 'UPDATE ' . FORUMS_TABLE . ' 116 SET forum_posts_approved = forum_posts_approved + 1 117 WHERE forum_id = ' . $forum_id; 118 $db->sql_query($sql); 119 } 120 121 // We redirect to the url. The third parameter indicates that external redirects are allowed. 122 redirect($forum_data['forum_link'], false, true); 123 return; 124 } 125 126 // Build navigation links 127 generate_forum_nav($forum_data); 128 129 // Forum Rules 130 if ($auth->acl_get('f_read', $forum_id)) 131 { 132 generate_forum_rules($forum_data); 133 } 134 135 // Do we have subforums? 136 $active_forum_ary = $moderators = array(); 137 138 if ($forum_data['left_id'] != $forum_data['right_id'] - 1) 139 { 140 list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']); 141 } 142 else 143 { 144 $template->assign_var('S_HAS_SUBFORUM', false); 145 if ($config['load_moderators']) 146 { 147 get_moderators($moderators, $forum_id); 148 } 149 } 150 151 // Is a forum specific topic count required? 152 if ($forum_data['forum_topics_per_page']) 153 { 154 $config['topics_per_page'] = $forum_data['forum_topics_per_page']; 155 } 156 157 /* @var $phpbb_content_visibility \phpbb\content_visibility */ 158 $phpbb_content_visibility = $phpbb_container->get('content.visibility'); 159 160 // Dump out the page header and load viewforum template 161 $topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id); 162 $start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); 163 164 $page_title = $forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''); 165 166 /** 167 * You can use this event to modify the page title of the viewforum page 168 * 169 * @event core.viewforum_modify_page_title 170 * @var string page_title Title of the viewforum page 171 * @var array forum_data Array with forum data 172 * @var int forum_id The forum ID 173 * @var int start Start offset used to calculate the page 174 * @since 3.2.2-RC1 175 */ 176 $vars = array('page_title', 'forum_data', 'forum_id', 'start'); 177 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_page_title', compact($vars))); 178 179 page_header($page_title, true, $forum_id); 180 181 $template->set_filenames(array( 182 'body' => 'viewforum_body.html') 183 ); 184 185 make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); 186 187 $template->assign_vars(array( 188 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), 189 )); 190 191 // Not postable forum or showing active topics? 192 if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT))) 193 { 194 page_footer(); 195 } 196 197 // Ok, if someone has only list-access, we only display the forum list. 198 // We also make this circumstance available to the template in case we want to display a notice. ;) 199 if (!$auth->acl_gets('f_read', 'f_list_topics', $forum_id)) 200 { 201 $template->assign_vars(array( 202 'S_NO_READ_ACCESS' => true, 203 )); 204 205 page_footer(); 206 } 207 208 // Handle marking posts 209 if ($mark_read == 'topics') 210 { 211 $token = $request->variable('hash', ''); 212 if (check_link_hash($token, 'global')) 213 { 214 markread('topics', array($forum_id), false, $request->variable('mark_time', 0)); 215 } 216 $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); 217 meta_refresh(3, $redirect_url); 218 219 if ($request->is_ajax()) 220 { 221 // Tell the ajax script what language vars and URL need to be replaced 222 $data = array( 223 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 224 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 225 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time(), false) : '', 226 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 227 'MESSAGE_TEXT' => $user->lang['TOPICS_MARKED'] 228 ); 229 $json_response = new \phpbb\json_response(); 230 $json_response->send($data); 231 } 232 233 trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>')); 234 } 235 236 // Do the forum Prune thang - cron type job ... 237 if (!$config['use_system_cron']) 238 { 239 /* @var $cron \phpbb\cron\manager */ 240 $cron = $phpbb_container->get('cron.manager'); 241 242 $task = $cron->find_task('cron.task.core.prune_forum'); 243 $task->set_forum_data($forum_data); 244 245 if ($task->is_ready()) 246 { 247 $cron_task_tag = $task->get_html_tag(); 248 $template->assign_var('RUN_CRON_TASK', $cron_task_tag); 249 } 250 else 251 { 252 // See if we should prune the shadow topics instead 253 $task = $cron->find_task('cron.task.core.prune_shadow_topics'); 254 $task->set_forum_data($forum_data); 255 256 if ($task->is_ready()) 257 { 258 $cron_task_tag = $task->get_html_tag(); 259 $template->assign_var('RUN_CRON_TASK', $cron_task_tag); 260 } 261 } 262 } 263 264 // Forum rules and subscription info 265 $s_watching_forum = array( 266 'link' => '', 267 'link_toggle' => '', 268 'title' => '', 269 'title_toggle' => '', 270 'is_watching' => false, 271 ); 272 273 if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) 274 { 275 $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; 276 watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']); 277 } 278 279 $s_forum_rules = ''; 280 gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']); 281 282 // Topic ordering options 283 $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'], 365 => $user->lang['1_YEAR']); 284 285 $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']); 286 $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views'); 287 288 /** 289 * Modify the topic ordering if needed 290 * 291 * @event core.viewforum_modify_topic_ordering 292 * @var array sort_by_text Topic ordering options 293 * @var array sort_by_sql Topic orderings options SQL equivalent 294 * @since 3.2.5-RC1 295 */ 296 $vars = array( 297 'sort_by_text', 298 'sort_by_sql', 299 ); 300 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_ordering', compact($vars))); 301 302 $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; 303 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); 304 305 // Limit topics to certain time frame, obtain correct topic count 306 if ($sort_days) 307 { 308 $min_post_time = time() - ($sort_days * 86400); 309 310 $sql_array = array( 311 'SELECT' => 'COUNT(t.topic_id) AS num_topics', 312 'FROM' => array( 313 TOPICS_TABLE => 't', 314 ), 315 'WHERE' => 't.forum_id = ' . $forum_id . ' 316 AND (t.topic_last_post_time >= ' . $min_post_time . ' 317 OR t.topic_type = ' . POST_ANNOUNCE . ' 318 OR t.topic_type = ' . POST_GLOBAL . ') 319 AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'), 320 ); 321 322 /** 323 * Modify the sort data SQL query for getting additional fields if needed 324 * 325 * @event core.viewforum_modify_sort_data_sql 326 * @var int forum_id The forum_id whose topics are being listed 327 * @var int start Variable containing start for pagination 328 * @var int sort_days The oldest topic displayable in elapsed days 329 * @var string sort_key The sorting by. It is one of the first character of (in low case): 330 * Author, Post time, Replies, Subject, Views 331 * @var string sort_dir Either "a" for ascending or "d" for descending 332 * @var array sql_array The SQL array to get the data of all topics 333 * @since 3.1.9-RC1 334 */ 335 $vars = array( 336 'forum_id', 337 'start', 338 'sort_days', 339 'sort_key', 340 'sort_dir', 341 'sql_array', 342 ); 343 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_data_sql', compact($vars))); 344 345 $result = $db->sql_query($db->sql_build_query('SELECT', $sql_array)); 346 $topics_count = (int) $db->sql_fetchfield('num_topics'); 347 $db->sql_freeresult($result); 348 349 if (isset($_POST['sort'])) 350 { 351 $start = 0; 352 } 353 $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time"; 354 355 // Make sure we have information about day selection ready 356 $template->assign_var('S_SORT_DAYS', true); 357 } 358 else 359 { 360 $sql_limit_time = ''; 361 } 362 363 // Basic pagewide vars 364 $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; 365 366 // Display active topics? 367 $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; 368 369 $s_search_hidden_fields = array('fid' => array($forum_id)); 370 if ($_SID) 371 { 372 $s_search_hidden_fields['sid'] = $_SID; 373 } 374 375 if (!empty($_EXTRA_URL)) 376 { 377 foreach ($_EXTRA_URL as $url_param) 378 { 379 $url_param = explode('=', $url_param, 2); 380 $s_search_hidden_fields[$url_param[0]] = $url_param[1]; 381 } 382 } 383 384 $template->assign_vars(array( 385 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', 386 387 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), 388 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 389 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 390 'FOLDER_IMG' => $user->img('topic_read', 'NO_UNREAD_POSTS'), 391 'FOLDER_UNREAD_IMG' => $user->img('topic_unread', 'UNREAD_POSTS'), 392 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'), 393 'FOLDER_HOT_UNREAD_IMG' => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'), 394 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'), 395 'FOLDER_LOCKED_UNREAD_IMG' => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'), 396 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), 397 'FOLDER_STICKY_UNREAD_IMG' => $user->img('sticky_unread', 'POST_STICKY'), 398 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), 399 'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'), 400 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), 401 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 402 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 403 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), 404 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), 405 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), 406 407 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], 408 409 'S_DISPLAY_POST_INFO' => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, 410 411 'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, 412 'S_USER_CAN_POST' => ($auth->acl_get('f_post', $forum_id)) ? true : false, 413 'S_DISPLAY_ACTIVE' => $s_display_active, 414 'S_SELECT_SORT_DIR' => $s_sort_dir, 415 'S_SELECT_SORT_KEY' => $s_sort_key, 416 'S_SELECT_SORT_DAYS' => $s_limit_days, 417 'S_TOPIC_ICONS' => ($s_display_active && count($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), 418 'U_WATCH_FORUM_LINK' => $s_watching_forum['link'], 419 'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'], 420 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], 421 'S_WATCH_FORUM_TOGGLE' => $s_watching_forum['title_toggle'], 422 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], 423 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), 424 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, 425 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"), 426 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 427 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && count($moderators[$forum_id]) > 1) ? false : true, 428 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, 429 'S_VIEWFORUM' => true, 430 431 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', 432 '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) : '', 433 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start == 0) ? '' : "&start=$start")), 434 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.$phpEx", "f=$forum_id" . (($start) ? "&start=$start" : ''), true, ''), 435 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', 436 'U_SEARCH_FORUM' => append_sid("{$phpbb_root_path}search.$phpEx", 'fid%5B%5D=' . $forum_id), 437 )); 438 439 // Grab icons 440 $icons = $cache->obtain_icons(); 441 442 // Grab all topic data 443 $rowset = $announcement_list = $topic_list = $global_announce_forums = array(); 444 445 $sql_array = array( 446 'SELECT' => 't.*', 447 'FROM' => array( 448 TOPICS_TABLE => 't' 449 ), 450 'LEFT_JOIN' => array(), 451 ); 452 453 /** 454 * Event to modify the SQL query before the topic data is retrieved 455 * 456 * It may also be used to override the above assigned template vars 457 * 458 * @event core.viewforum_get_topic_data 459 * @var array forum_data Array with forum data 460 * @var array sql_array The SQL array to get the data of all topics 461 * @var int forum_id The forum_id whose topics are being listed 462 * @var int topics_count The total number of topics for display 463 * @var int sort_days The oldest topic displayable in elapsed days 464 * @var string sort_key The sorting by. It is one of the first character of (in low case): 465 * Author, Post time, Replies, Subject, Views 466 * @var string sort_dir Either "a" for ascending or "d" for descending 467 * @since 3.1.0-a1 468 * @changed 3.1.0-RC4 Added forum_data var 469 * @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars 470 * @changed 3.1.9-RC1 Fix types of properties 471 */ 472 $vars = array( 473 'forum_data', 474 'sql_array', 475 'forum_id', 476 'topics_count', 477 'sort_days', 478 'sort_key', 479 'sort_dir', 480 ); 481 extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); 482 483 $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); 484 485 if ($user->data['is_registered']) 486 { 487 if ($config['load_db_track']) 488 { 489 $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); 490 $sql_array['SELECT'] .= ', tp.topic_posted'; 491 } 492 493 if ($config['load_db_lastread']) 494 { 495 $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); 496 $sql_array['SELECT'] .= ', tt.mark_time'; 497 498 if ($s_display_active && count($active_forum_ary)) 499 { 500 $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); 501 $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time'; 502 } 503 } 504 } 505 506 if ($forum_data['forum_type'] == FORUM_POST) 507 { 508 // Get global announcement forums 509 $g_forum_ary = $auth->acl_getf('f_read', true); 510 $g_forum_ary = array_unique(array_keys($g_forum_ary)); 511 512 $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN']; 513 $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'); 514 $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name'; 515 516 // Obtain announcements ... removed sort ordering, sort by time in all cases 517 $sql_ary = array( 518 'SELECT' => $sql_anounce_array['SELECT'], 519 'FROM' => $sql_array['FROM'], 520 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'], 521 522 'WHERE' => '(t.forum_id = ' . $forum_id . ' 523 AND t.topic_type = ' . POST_ANNOUNCE . ') OR 524 (' . $db->sql_in_set('t.forum_id', $g_forum_ary, false, true) . ' 525 AND t.topic_type = ' . POST_GLOBAL . ')', 526 527 'ORDER_BY' => 't.topic_time DESC', 528 ); 529 530 /** 531 * Event to modify the SQL query before the announcement topic ids data is retrieved 532 * 533 * @event core.viewforum_get_announcement_topic_ids_data 534 * @var array forum_data Data about the forum 535 * @var array g_forum_ary Global announcement forums array 536 * @var array sql_anounce_array SQL announcement array 537 * @var array sql_ary SQL query array to get the announcement topic ids data 538 * @var int forum_id The forum ID 539 * 540 * @since 3.1.10-RC1 541 */ 542 $vars = array( 543 'forum_data', 544 'g_forum_ary', 545 'sql_anounce_array', 546 'sql_ary', 547 'forum_id', 548 ); 549 extract($phpbb_dispatcher->trigger_event('core.viewforum_get_announcement_topic_ids_data', compact($vars))); 550 551 $sql = $db->sql_build_query('SELECT', $sql_ary); 552 $result = $db->sql_query($sql); 553 554 while ($row = $db->sql_fetchrow($result)) 555 { 556 if (!$phpbb_content_visibility->is_visible('topic', $row['forum_id'], $row)) 557 { 558 // Do not display announcements that are waiting for approval or soft deleted. 559 continue; 560 } 561 562 $rowset[$row['topic_id']] = $row; 563 $announcement_list[] = $row['topic_id']; 564 565 if ($forum_id != $row['forum_id']) 566 { 567 $topics_count++; 568 $global_announce_forums[] = $row['forum_id']; 569 } 570 } 571 $db->sql_freeresult($result); 572 } 573 574 $forum_tracking_info = array(); 575 576 if ($user->data['is_registered'] && $config['load_db_lastread']) 577 { 578 $forum_tracking_info[$forum_id] = $forum_data['mark_time']; 579 580 if (!empty($global_announce_forums)) 581 { 582 $sql = 'SELECT forum_id, mark_time 583 FROM ' . FORUMS_TRACK_TABLE . ' 584 WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . ' 585 AND user_id = ' . $user->data['user_id']; 586 $result = $db->sql_query($sql); 587 588 while ($row = $db->sql_fetchrow($result)) 589 { 590 $forum_tracking_info[$row['forum_id']] = $row['mark_time']; 591 } 592 $db->sql_freeresult($result); 593 } 594 } 595 596 // If the user is trying to reach late pages, start searching from the end 597 $store_reverse = false; 598 $sql_limit = $config['topics_per_page']; 599 if ($start > $topics_count / 2) 600 { 601 $store_reverse = true; 602 603 // Select the sort order 604 $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); 605 606 $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count - count($announcement_list)); 607 $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count - count($announcement_list)); 608 } 609 else 610 { 611 // Select the sort order 612 $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); 613 $sql_start = $start; 614 } 615 616 /** 617 * Modify the topics sort ordering if needed 618 * 619 * @event core.viewforum_modify_sort_direction 620 * @var string direction Topics sort order 621 * @since 3.2.5-RC1 622 */ 623 $vars = array( 624 'direction', 625 ); 626 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_sort_direction', compact($vars))); 627 628 if (is_array($sort_by_sql[$sort_key])) 629 { 630 $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; 631 } 632 else 633 { 634 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; 635 } 636 637 if ($forum_data['forum_type'] == FORUM_POST || !count($active_forum_ary)) 638 { 639 $sql_where = 't.forum_id = ' . $forum_id; 640 } 641 else if (empty($active_forum_ary['exclude_forum_id'])) 642 { 643 $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']); 644 } 645 else 646 { 647 $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); 648 $sql_where = (count($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; 649 } 650 651 // Grab just the sorted topic ids 652 $sql_ary = array( 653 'SELECT' => 't.topic_id', 654 'FROM' => array( 655 TOPICS_TABLE => 't', 656 ), 657 'WHERE' => "$sql_where 658 AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ") 659 $sql_approved 660 $sql_limit_time", 661 'ORDER_BY' => 't.topic_type ' . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order, 662 ); 663 664 /** 665 * Event to modify the SQL query before the topic ids data is retrieved 666 * 667 * @event core.viewforum_get_topic_ids_data 668 * @var array forum_data Data about the forum 669 * @var array sql_ary SQL query array to get the topic ids data 670 * @var string sql_approved Topic visibility SQL string 671 * @var int sql_limit Number of records to select 672 * @var string sql_limit_time SQL string to limit topic_last_post_time data 673 * @var array sql_sort_order SQL sorting string 674 * @var int sql_start Offset point to start selection from 675 * @var string sql_where SQL WHERE clause string 676 * @var bool store_reverse Flag indicating if we select from the late pages 677 * 678 * @since 3.1.0-RC4 679 * 680 * @changed 3.1.3 Added forum_data 681 */ 682 $vars = array( 683 'forum_data', 684 'sql_ary', 685 'sql_approved', 686 'sql_limit', 687 'sql_limit_time', 688 'sql_sort_order', 689 'sql_start', 690 'sql_where', 691 'store_reverse', 692 ); 693 extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_ids_data', compact($vars))); 694 695 $sql = $db->sql_build_query('SELECT', $sql_ary); 696 $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); 697 698 while ($row = $db->sql_fetchrow($result)) 699 { 700 $topic_list[] = (int) $row['topic_id']; 701 } 702 $db->sql_freeresult($result); 703 704 // For storing shadow topics 705 $shadow_topic_list = array(); 706 707 if (count($topic_list)) 708 { 709 // SQL array for obtaining topics/stickies 710 $sql_array = array( 711 'SELECT' => $sql_array['SELECT'], 712 'FROM' => $sql_array['FROM'], 713 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 714 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), 715 ); 716 717 /** 718 * Event to modify the SQL query before obtaining topics/stickies 719 * 720 * @event core.viewforum_modify_topic_list_sql 721 * @var int forum_id The forum ID 722 * @var array forum_data Data about the forum 723 * @var array topic_list Topic ids array 724 * @var array sql_array SQL query array for obtaining topics/stickies 725 * 726 * @since 3.2.10-RC1 727 * @since 3.3.1-RC1 728 */ 729 $vars = [ 730 'forum_id', 731 'forum_data', 732 'topic_list', 733 'sql_array', 734 ]; 735 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topic_list_sql', compact($vars))); 736 737 // If store_reverse, then first obtain topics, then stickies, else the other way around... 738 // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because 739 // the number of stickies are not known 740 $sql = $db->sql_build_query('SELECT', $sql_array); 741 $result = $db->sql_query($sql); 742 743 while ($row = $db->sql_fetchrow($result)) 744 { 745 if ($row['topic_status'] == ITEM_MOVED) 746 { 747 $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; 748 } 749 750 $rowset[$row['topic_id']] = $row; 751 } 752 $db->sql_freeresult($result); 753 } 754 755 // If we have some shadow topics, update the rowset to reflect their topic information 756 if (count($shadow_topic_list)) 757 { 758 // SQL array for obtaining shadow topics 759 $sql_array = array( 760 'SELECT' => 't.*', 761 'FROM' => array( 762 TOPICS_TABLE => 't' 763 ), 764 'WHERE' => $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)), 765 ); 766 767 /** 768 * Event to modify the SQL query before the shadowtopic data is retrieved 769 * 770 * @event core.viewforum_get_shadowtopic_data 771 * @var array sql_array SQL array to get the data of any shadowtopics 772 * @since 3.1.0-a1 773 */ 774 $vars = array('sql_array'); 775 extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); 776 777 $sql = $db->sql_build_query('SELECT', $sql_array); 778 $result = $db->sql_query($sql); 779 780 while ($row = $db->sql_fetchrow($result)) 781 { 782 $orig_topic_id = $shadow_topic_list[$row['topic_id']]; 783 784 // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it... 785 if (isset($rowset[$row['topic_id']])) 786 { 787 // We need to remove any trace regarding this topic. :) 788 unset($rowset[$orig_topic_id]); 789 unset($topic_list[array_search($orig_topic_id, $topic_list)]); 790 $topics_count--; 791 792 continue; 793 } 794 795 // Do not include those topics the user has no permission to access 796 if (!$auth->acl_gets('f_read', 'f_list_topics', $row['forum_id'])) 797 { 798 // We need to remove any trace regarding this topic. :) 799 unset($rowset[$orig_topic_id]); 800 unset($topic_list[array_search($orig_topic_id, $topic_list)]); 801 $topics_count--; 802 803 continue; 804 } 805 806 // We want to retain some values 807 $row = array_merge($row, array( 808 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], 809 'topic_status' => $rowset[$orig_topic_id]['topic_status'], 810 'topic_type' => $rowset[$orig_topic_id]['topic_type'], 811 'topic_title' => $rowset[$orig_topic_id]['topic_title'], 812 )); 813 814 // Shadow topics are never reported 815 $row['topic_reported'] = 0; 816 817 $rowset[$orig_topic_id] = $row; 818 } 819 $db->sql_freeresult($result); 820 } 821 unset($shadow_topic_list); 822 823 // Ok, adjust topics count for active topics list 824 if ($s_display_active) 825 { 826 $topics_count = 1; 827 } 828 829 // We need to remove the global announcements from the forums total topic count, 830 // otherwise the number is different from the one on the forum list 831 $total_topic_count = $topics_count - count($announcement_list); 832 833 $base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')); 834 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_topic_count, $config['topics_per_page'], $start); 835 836 $template->assign_vars(array( 837 'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count), 838 )); 839 840 $topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list); 841 $topic_tracking_info = $tracking_topics = array(); 842 843 /** 844 * Modify topics data before we display the viewforum page 845 * 846 * @event core.viewforum_modify_topics_data 847 * @var array topic_list Array with current viewforum page topic ids 848 * @var array rowset Array with topics data (in topic_id => topic_data format) 849 * @var int total_topic_count Forum's total topic count 850 * @var int forum_id Forum identifier 851 * @since 3.1.0-b3 852 * @changed 3.1.11-RC1 Added forum_id 853 */ 854 $vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id'); 855 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars))); 856 857 // Okay, lets dump out the page ... 858 if (count($topic_list)) 859 { 860 $mark_forum_read = true; 861 $mark_time_forum = 0; 862 863 // Generate topic forum list... 864 $topic_forum_list = array(); 865 foreach ($rowset as $t_id => $row) 866 { 867 if (isset($forum_tracking_info[$row['forum_id']])) 868 { 869 $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; 870 } 871 872 $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; 873 $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; 874 } 875 876 if ($config['load_db_lastread'] && $user->data['is_registered']) 877 { 878 foreach ($topic_forum_list as $f_id => $topic_row) 879 { 880 $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); 881 } 882 } 883 else if ($config['load_anon_lastread'] || $user->data['is_registered']) 884 { 885 foreach ($topic_forum_list as $f_id => $topic_row) 886 { 887 $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); 888 } 889 } 890 891 unset($topic_forum_list); 892 893 if (!$s_display_active) 894 { 895 if ($config['load_db_lastread'] && $user->data['is_registered']) 896 { 897 $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; 898 } 899 else if ($config['load_anon_lastread'] || $user->data['is_registered']) 900 { 901 if (!$user->data['is_registered']) 902 { 903 $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; 904 } 905 $mark_time_forum = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; 906 } 907 } 908 909 $s_type_switch = 0; 910 foreach ($topic_list as $topic_id) 911 { 912 $row = &$rowset[$topic_id]; 913 914 $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id; 915 916 // This will allow the style designer to output a different header 917 // or even separate the list of announcements from sticky and normal topics 918 $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; 919 920 // Replies 921 $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1; 922 // Correction for case of unapproved topic visible to poster 923 if ($replies < 0) 924 { 925 $replies = 0; 926 } 927 928 if ($row['topic_status'] == ITEM_MOVED) 929 { 930 $topic_id = $row['topic_moved_id']; 931 $unread_topic = false; 932 } 933 else 934 { 935 $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; 936 } 937 938 // Get folder img, topic status/type related information 939 $folder_img = $folder_alt = $topic_type = ''; 940 topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); 941 942 // Generate all the URIs ... 943 $view_topic_url_params = 't=' . $topic_id; 944 $view_topic_url = $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params) : false; 945 946 $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])); 947 $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])); 948 $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; 949 950 $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; 951 $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=deleted_topics&t=' . $topic_id, true, $user->session_id) : $u_mcp_queue; 952 953 // Send vars to template 954 $topic_row = array( 955 'FORUM_ID' => $row['forum_id'], 956 'TOPIC_ID' => $topic_id, 957 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 958 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 959 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 960 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 961 'FIRST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_time']), 962 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), 963 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 964 'LAST_POST_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_post_time']), 965 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 966 'LAST_VIEW_TIME_RFC3339' => gmdate(DATE_RFC3339, $row['topic_last_view_time']), 967 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 968 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 969 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 970 971 'REPLIES' => $replies, 972 'VIEWS' => $row['topic_views'], 973 'TOPIC_TITLE' => censor_text($row['topic_title']), 974 'TOPIC_TYPE' => $topic_type, 975 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'], 976 977 'TOPIC_IMG_STYLE' => $folder_img, 978 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 979 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 980 981 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 982 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 983 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 984 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 985 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 986 987 'S_TOPIC_TYPE' => $row['topic_type'], 988 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, 989 'S_UNREAD_TOPIC' => $unread_topic, 990 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 991 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 992 'S_POSTS_UNAPPROVED' => $posts_unapproved, 993 'S_TOPIC_DELETED' => $topic_deleted, 994 'S_HAS_POLL' => ($row['poll_start']) ? true : false, 995 'S_POST_ANNOUNCE' => ($row['topic_type'] == POST_ANNOUNCE) ? true : false, 996 'S_POST_GLOBAL' => ($row['topic_type'] == POST_GLOBAL) ? true : false, 997 'S_POST_STICKY' => ($row['topic_type'] == POST_STICKY) ? true : false, 998 'S_TOPIC_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false, 999 'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false, 1000 1001 'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false, 1002 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false, 1003 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 1004 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 1005 'U_VIEW_TOPIC' => $view_topic_url, 1006 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 1007 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $topic_id, true, $user->session_id), 1008 'U_MCP_QUEUE' => $u_mcp_queue, 1009 1010 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, 1011 ); 1012 1013 /** 1014 * Modify the topic data before it is assigned to the template 1015 * 1016 * @event core.viewforum_modify_topicrow 1017 * @var array row Array with topic data 1018 * @var array topic_row Template array with topic data 1019 * @var bool s_type_switch Flag indicating if the topic type is [global] announcement 1020 * @var bool s_type_switch_test Flag indicating if the test topic type is [global] announcement 1021 * @since 3.1.0-a1 1022 * 1023 * @changed 3.1.10-RC1 Added s_type_switch, s_type_switch_test 1024 */ 1025 $vars = array('row', 'topic_row', 's_type_switch', 's_type_switch_test'); 1026 extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars))); 1027 1028 $template->assign_block_vars('topicrow', $topic_row); 1029 1030 $pagination->generate_template_pagination($topic_row['U_VIEW_TOPIC'], 'topicrow.pagination', 'start', (int) $topic_row['REPLIES'] + 1, $config['posts_per_page'], 1, true, true); 1031 1032 $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; 1033 1034 /** 1035 * Event after the topic data has been assigned to the template 1036 * 1037 * @event core.viewforum_topic_row_after 1038 * @var array row Array with the topic data 1039 * @var array rowset Array with topics data (in topic_id => topic_data format) 1040 * @var bool s_type_switch Flag indicating if the topic type is [global] announcement 1041 * @var int topic_id The topic ID 1042 * @var array topic_list Array with current viewforum page topic ids 1043 * @var array topic_row Template array with topic data 1044 * @since 3.1.3-RC1 1045 */ 1046 $vars = array( 1047 'row', 1048 'rowset', 1049 's_type_switch', 1050 'topic_id', 1051 'topic_list', 1052 'topic_row', 1053 ); 1054 extract($phpbb_dispatcher->trigger_event('core.viewforum_topic_row_after', compact($vars))); 1055 1056 if ($unread_topic) 1057 { 1058 $mark_forum_read = false; 1059 } 1060 1061 unset($rowset[$topic_id]); 1062 } 1063 } 1064 1065 /** 1066 * This event is to perform additional actions on viewforum page 1067 * 1068 * @event core.viewforum_generate_page_after 1069 * @var array forum_data Array with the forum data 1070 * @since 3.2.2-RC1 1071 */ 1072 $vars = array('forum_data'); 1073 extract($phpbb_dispatcher->trigger_event('core.viewforum_generate_page_after', compact($vars))); 1074 1075 // This is rather a fudge but it's the best I can think of without requiring information 1076 // on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find 1077 // any it updates the forum last read cookie. This requires that the user visit the forum 1078 // after reading a topic 1079 if ($forum_data['forum_type'] == FORUM_POST && count($topic_list) && $mark_forum_read) 1080 { 1081 update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum); 1082 } 1083 1084 page_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 4 14:26:03 2023 | Cross-referenced by PHPXref 0.7.1 |