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