| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * |
|---|
| 4 | * @package phpBB3 |
|---|
| 5 | * @version $Id: viewforum.php 9459 2009-04-17 15:08:09Z acydburn $ |
|---|
| 6 | * @copyright (c) 2005 phpBB Group |
|---|
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|---|
| 8 | * |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * @ignore |
|---|
| 13 | */ |
|---|
| 14 | define('IN_PHPBB', true); |
|---|
| 15 | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
|---|
| 16 | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
|---|
| 17 | include($phpbb_root_path . 'common.' . $phpEx); |
|---|
| 18 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
|---|
| 19 | // www.phpBB-SEO.com SEO TOOLKIT BEGIN |
|---|
| 20 | if (empty($_REQUEST['f'])) { |
|---|
| 21 | $phpbb_seo->get_forum_id($session_forum_id); |
|---|
| 22 | if ($session_forum_id == 0) { |
|---|
| 23 | header('HTTP/1.1 404 Not Found'); |
|---|
| 24 | } else { |
|---|
| 25 | $_REQUEST['f'] = (int) $session_forum_id; |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | // www.phpBB-SEO.com SEO TOOLKIT END |
|---|
| 29 | |
|---|
| 30 | // Start session |
|---|
| 31 | $user->session_begin(); |
|---|
| 32 | $auth->acl($user->data); |
|---|
| 33 | |
|---|
| 34 | // Start initial var setup |
|---|
| 35 | $forum_id = request_var('f', 0); |
|---|
| 36 | $mark_read = request_var('mark', ''); |
|---|
| 37 | $start = request_var('start', 0); |
|---|
| 38 | |
|---|
| 39 | $default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; |
|---|
| 40 | $default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; |
|---|
| 41 | $default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; |
|---|
| 42 | |
|---|
| 43 | $sort_days = request_var('st', $default_sort_days); |
|---|
| 44 | $sort_key = request_var('sk', $default_sort_key); |
|---|
| 45 | $sort_dir = request_var('sd', $default_sort_dir); |
|---|
| 46 | |
|---|
| 47 | // Check if the user has actually sent a forum ID with his/her request |
|---|
| 48 | // If not give them a nice error page. |
|---|
| 49 | if (!$forum_id) |
|---|
| 50 | { |
|---|
| 51 | trigger_error('NO_FORUM'); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | $sql_from = FORUMS_TABLE . ' f'; |
|---|
| 55 | $lastread_select = ''; |
|---|
| 56 | |
|---|
| 57 | // Grab appropriate forum data |
|---|
| 58 | if ($config['load_db_lastread'] && $user->data['is_registered']) |
|---|
| 59 | { |
|---|
| 60 | $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' |
|---|
| 61 | AND ft.forum_id = f.forum_id)'; |
|---|
| 62 | $lastread_select .= ', ft.mark_time'; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | if ($user->data['is_registered']) |
|---|
| 66 | { |
|---|
| 67 | $sql_from .= ' LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (fw.forum_id = f.forum_id AND fw.user_id = ' . $user->data['user_id'] . ')'; |
|---|
| 68 | $lastread_select .= ', fw.notify_status'; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | $sql = "SELECT f.* $lastread_select |
|---|
| 72 | FROM $sql_from |
|---|
| 73 | WHERE f.forum_id = $forum_id"; |
|---|
| 74 | $result = $db->sql_query($sql); |
|---|
| 75 | $forum_data = $db->sql_fetchrow($result); |
|---|
| 76 | $db->sql_freeresult($result); |
|---|
| 77 | |
|---|
| 78 | if (!$forum_data) |
|---|
| 79 | { |
|---|
| 80 | trigger_error('NO_FORUM'); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | // www.phpBB-SEO.com SEO TOOLKIT BEGIN |
|---|
| 84 | $phpbb_seo->set_url($forum_data['forum_name'], $forum_data['forum_id'], $phpbb_seo->seo_static['forum']); |
|---|
| 85 | // www.phpBB-SEO.com SEO TOOLKIT END |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | // Configure style, language, etc. |
|---|
| 89 | $user->setup('viewforum', $forum_data['forum_style']); |
|---|
| 90 | |
|---|
| 91 | // Redirect to login upon emailed notification links |
|---|
| 92 | if (isset($_GET['e']) && !$user->data['is_registered']) |
|---|
| 93 | { |
|---|
| 94 | login_box('', $user->lang['LOGIN_NOTIFY_FORUM']); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | // Permissions check |
|---|
| 98 | if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id))) |
|---|
| 99 | { |
|---|
| 100 | if ($user->data['user_id'] != ANONYMOUS) |
|---|
| 101 | { |
|---|
| 102 | trigger_error('SORRY_AUTH_READ'); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | login_box('', $user->lang['LOGIN_VIEWFORUM']); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | // Forum is passworded ... check whether access has been granted to this |
|---|
| 109 | // user this session, if not show login box |
|---|
| 110 | if ($forum_data['forum_password']) |
|---|
| 111 | { |
|---|
| 112 | login_forum_box($forum_data); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | // Is this forum a link? ... User got here either because the |
|---|
| 116 | // number of clicks is being tracked or they guessed the id |
|---|
| 117 | if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link']) |
|---|
| 118 | { |
|---|
| 119 | // Does it have click tracking enabled? |
|---|
| 120 | if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) |
|---|
| 121 | { |
|---|
| 122 | $sql = 'UPDATE ' . FORUMS_TABLE . ' |
|---|
| 123 | SET forum_posts = forum_posts + 1 |
|---|
| 124 | WHERE forum_id = ' . $forum_id; |
|---|
| 125 | $db->sql_query($sql); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | // We redirect to the url. The third parameter indicates that external redirects are allowed. |
|---|
| 129 | redirect($forum_data['forum_link'], false, true); |
|---|
| 130 | return; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | // Build navigation links |
|---|
| 134 | generate_forum_nav($forum_data); |
|---|
| 135 | |
|---|
| 136 | // Forum Rules |
|---|
| 137 | if ($auth->acl_get('f_read', $forum_id)) |
|---|
| 138 | { |
|---|
| 139 | generate_forum_rules($forum_data); |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | // Do we have subforums? |
|---|
| 143 | $active_forum_ary = $moderators = array(); |
|---|
| 144 | |
|---|
| 145 | if ($forum_data['left_id'] != $forum_data['right_id'] - 1) |
|---|
| 146 | { |
|---|
| 147 | list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']); |
|---|
| 148 | } |
|---|
| 149 | else |
|---|
| 150 | { |
|---|
| 151 | $template->assign_var('S_HAS_SUBFORUM', false); |
|---|
| 152 | get_moderators($moderators, $forum_id); |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | // Dump out the page header and load viewforum template |
|---|
| 156 | page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']); |
|---|
| 157 | |
|---|
| 158 | $template->set_filenames(array( |
|---|
| 159 | 'body' => 'viewforum_body.html') |
|---|
| 160 | ); |
|---|
| 161 | |
|---|
| 162 | make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); |
|---|
| 163 | |
|---|
| 164 | $template->assign_vars(array( |
|---|
| 165 | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&start=$start"), |
|---|
| 166 | )); |
|---|
| 167 | |
|---|
| 168 | // Not postable forum or showing active topics? |
|---|
| 169 | if (!($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && $forum_data['forum_type'] == FORUM_CAT))) |
|---|
| 170 | { |
|---|
| 171 | page_footer(); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | // Ok, if someone has only list-access, we only display the forum list. |
|---|
| 175 | // We also make this circumstance available to the template in case we want to display a notice. ;) |
|---|
| 176 | if (!$auth->acl_get('f_read', $forum_id)) |
|---|
| 177 | { |
|---|
| 178 | $template->assign_vars(array( |
|---|
| 179 | 'S_NO_READ_ACCESS' => true, |
|---|
| 180 | 'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false, |
|---|
| 181 | 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') . '&redirect=' . urlencode(str_replace('&', '&', build_url())), |
|---|
| 182 | )); |
|---|
| 183 | |
|---|
| 184 | page_footer(); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | // Handle marking posts |
|---|
| 188 | if ($mark_read == 'topics') |
|---|
| 189 | { |
|---|
| 190 | $token = request_var('hash', ''); |
|---|
| 191 | if (check_link_hash($token, 'global')) |
|---|
| 192 | { |
|---|
| 193 | markread('topics', $forum_id); |
|---|
| 194 | } |
|---|
| 195 | $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); |
|---|
| 196 | meta_refresh(3, $redirect_url); |
|---|
| 197 | |
|---|
| 198 | trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>')); |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | // Is a forum specific topic count required? |
|---|
| 202 | if ($forum_data['forum_topics_per_page']) |
|---|
| 203 | { |
|---|
| 204 | $config['topics_per_page'] = $forum_data['forum_topics_per_page']; |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | // Do the forum Prune thang - cron type job ... |
|---|
| 208 | if ($forum_data['prune_next'] < time() && $forum_data['enable_prune']) |
|---|
| 209 | { |
|---|
| 210 | $template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_forum&f=' . $forum_id) . '" alt="cron" width="1" height="1" />'); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | // Forum rules and subscription info |
|---|
| 214 | $s_watching_forum = array( |
|---|
| 215 | 'link' => '', |
|---|
| 216 | 'title' => '', |
|---|
| 217 | 'is_watching' => false, |
|---|
| 218 | ); |
|---|
| 219 | |
|---|
| 220 | if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id)) |
|---|
| 221 | { |
|---|
| 222 | $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; |
|---|
| 223 | watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status); |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | $s_forum_rules = ''; |
|---|
| 227 | gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']); |
|---|
| 228 | |
|---|
| 229 | // Topic ordering options |
|---|
| 230 | $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']); |
|---|
| 231 | |
|---|
| 232 | $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']); |
|---|
| 233 | $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'); |
|---|
| 234 | |
|---|
| 235 | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|---|
| 236 | 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); |
|---|
| 237 | |
|---|
| 238 | // Limit topics to certain time frame, obtain correct topic count |
|---|
| 239 | // global announcements must not be counted, normal announcements have to |
|---|
| 240 | // be counted, as forum_topics(_real) includes them |
|---|
| 241 | if ($sort_days) |
|---|
| 242 | { |
|---|
| 243 | $min_post_time = time() - ($sort_days * 86400); |
|---|
| 244 | |
|---|
| 245 | $sql = 'SELECT COUNT(topic_id) AS num_topics |
|---|
| 246 | FROM ' . TOPICS_TABLE . " |
|---|
| 247 | WHERE forum_id = $forum_id |
|---|
| 248 | AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time) |
|---|
| 249 | OR topic_type = " . POST_ANNOUNCE . ") |
|---|
| 250 | " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); |
|---|
| 251 | $result = $db->sql_query($sql); |
|---|
| 252 | $topics_count = (int) $db->sql_fetchfield('num_topics'); |
|---|
| 253 | $db->sql_freeresult($result); |
|---|
| 254 | |
|---|
| 255 | if (isset($_POST['sort'])) |
|---|
| 256 | { |
|---|
| 257 | $start = 0; |
|---|
| 258 | } |
|---|
| 259 | $sql_limit_time = "AND t.topic_last_post_time >= $min_post_time"; |
|---|
| 260 | |
|---|
| 261 | // Make sure we have information about day selection ready |
|---|
| 262 | $template->assign_var('S_SORT_DAYS', true); |
|---|
| 263 | } |
|---|
| 264 | else |
|---|
| 265 | { |
|---|
| 266 | $topics_count = ($auth->acl_get('m_approve', $forum_id)) ? $forum_data['forum_topics_real'] : $forum_data['forum_topics']; |
|---|
| 267 | $sql_limit_time = ''; |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | // Make sure $start is set to the last page if it exceeds the amount |
|---|
| 271 | if ($start < 0 || $start > $topics_count) |
|---|
| 272 | { |
|---|
| 273 | $start = ($start < 0) ? 0 : floor(($topics_count - 1) / $config['topics_per_page']) * $config['topics_per_page']; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | // Basic pagewide vars |
|---|
| 277 | $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; |
|---|
| 278 | |
|---|
| 279 | // Display active topics? |
|---|
| 280 | $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; |
|---|
| 281 | |
|---|
| 282 | $template->assign_vars(array( |
|---|
| 283 | 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode(', ', $moderators[$forum_id]) : '', |
|---|
| 284 | |
|---|
| 285 | 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), |
|---|
| 286 | 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), |
|---|
| 287 | 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), |
|---|
| 288 | 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), |
|---|
| 289 | 'FOLDER_NEW_IMG' => $user->img('topic_unread', 'NEW_POSTS'), |
|---|
| 290 | 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_NEW_POSTS_HOT'), |
|---|
| 291 | 'FOLDER_HOT_NEW_IMG' => $user->img('topic_unread_hot', 'NEW_POSTS_HOT'), |
|---|
| 292 | 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_NEW_POSTS_LOCKED'), |
|---|
| 293 | 'FOLDER_LOCKED_NEW_IMG' => $user->img('topic_unread_locked', 'NEW_POSTS_LOCKED'), |
|---|
| 294 | 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), |
|---|
| 295 | 'FOLDER_STICKY_NEW_IMG' => $user->img('sticky_unread', 'POST_STICKY'), |
|---|
| 296 | 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), |
|---|
| 297 | 'FOLDER_ANNOUNCE_NEW_IMG' => $user->img('announce_unread', 'POST_ANNOUNCEMENT'), |
|---|
| 298 | 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), |
|---|
| 299 | 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), |
|---|
| 300 | 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), |
|---|
| 301 | 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), |
|---|
| 302 | |
|---|
| 303 | 'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], |
|---|
| 304 | |
|---|
| 305 | 'S_DISPLAY_POST_INFO' => ($forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false, |
|---|
| 306 | |
|---|
| 307 | 'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, |
|---|
| 308 | 'S_USER_CAN_POST' => ($auth->acl_get('f_post', $forum_id)) ? true : false, |
|---|
| 309 | 'S_DISPLAY_ACTIVE' => $s_display_active, |
|---|
| 310 | 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|---|
| 311 | 'S_SELECT_SORT_KEY' => $s_sort_key, |
|---|
| 312 | 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|---|
| 313 | 'S_TOPIC_ICONS' => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), |
|---|
| 314 | 'S_WATCH_FORUM_LINK' => $s_watching_forum['link'], |
|---|
| 315 | 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], |
|---|
| 316 | 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], |
|---|
| 317 | 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&start=$start"), |
|---|
| 318 | 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, |
|---|
| 319 | 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'fid[]=' . $forum_id), |
|---|
| 320 | 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true, |
|---|
| 321 | 'S_IS_LOCKED' => ($forum_data['forum_status'] == ITEM_LOCKED) ? true : false, |
|---|
| 322 | 'S_VIEWFORUM' => true, |
|---|
| 323 | |
|---|
| 324 | '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) : '', |
|---|
| 325 | '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) : '', |
|---|
| 326 | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . "&start=$start"), |
|---|
| 327 | '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") : '', |
|---|
| 328 | )); |
|---|
| 329 | |
|---|
| 330 | // Grab icons |
|---|
| 331 | $icons = $cache->obtain_icons(); |
|---|
| 332 | |
|---|
| 333 | // Grab all topic data |
|---|
| 334 | $rowset = $announcement_list = $topic_list = $global_announce_list = array(); |
|---|
| 335 | |
|---|
| 336 | $sql_array = array( |
|---|
| 337 | 'SELECT' => 't.*', |
|---|
| 338 | 'FROM' => array( |
|---|
| 339 | TOPICS_TABLE => 't' |
|---|
| 340 | ), |
|---|
| 341 | 'LEFT_JOIN' => array(), |
|---|
| 342 | ); |
|---|
| 343 | |
|---|
| 344 | $sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'; |
|---|
| 345 | |
|---|
| 346 | if ($user->data['is_registered']) |
|---|
| 347 | { |
|---|
| 348 | if ($config['load_db_track']) |
|---|
| 349 | { |
|---|
| 350 | $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']); |
|---|
| 351 | $sql_array['SELECT'] .= ', tp.topic_posted'; |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | if ($config['load_db_lastread']) |
|---|
| 355 | { |
|---|
| 356 | $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']); |
|---|
| 357 | $sql_array['SELECT'] .= ', tt.mark_time'; |
|---|
| 358 | |
|---|
| 359 | if ($s_display_active && sizeof($active_forum_ary)) |
|---|
| 360 | { |
|---|
| 361 | $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']); |
|---|
| 362 | $sql_array['SELECT'] .= ', ft.mark_time AS forum_mark_time'; |
|---|
| 363 | } |
|---|
| 364 | } |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | if ($forum_data['forum_type'] == FORUM_POST) |
|---|
| 368 | { |
|---|
| 369 | // Obtain announcements ... removed sort ordering, sort by time in all cases |
|---|
| 370 | $sql = $db->sql_build_query('SELECT', array( |
|---|
| 371 | 'SELECT' => $sql_array['SELECT'], |
|---|
| 372 | 'FROM' => $sql_array['FROM'], |
|---|
| 373 | 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], |
|---|
| 374 | |
|---|
| 375 | 'WHERE' => 't.forum_id IN (' . $forum_id . ', 0) |
|---|
| 376 | AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')', |
|---|
| 377 | |
|---|
| 378 | 'ORDER_BY' => 't.topic_time DESC', |
|---|
| 379 | )); |
|---|
| 380 | $result = $db->sql_query($sql); |
|---|
| 381 | |
|---|
| 382 | while ($row = $db->sql_fetchrow($result)) |
|---|
| 383 | { |
|---|
| 384 | $rowset[$row['topic_id']] = $row; |
|---|
| 385 | $announcement_list[] = $row['topic_id']; |
|---|
| 386 | |
|---|
| 387 | if ($row['topic_type'] == POST_GLOBAL) |
|---|
| 388 | { |
|---|
| 389 | $global_announce_list[$row['topic_id']] = true; |
|---|
| 390 | } |
|---|
| 391 | else |
|---|
| 392 | { |
|---|
| 393 | $topics_count--; |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | $db->sql_freeresult($result); |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | // If the user is trying to reach late pages, start searching from the end |
|---|
| 400 | $store_reverse = false; |
|---|
| 401 | $sql_limit = $config['topics_per_page']; |
|---|
| 402 | if ($start > $topics_count / 2) |
|---|
| 403 | { |
|---|
| 404 | $store_reverse = true; |
|---|
| 405 | |
|---|
| 406 | if ($start + $config['topics_per_page'] > $topics_count) |
|---|
| 407 | { |
|---|
| 408 | $sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start)); |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | // Select the sort order |
|---|
| 412 | $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
|---|
| 413 | $sql_start = max(0, $topics_count - $sql_limit - $start); |
|---|
| 414 | } |
|---|
| 415 | else |
|---|
| 416 | { |
|---|
| 417 | // Select the sort order |
|---|
| 418 | $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|---|
| 419 | $sql_start = $start; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary)) |
|---|
| 423 | { |
|---|
| 424 | $sql_where = 't.forum_id = ' . $forum_id; |
|---|
| 425 | } |
|---|
| 426 | else if (empty($active_forum_ary['exclude_forum_id'])) |
|---|
| 427 | { |
|---|
| 428 | $sql_where = $db->sql_in_set('t.forum_id', $active_forum_ary['forum_id']); |
|---|
| 429 | } |
|---|
| 430 | else |
|---|
| 431 | { |
|---|
| 432 | $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); |
|---|
| 433 | $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | // Grab just the sorted topic ids |
|---|
| 437 | $sql = 'SELECT t.topic_id |
|---|
| 438 | FROM ' . TOPICS_TABLE . " t |
|---|
| 439 | WHERE $sql_where |
|---|
| 440 | AND t.topic_type IN (" . POST_NORMAL . ', ' . POST_STICKY . ") |
|---|
| 441 | $sql_approved |
|---|
| 442 | $sql_limit_time |
|---|
| 443 | ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; |
|---|
| 444 | $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); |
|---|
| 445 | |
|---|
| 446 | while ($row = $db->sql_fetchrow($result)) |
|---|
| 447 | { |
|---|
| 448 | $topic_list[] = (int) $row['topic_id']; |
|---|
| 449 | } |
|---|
| 450 | $db->sql_freeresult($result); |
|---|
| 451 | |
|---|
| 452 | // For storing shadow topics |
|---|
| 453 | $shadow_topic_list = array(); |
|---|
| 454 | |
|---|
| 455 | if (sizeof($topic_list)) |
|---|
| 456 | { |
|---|
| 457 | // SQL array for obtaining topics/stickies |
|---|
| 458 | $sql_array = array( |
|---|
| 459 | 'SELECT' => $sql_array['SELECT'], |
|---|
| 460 | 'FROM' => $sql_array['FROM'], |
|---|
| 461 | 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], |
|---|
| 462 | |
|---|
| 463 | 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), |
|---|
| 464 | ); |
|---|
| 465 | |
|---|
| 466 | // If store_reverse, then first obtain topics, then stickies, else the other way around... |
|---|
| 467 | // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because |
|---|
| 468 | // the number of stickies are not known |
|---|
| 469 | $sql = $db->sql_build_query('SELECT', $sql_array); |
|---|
| 470 | $result = $db->sql_query($sql); |
|---|
| 471 | |
|---|
| 472 | while ($row = $db->sql_fetchrow($result)) |
|---|
| 473 | { |
|---|
| 474 | if ($row['topic_status'] == ITEM_MOVED) |
|---|
| 475 | { |
|---|
| 476 | $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | $rowset[$row['topic_id']] = $row; |
|---|
| 480 | } |
|---|
| 481 | $db->sql_freeresult($result); |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | // If we have some shadow topics, update the rowset to reflect their topic information |
|---|
| 485 | if (sizeof($shadow_topic_list)) |
|---|
| 486 | { |
|---|
| 487 | $sql = 'SELECT * |
|---|
| 488 | FROM ' . TOPICS_TABLE . ' |
|---|
| 489 | WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); |
|---|
| 490 | $result = $db->sql_query($sql); |
|---|
| 491 | |
|---|
| 492 | while ($row = $db->sql_fetchrow($result)) |
|---|
| 493 | { |
|---|
| 494 | $orig_topic_id = $shadow_topic_list[$row['topic_id']]; |
|---|
| 495 | |
|---|
| 496 | // If the shadow topic is already listed within the rowset (happens for active topics for example), then do not include it... |
|---|
| 497 | if (isset($rowset[$row['topic_id']])) |
|---|
| 498 | { |
|---|
| 499 | // We need to remove any trace regarding this topic. :) |
|---|
| 500 | unset($rowset[$orig_topic_id]); |
|---|
| 501 | unset($topic_list[array_search($orig_topic_id, $topic_list)]); |
|---|
| 502 | $topics_count--; |
|---|
| 503 | |
|---|
| 504 | continue; |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | // Do not include those topics the user has no permission to access |
|---|
| 508 | if (!$auth->acl_get('f_read', $row['forum_id'])) |
|---|
| 509 | { |
|---|
| 510 | // We need to remove any trace regarding this topic. :) |
|---|
| 511 | unset($rowset[$orig_topic_id]); |
|---|
| 512 | unset($topic_list[array_search($orig_topic_id, $topic_list)]); |
|---|
| 513 | $topics_count--; |
|---|
| 514 | |
|---|
| 515 | continue; |
|---|
| 516 | } |
|---|
| 517 | |
|---|
| 518 | // We want to retain some values |
|---|
| 519 | $row = array_merge($row, array( |
|---|
| 520 | 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], |
|---|
| 521 | 'topic_status' => $rowset[$orig_topic_id]['topic_status'], |
|---|
| 522 | 'topic_type' => $rowset[$orig_topic_id]['topic_type'], |
|---|
| 523 | )); |
|---|
| 524 | |
|---|
| 525 | // Shadow topics are never reported |
|---|
| 526 | $row['topic_reported'] = 0; |
|---|
| 527 | |
|---|
| 528 | $rowset[$orig_topic_id] = $row; |
|---|
| 529 | } |
|---|
| 530 | $db->sql_freeresult($result); |
|---|
| 531 | } |
|---|
| 532 | unset($shadow_topic_list); |
|---|
| 533 | |
|---|
| 534 | // Ok, adjust topics count for active topics list |
|---|
| 535 | if ($s_display_active) |
|---|
| 536 | { |
|---|
| 537 | $topics_count = 1; |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | $template->assign_vars(array( |
|---|
| 541 | 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')), $topics_count, $config['topics_per_page'], $start), |
|---|
| 542 | 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), |
|---|
| 543 | 'TOTAL_TOPICS' => ($s_display_active) ? false : (($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))) |
|---|
| 544 | ); |
|---|
| 545 | |
|---|
| 546 | $topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list); |
|---|
| 547 | $topic_tracking_info = $tracking_topics = array(); |
|---|
| 548 | |
|---|
| 549 | // Okay, lets dump out the page ... |
|---|
| 550 | if (sizeof($topic_list)) |
|---|
| 551 | { |
|---|
| 552 | $mark_forum_read = true; |
|---|
| 553 | $mark_time_forum = 0; |
|---|
| 554 | |
|---|
| 555 | // Active topics? |
|---|
| 556 | if ($s_display_active && sizeof($active_forum_ary)) |
|---|
| 557 | { |
|---|
| 558 | // Generate topic forum list... |
|---|
| 559 | $topic_forum_list = array(); |
|---|
| 560 | foreach ($rowset as $t_id => $row) |
|---|
| 561 | { |
|---|
| 562 | $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; |
|---|
| 563 | $topic_forum_list[$row['forum_id']]['topics'][] = $t_id; |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | if ($config['load_db_lastread'] && $user->data['is_registered']) |
|---|
| 567 | { |
|---|
| 568 | foreach ($topic_forum_list as $f_id => $topic_row) |
|---|
| 569 | { |
|---|
| 570 | $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false); |
|---|
| 571 | } |
|---|
| 572 | } |
|---|
| 573 | else if ($config['load_anon_lastread'] || $user->data['is_registered']) |
|---|
| 574 | { |
|---|
| 575 | foreach ($topic_forum_list as $f_id => $topic_row) |
|---|
| 576 | { |
|---|
| 577 | $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false); |
|---|
| 578 | } |
|---|
| 579 | } |
|---|
| 580 | |
|---|
| 581 | unset($topic_forum_list); |
|---|
| 582 | } |
|---|
| 583 | else |
|---|
| 584 | { |
|---|
| 585 | if ($config['load_db_lastread'] && $user->data['is_registered']) |
|---|
| 586 | { |
|---|
| 587 | $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list); |
|---|
| 588 | $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; |
|---|
| 589 | } |
|---|
| 590 | else if ($config['load_anon_lastread'] || $user->data['is_registered']) |
|---|
| 591 | { |
|---|
| 592 | $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list); |
|---|
| 593 | |
|---|
| 594 | if (!$user->data['is_registered']) |
|---|
| 595 | { |
|---|
| 596 | $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; |
|---|
| 597 | } |
|---|
| 598 | $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']; |
|---|
| 599 | } |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | $s_type_switch = 0; |
|---|
| 603 | foreach ($topic_list as $topic_id) |
|---|
| 604 | { |
|---|
| 605 | $row = &$rowset[$topic_id]; |
|---|
| 606 | // www.phpBB-SEO.com SEO TOOLKIT BEGIN |
|---|
| 607 | if (!empty($row['topic_url'])) { |
|---|
| 608 | $phpbb_seo->prepare_iurl($row, 'topic', ''); |
|---|
| 609 | } else { |
|---|
| 610 | if ($phpbb_seo->modrtype > 2) { |
|---|
| 611 | $row['topic_title'] = censor_text($row['topic_title']); |
|---|
| 612 | } |
|---|
| 613 | $cur_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id; |
|---|
| 614 | $parent_forum = $row['topic_type'] == POST_GLOBAL ? $phpbb_seo->seo_static['global_announce'] : (!empty($phpbb_seo->seo_url['forum'][$cur_forum_id]) ? $phpbb_seo->seo_url['forum'][$cur_forum_id] : false); |
|---|
| 615 | if ($parent_forum) { |
|---|
| 616 | $phpbb_seo->prepare_iurl($row, 'topic', $parent_forum); |
|---|
| 617 | } |
|---|
| 618 | } |
|---|
| 619 | // www.phpBB-SEO.com SEO TOOLKIT END |
|---|
| 620 | |
|---|
| 621 | // This will allow the style designer to output a different header |
|---|
| 622 | // or even separate the list of announcements from sticky and normal topics |
|---|
| 623 | $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; |
|---|
| 624 | |
|---|
| 625 | // Replies |
|---|
| 626 | $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; |
|---|
| 627 | |
|---|
| 628 | if ($row['topic_status'] == ITEM_MOVED) |
|---|
| 629 | { |
|---|
| 630 | $topic_id = $row['topic_moved_id']; |
|---|
| 631 | $unread_topic = false; |
|---|
| 632 | } |
|---|
| 633 | else |
|---|
| 634 | { |
|---|
| 635 | $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | // Get folder img, topic status/type related information |
|---|
| 639 | $folder_img = $folder_alt = $topic_type = ''; |
|---|
| 640 | topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); |
|---|
| 641 | |
|---|
| 642 | // Generate all the URIs ... |
|---|
| 643 | $view_topic_url_params = 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id; |
|---|
| 644 | $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); |
|---|
| 645 | |
|---|
| 646 | $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; |
|---|
| 647 | $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; |
|---|
| 648 | $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) : ''; |
|---|
| 649 | |
|---|
| 650 | // Send vars to template |
|---|
| 651 | $template->assign_block_vars('topicrow', array( |
|---|
| 652 | 'FORUM_ID' => $forum_id, |
|---|
| 653 | 'TOPIC_ID' => $topic_id, |
|---|
| 654 | 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), |
|---|
| 655 | 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), |
|---|
| 656 | 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), |
|---|
| 657 | 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), |
|---|
| 658 | 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), |
|---|
| 659 | 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), |
|---|
| 660 | 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), |
|---|
| 661 | 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), |
|---|
| 662 | 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), |
|---|
| 663 | 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), |
|---|
| 664 | |
|---|
| 665 | 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url), |
|---|
| 666 | 'REPLIES' => $replies, |
|---|
| 667 | 'VIEWS' => $row['topic_views'], |
|---|
| 668 | 'TOPIC_TITLE' => censor_text($row['topic_title']), |
|---|
| 669 | 'TOPIC_TYPE' => $topic_type, |
|---|
| 670 | |
|---|
| 671 | 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), |
|---|
| 672 | 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), |
|---|
| 673 | 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], |
|---|
| 674 | 'TOPIC_FOLDER_IMG_WIDTH'=> $user->img($folder_img, '', false, '', 'width'), |
|---|
| 675 | 'TOPIC_FOLDER_IMG_HEIGHT' => $user->img($folder_img, '', false, '', 'height'), |
|---|
| 676 | |
|---|
| 677 | 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', |
|---|
| 678 | 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', |
|---|
| 679 | 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', |
|---|
| 680 | 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', |
|---|
| 681 | 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', |
|---|
| 682 | |
|---|
| 683 | 'S_TOPIC_TYPE' => $row['topic_type'], |
|---|
| 684 | 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, |
|---|
| 685 | 'S_UNREAD_TOPIC' => $unread_topic, |
|---|
| 686 | 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, |
|---|
| 687 | 'S_TOPIC_UNAPPROVED' => $topic_unapproved, |
|---|
| 688 | 'S_POSTS_UNAPPROVED' => $posts_unapproved, |
|---|
| 689 | 'S_HAS_POLL' => ($row['poll_start']) ? true : false, |
|---|
| 690 | 'S_POST_ANNOUNCE' => ($row['topic_type'] == POST_ANNOUNCE) ? true : false, |
|---|
| 691 | 'S_POST_GLOBAL' => ($row['topic_type'] == POST_GLOBAL) ? true : false, |
|---|
| 692 | 'S_POST_STICKY' => ($row['topic_type'] == POST_STICKY) ? true : false, |
|---|
| 693 | 'S_TOPIC_LOCKED' => ($row['topic_status'] == ITEM_LOCKED) ? true : false, |
|---|
| 694 | 'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false, |
|---|
| 695 | |
|---|
| 696 | 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', |
|---|
| 697 | 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], |
|---|
| 698 | 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), |
|---|
| 699 | 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), |
|---|
| 700 | 'U_VIEW_TOPIC' => $view_topic_url, |
|---|
| 701 | 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $forum_id . '&t=' . $topic_id, true, $user->session_id), |
|---|
| 702 | 'U_MCP_QUEUE' => $u_mcp_queue, |
|---|
| 703 | |
|---|
| 704 | 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test) |
|---|
| 705 | ); |
|---|
| 706 | |
|---|
| 707 | $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; |
|---|
| 708 | |
|---|
| 709 | if ($unread_topic) |
|---|
| 710 | { |
|---|
| 711 | $mark_forum_read = false; |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | unset($rowset[$topic_id]); |
|---|
| 715 | } |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | // This is rather a fudge but it's the best I can think of without requiring information |
|---|
| 719 | // on all topics (as we do in 2.0.x). It looks for unread or new topics, if it doesn't find |
|---|
| 720 | // any it updates the forum last read cookie. This requires that the user visit the forum |
|---|
| 721 | // after reading a topic |
|---|
| 722 | if ($forum_data['forum_type'] == FORUM_POST && sizeof($topic_list) && $mark_forum_read) |
|---|
| 723 | { |
|---|
| 724 | update_forum_tracking_info($forum_id, $forum_data['forum_last_post_time'], false, $mark_time_forum); |
|---|
| 725 | } |
|---|
| 726 | |
|---|
| 727 | page_footer(); |
|---|
| 728 | |
|---|
| 729 | ?> |
|---|