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

