cat_collapse_status ? unserialize($usr->cat_collapse_status) : array();
$cat_id = !empty($_GET['cat']) ? (int) $_GET['cat'] : 0;
$frm_id = !empty($_GET['frm_id']) ? (int) $_GET['frm_id'] : 0;
if ($cat_id && !empty($collapse[$cat_id])) {
$collapse[$cat_id] = 0;
}
require $FORUM_SETTINGS_PATH .'idx.inc';
if (!isset($cidxc[$cat_id])) {
$cat_id = 0;
}
$cbuf = $forum_list_table_data = $cat_path = '';
if ($cat_id) {
$cid = $cat_id;
while (($cid = $cidxc[$cid][4]) > 0) {
$cat_path = ' » '.$cidxc[$cid][1].''. $cat_path;
}
$cat_path = '
Home
'.$cat_path.' » '.$cidxc[$cat_id][1].'';
}
/* List of fetched fields & their ids
0 msg.subject,
1 msg.id AS msg_id,
2 msg.post_stamp,
3 users.id AS user_id,
4 users.alias
5 forum.cat_id,
6 forum.forum_icon
7 forum.id
8 forum.last_post_id
9 forum.moderators
10 forum.name
11 forum.descr
12 forum.url_redirect
13 forum.post_count
14 forum.thread_count
15 forum_read.last_view
16 is_moderator
17 read perm
18 is the category using compact view
*/
$c = uq('SELECT
m.subject, m.id, m.post_stamp,
u.id, u.alias,
f.cat_id, f.forum_icon, f.id, f.last_post_id, f.moderators, f.name, f.descr, f.url_redirect, f.post_count, f.thread_count,
'. (_uid ? 'fr.last_view, mo.id, COALESCE(g2.group_cache_opt, g1.group_cache_opt) AS group_cache_opt' : '0,0,g1.group_cache_opt') .',
c.cat_opt
FROM fud30_fc_view v
INNER JOIN fud30_cat c ON c.id=v.c
INNER JOIN fud30_forum f ON f.id=v.f
INNER JOIN fud30_group_cache g1 ON g1.user_id='. (_uid ? 2147483647 : 0) .' AND g1.resource_id=f.id
LEFT JOIN fud30_msg m ON f.last_post_id=m.id
LEFT JOIN fud30_users u ON u.id=m.poster_id '.
(_uid ? ' LEFT JOIN fud30_forum_read fr ON fr.forum_id=f.id AND fr.user_id='. _uid .' LEFT JOIN fud30_mod mo ON mo.user_id='. _uid .' AND mo.forum_id=f.id LEFT JOIN fud30_group_cache g2 ON g2.user_id='. _uid .' AND g2.resource_id=f.id' : '').
' WHERE f.parent = '. $frm_id .
((!$is_a || $cat_id) ? ' AND ' : '') .
($is_a ? '' : (_uid ? ' (mo.id IS NOT NULL OR ('. q_bitand('COALESCE(g2.group_cache_opt, g1.group_cache_opt)', 1) .' > 0))' : ' ('. q_bitand('g1.group_cache_opt', 1) .' > 0)')) .
($cat_id ? ($is_a ? '' : ' AND ') .' v.c IN('. implode(',', ($cf = $cidxc[$cat_id][5])) .') ' : '') .' ORDER BY v.id');
$post_count = $thread_count = $last_msg_id = $cat = 0;
while ($r = db_rowarr($c)) {
/* Increase thread & post count. */
$post_count += $r[13];
$thread_count += $r[14];
$cid = (int) $r[5];
if ($cat != $cid && !$frm_id) {
if ($cbuf) { /* If previous category was using compact view, print forum row. */
if (empty($collapse[$i[4]])) { /* Only show if parent is not collapsed as well. */
$forum_list_table_data .= '