$max_level )
{
$max_level = $keys['level'][$i];
}
}
return $max_level;
}
function build_index($cur = 'Root', $cat_break = false, &$forum_moderators, $real_level = -1, $max_level = -1, &$keys, $br = false)
{
global $userdata, $db, $lang, $template, $phpEx, $board_config, $lang, $images, $theme;
global $tree, $phpEx, $idx_buffer, $readhist_buffer, $userdata, $HTTP_COOKIE_VARS, $unique_cookie_name;
// init
$display = false;
$board_config['split_cat'] = (!$board_config['split_cat_over']) ? $userdata['user_split_cat'] : $board_config['split_cat'];
// get the sub_forum switch value
$board_config['sub_forum'] = (!$board_config['sub_forum_over']) ? $userdata['user_sub_forum'] : $board_config['sub_forum'];
$sub_forum = intval($board_config['sub_forum']);
if ( ($sub_forum == 2) && defined('IN_VIEWFORUM') )
{
$sub_forum = 1;
}
$pack_first_level = ($sub_forum == 2);
// verify the cat_break parm
if ( ($cur != 'Root') && ($real_level == -1) )
{
$cat_break = false;
}
// display the level
$athis = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
// display each kind of row
// root level head
if ( $real_level == -1 )
{
// get max inc level
$max = -1;
if ( $sub_forum == 2 )
{
$max = 0;
}
if ( $sub_forum == 1 )
{
$max = 1;
}
$keys = array();
$keys = get_auth_keys($cur, false, -1, $max);
$max_level = get_max_depth($cur, false, -1, $keys, $max);
}
// table header
if ( ($board_config['split_cat'] && $cat_break && ($real_level == 0)) || ((!$board_config['split_cat'] || !$cat_break) && ($real_level == -1)) )
{
// if break, get the local max level
if ( $board_config['split_cat'] && $cat_break && ($real_level == 0) )
{
$max_level = 0;
// the array is sorted
$start = false;
$stop = false;
for($i=0; ($i < count($keys['id']) && !$stop); $i++)
{
if ( $start && ($tree['main'][$keys['idx'][$i]] == $tree['main'][$athis]) )
{
$stop = true;
$break;
}
if ( $keys['id'][$i] == $cur )
{
$start = true;
}
if ( $start && !$stop && ($keys['level'][$i] > $max_level) )
{
$max_level = $keys['level'][$i];
}
}
}
$template->assign_block_vars('catrow', array());
$template->assign_block_vars('catrow.tablehead', array(
'CAT_ID' => $cur,
'L_FORUM' => ($athis < 0) ? $lang['Forum'] : get_object_lang($cur, 'name'),
'INC_SPAN' => $max_level + 2)
);
if ( $cur != 'Root' )
{
$template->assign_block_vars('catrow.tablehead.br', array('CAT_ID' => $cur));
}
}
// get the level
$level = $keys['level'][$keys['keys'][$cur]];
// sub-forum view management
$pull_down = true;
if ( $sub_forum > 0 )
{
$pull_down = false;
if ( ($real_level == 0) && ($sub_forum == 1) )
{
$pull_down = true;
}
}
if ( $level >= 0 )
{
// cat header row
if ( ($tree['type'][$athis] == POST_CAT_URL) && $pull_down )
{
// display a cat row
$cat = $tree['data'][$athis];
$cat_id = $tree['id'][$athis];
// get the class colors
$class_catLeft = 'catLeft';
$class_cat = 'cat';
$class_rowpic = 'rowpic';
// send to template
$template->assign_block_vars('catrow', array());
$template->assign_block_vars('catrow.cathead', array(
'CAT_ID' => $cat_id,
'CAT_TITLE' => get_object_lang($cur, 'name'),
'CLASS_CATLEFT' => $class_catLeft,
'CLASS_CAT' => $class_cat,
'CLASS_ROWPIC' => $class_rowpic,
'INC_SPAN' => $max_level - $level + 2,
'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
);
// add indentation to the display
for($k = 1; $k <= $level; $k++)
{
$template->assign_block_vars('catrow.cathead.inc', array(
'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
);
}
if (!empty($cat['cat_desc']))
{
$template->assign_block_vars('catrow', array());
$template->assign_block_vars('catrow.cattitle', array(
'CAT_DESCRIPTION' => get_object_lang(POST_CAT_URL . $cat_id, 'desc'),
'INC_SPAN_ALL' => $max_level - $level + 5)
);
// add indentation to the display
for($k = 1; $k <= $level; $k++)
{
$template->assign_block_vars('catrow.cattitle.inc', array(
'INC_CLASS' => ($k % 2) ? 'row1' : 'row2')
);
}
}
// something displayed
$display = true;
}
}
// forum header row
if ( $level >= 0 )
{
if ( ($tree['type'][$athis] == POST_FORUM_URL) || (($tree['type'][$athis] == POST_CAT_URL) && !$pull_down) )
{
// get the data
$data = $tree['data'][$athis];
$id = $tree['id'][$athis];
$type = $tree['type'][$athis];
$sub = (!empty($tree['sub'][$cur]) && $tree['auth'][$cur]['tree.auth_view']);
// specific to the data type
$title = get_object_lang($cur, 'name');
$desc = get_object_lang($cur, 'desc');
// specific to something attached
if ( $sub )
{
$i_new = $images['category_new'];
$a_new = $lang['New_posts'];
$i_norm = $images['category'];
$a_norm = $lang['No_new_posts'];
$i_locked = $images['category_locked'];
$a_locked = $lang['Forum_locked'];
}
else
{
$i_new = $images['forum_new'];
$a_new = $lang['New_posts'];
$i_norm = $images['forum'];
$a_norm = $lang['No_new_posts'];
$i_locked = $images['forum_locked'];
$a_locked = $lang['Forum_locked'];
}
// forum link type
if ( ($tree['type'][$athis] == POST_FORUM_URL) && !empty($tree['data'][$athis]['forum_link']) )
{
$i_new = $images['link'];
$a_new = $lang['Forum_link'];
$i_norm = $images['link'];
$a_norm = $lang['Forum_link'];
$i_locked = $images['link'];
$a_locked = $lang['Forum_link'];
}
if ( defined('IN_VIEWFORUM') && !defined('UNREAD_POSTS') && $userdata['user_id'] != ANONYMOUS )
{
define('UNREAD_POSTS', true);
$userdata = user_unread_posts();
}
$forum_id = $tree['id'][$athis];
// front icon
if ( $userdata['session_logged_in'] && $forum_id && $type == POST_FORUM_URL )
{
if ( isset($userdata['unread_data'][$forum_id]) )
{
$smart_new = true;
}
}
$folder_image = ( $smart_new ) ? $i_new : $i_norm;
$folder_alt = ( $smart_new ) ? $a_new : $a_norm;
if ( $data['tree.locked'] )
{
$folder_image = $i_locked;
$folder_alt = $a_locked;
}
// moderators list
$l_moderators = ' ';
$moderator_list = ' ';
if ( $type == POST_FORUM_URL )
{
$forum_moderators = moderarots_list($id, 'groups');
$count_moderators = count($forum_moderators);
if ( $count_moderators > 0 )
{
$moderator_list = implode(', ', $forum_moderators);
$l_moderators = ( $count_moderators == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
}
}
// last post
$last_post = '--';
if ( $data['tree.topic_last_post_id'] )
{
$topic_title = $data['tree.topic_title'];
if ( strlen($topic_title) > (intval($board_config['last_topic_title_length']) -3 ) )
{
$topic_title = substr($topic_title, 0, intval($board_config['last_topic_title_length'])) . '...';
}
$topic_title = '' . $topic_title . '';
$board_config['last_topic_title'] = (!$board_config['last_topic_title_over']) ? $userdata['user_last_topic_title'] : $board_config['last_topic_title'];
$last_postmsg = (($board_config['last_topic_title']) ? $topic_title : '');
$last_postmsg = ($board_config['last_topic_title']) ? '' . $lang['Last_Post'] . ': ' . $last_postmsg . '' : '';
$colored_username = color_username($data['tree.user_level'], $data['tree.user_jr'], $data['tree.post_user_id'], $data['tree.post_username']);
$color_username = $colored_username[0];
$last_post_time = create_date($board_config['default_dateformat'], $data['tree.post_time'], $board_config['board_timezone']);
$last_post = $last_post_time . '
';
if ( $data['post_approve'] || !$data['forum_moderate'] )
{
$last_post .= ( $data['tree.post_user_id'] == ANONYMOUS ) ? $data['tree.post_username'] . ' ' : '' . $color_username . ' ';
}
$last_post .= '';
}
// links to sub-levels
$num_cols = 3; // liczba kolumn
$x = -1;
$width = floor(100 / $num_cols);
$links = '';
$board_config['sub_level_links'] = (!$board_config['sub_level_links_over']) ? $userdata['user_sub_level_links'] : $board_config['sub_level_links'];
if ( $sub && !$pull_down && (intval($board_config['sub_level_links']) > 0) && ((($real_level == 0) && ($sub_forum == 1)) || ($real_level == 1) || ($sub_forum == 2)) )
{
for($j=0; $j < count($tree['sub'][$cur]); $j++) if ( $tree['auth'][ $tree['sub'][$cur][$j] ]['auth_view'] )
{
$wcur = $tree['sub'][$cur][$j];
$wthis = $tree['keys'][$wcur];
$wdata = $tree['data'][$wthis];
$wname = get_object_lang($wcur, 'name');
$wdesc = get_object_lang($wcur, 'desc');
switch($tree['type'][$wthis])
{
case POST_FORUM_URL:
$wpgm = append_sid("./viewforum.$phpEx?" . POST_FORUM_URL . '=' . $tree['id'][$wthis]);
break;
case POST_CAT_URL:
$wpgm = append_sid("./index.$phpEx?" . POST_CAT_URL . '=' . $tree['id'][$wthis]);
break;
default:
$wpgm = append_sid("./index.$phpEx");
break;
}
$link = '';
if ( $wname != '' )
{
$style_color = ($tree['data'][$wthis]['forum_color']) ? ' style="color: #' . $tree['data'][$wthis]['forum_color'] . '"' : '';
$link = '' . $wname . '';
}
if ( intval($board_config['sub_level_links']) == 2 )
{
$wsub = (!empty($tree['sub'][$wcur]) && $tree['auth'][$wcur]['tree.auth_view']);
// specific to something attached
// if ( $wsub )
// {
$wi_new = $images['icon_minicat_new'];
$wa_new = $lang['New_posts'];
$wi_norm = $images['icon_minicat'];
$wa_norm = $lang['No_new_posts'];
$wi_locked = $images['icon_minicat_locked'];
$wa_locked = $lang['Forum_locked'];
/* }
else
{
$wi_new = $images['icon_minipost_new'];
$wa_new = $lang['New_posts'];
$wi_norm = $images['icon_minipost'];
$wa_norm = $lang['No_new_posts'];
$wi_locked = $images['icon_minipost_lock'];
$wa_locked = $lang['Forum_locked'];
}
*/
// forum link type
if ( ($tree['type'][$wthis] == POST_FORUM_URL) && !empty($wdata['forum_link']) )
{
$wi_new = $images['icon_minilink'];
$wa_new = $lang['Forum_link'];
$wi_norm = $images['icon_minilink'];
$wa_norm = $lang['Forum_link'];
$wi_locked = $images['icon_minilink'];
$wa_locked = $lang['Forum_link'];
}
// front icon
$u_id = $tree['id'][$wthis];
$wdata['tree.unread_topics'] = ($userdata['unread_data'][$u_id]) ? true : false;
$wfolder_image = ( $wdata['tree.unread_topics'] ) ? $wi_new : $wi_norm;
$wfolder_alt = ( $wdata['tree.unread_topics'] ) ? $wa_new : $wa_norm;
if ( $wdata['tree.locked'] )
{
$wfolder_image = $wi_locked;
$wfolder_alt = $wa_locked;
}
$wlast_post = '';
$wlast_post .= '';
}
if ( $link != '' )
{
$x++;
if( $x % $num_cols == 0 )
{
$links .= '