phpBB
Statistics
| Revision:

root / branches / phpBB-3_0_0 / phpBB / viewforum.php

History | View | Annotate | Download (28.8 kB)

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