############################################################## 
## MOD Title: Categories hierarchy : upgrade from 1.1.0 to 2.0.0
## MOD Author: Ptirhiik < admin@rpgnet-fr.com > (Pierre) http://www.rpgnet-fr.com
## MOD Description:
##		Upgrade description of categories hierarchy, from 1.1.0 to 2.0.0
##
## MOD Version: 1.0.1
## 
## Installation Level: Moderate
## Installation Time: 2 Hours
## Files To Edit:
##		index.php
##		modcp.php
##		posting.php
##		search.php 
##		viewforum.php
##		viewonline.php
##		viewtopic.php
##
##		admin/admin_board.php
##		admin/admin_forum_prune.php
##		admin/admin_forumauth.php
##		admin/admin_forums.php
##		admin/admin_ug_auth.php
##
##		includes/functions.php
##		includes/functions_admin.php
##		includes/page_header.php
##		includes/topic_review.php
##
##		language/lang_english/lang_admin.php
##		language/lang_english/lang_main.php
##
##		templates/subSilver/index_body.tpl
##		templates/subSilver/modcp_move.tpl
##		templates/subSilver/modcp_split.tpl
##		templates/subSilver/overall_header.tpl
##		templates/subSilver/posting_body.tpl
##		templates/subSilver/search_body.tpl
##		templates/subSilver/subSilver.cfg
##		templates/subSilver/subSilver.css
##		templates/subSilver/viewforum_body.tpl
##		templates/subSilver/viewtopic_body.tpl
##
##		templates/subSilver/admin/auth_ug_body.tpl
##		templates/subSilver/admin/board_config_body.tpl
##		templates/subSilver/admin/forum_admin_body.tpl
##		templates/subSilver/admin/forum_delete_body.tpl
##		templates/subSilver/admin/forum_edit_body.tpl
##		templates/subSilver/admin/page_header.tpl
##
## Included Files:
##		index_box.tpl
##
##		graph.gif/icon_minicat.gif
##		graph.gif/icon_minicat_new.gif
##		graph.gif/icon_minicat_lock.gif
##		graph.gif/link_folder.gif
##		graph.gif/icon_minilink.gif
##		graph.gif/icon_minipost_lock.gif
##
##		mod_categories_hierarchy.php
##		mod-mods_settings/functions_mods_settings.php
##		mod-mods_settings/admin_board_extend.php
##		mod-mods_settings/board_config_extend_body.tpl
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
##		This mod is not the full version of categories hierarchy, but
##	the upgrade of the version 1.1.0 to 2.0.0
##
##
##	Note the cellpic4 used by the catRupt class has been removed
## 
############################################################## 
## MOD History: 
## 
##   2003-07-13 - Version 1.0.0
##      - first release
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
#-----[ SQL ]-------------------------------------------------
#
ALTER TABLE phpbb_categories ADD cat_main_type CHAR(1);
ALTER TABLE phpbb_forums ADD forum_link VARCHAR(255);
ALTER TABLE phpbb_forums ADD forum_link_internal TINYINT(1) NOT NULL;
ALTER TABLE phpbb_forums ADD forum_link_hit_count TINYINT(1) NOT NULL;
ALTER TABLE phpbb_forums ADD forum_link_hit BIGINT(20) UNSIGNED NOT NULL;
#
#-----[ SQL ]-------------------------------------------------
#
#	the next request is optional. Run it only if you plan to use the real sub-forums feature
#
ALTER TABLE phpbb_forums ADD main_type CHAR(1);
#
#-----[ SQL ]-------------------------------------------------
#
# This part is optional : do it only if you want your users to be able to choose their setup
#	if you want so, you'll have to install the MOD-mods_settings mod included in the pack
#
ALTER TABLE phpbb_users ADD user_sub_forum TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_split_cat TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_last_topic_title TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_sub_level_links TINYINT(1) DEFAULT '2' NOT NULL;
ALTER TABLE phpbb_users ADD user_display_viewonline TINYINT(1) DEFAULT '2' NOT NULL;
#
#-----[ COPY ]------------------------------------------------
#
copy index_box.tpl to templates/subSilver/index_box.tpl
#
#-----[ COPY ]------------------------------------------------
#
copy graph.gif/icon_minicat.gif to templates/subSilver/images/icon_minicat.gif
copy graph.gif/icon_minicat_new.gif to templates/subSilver/images/icon_minicat_new.gif
copy graph.gif/icon_minicat_lock.gif to templates/subSilver/images/icon_minicat_lock.gif
copy graph.gif/link_folder.gif to templates/subSilver/images/link_folder.gif
copy graph.gif/icon_minilink.gif to templates/subSilver/images/icon_minilink.gif
copy graph.gif/icon_minipost_lock.gif to templates/subSilver/images/icon_minipost_lock.gif
#
#-----[ COPY ]------------------------------------------------
#
#
# those ones are a part of the MOD-mods_settings mod, and are required for categories hierarchy
#
copy mod_categories_hierarchy.php to includes/mods_settings/mod_categories_hierarchy.php
copy mod-mods_settings/functions_mods_settings.php to includes/functions_mods_settings.php
copy mod-mods_settings/admin_board_extend.php to admin/admin_board_extend.php
copy mod-mods_settings/board_config_extend_body.tpl to templates/subSilver/admin/board_config_extend_body.tpl
#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.1
//
// enhance categories informations : description, last post, numbers of posts/topics, and so
function enhance_cat($cat_id)
{
//-- fix v 1.0.6
	global $HTTP_COOKIE_VARS, $category_rows, $forum_data, $is_auth_ary, $tracking_forums, $tracking_topics, $new_topic_data, $images, $lang, $board_config, $userdata, $phpEx;
//--

	if ($cat_id < 0) $cat_id=0;

	// default values
	$ind = -1;
	//-- v 1.0.5
	$categories_desc = ''; // all the sub-cat titles
	$forums_desc = ''; // all the sub-forum titles
	//--
	$cat_display = false;
	$cat_locked = true;
	$cat_unread_topics = false;
	$cat_posts = 0;
	$cat_topics = 0;
	$cat_post_time = 0;
	$cat_last_post = '';

	// look up for sub-categories
	for ($i=0; $i < count($category_rows); $i++)
	{
		// let's fix the cat_main : attached to  index : lvl 0
		if ($category_rows[$i]['cat_main']==$category_rows[$i]['cat_id']) $category_rows[$i]['cat_main'] = 0;

		// get the tab index for $cat_id
		if ( ($cat_id > 0) && ($category_rows[$i]['cat_id']==$cat_id) ) $ind = $i;

		// identify category which are daughters of the one running
		if ( $category_rows[$i]['cat_main']==$cat_id && $category_rows[$i]['cat_id']>0 )
		{
			// enhance sub-categories
			enhance_cat($category_rows[$i]['cat_id']);

			// get the result
			//-- v 1.0.5
			$categories_desc .= empty($categories_desc) ? '':', ';
			$categories_desc .= $category_rows[$i]['cat_title'];
			//--
			if ( $category_rows[$i]['cat_display'] ) $cat_display = true;
			if ( !($category_rows[$i]['cat_locked']) ) $cat_locked = false;
			if ( $category_rows[$i]['unread_topics'] ) $cat_unread_topics = true;
			$cat_posts = $cat_posts + $category_rows[$i]['posts'];
			$cat_topics = $cat_topics + $category_rows[$i]['topics'];
			if ( $cat_post_time < $category_rows[$i]['post_time']) 
			{
				$cat_post_time = $category_rows[$i]['post_time'];
				$cat_last_post = $category_rows[$i]['last_post'];
			}
		} //  if ($category_rows[$i]['cat_main']==$cat_id) || ( ($cat_id==0) && ($category_rows[$i]['cat_main']==$category_rows[$i]['cat_id']) )
	} // for ($i=0; $i < count($category_rows); $i++)

	// deal with the forums of the category
	if ($ind > -1)
	{
		// Raz
		$category_rows[$ind]['cat_display'] = false;
		$category_rows[$ind]['cat_locked'] = true;
		$category_rows[$ind]['unread_topics'] = false;
		$category_rows[$ind]['posts'] = 0;
		$category_rows[$ind]['topics'] = 0;
		$category_rows[$ind]['post_time'] = 0;
		$category_rows[$ind]['last_post'] = '';

		// look up for the forums of the category
		for ($j=0;$j<count($forum_data);$j++)
		{
			if ($forum_data[$j]['cat_id'] == $cat_id)
			{
				$forum_id = $forum_data[$j]['forum_id'];

				// valeur par dfaut
				$display_forum = false;
				$unread_topics = false;
				$last_post = "";

				// forum visible ?
				if ( $display_forum = $is_auth_ary[$forum_id]['auth_view'] )
				{
					if ($forum_data[$j]['forum_status'] != FORUM_LOCKED)
					{
						if ( $userdata['session_logged_in'] && !empty($new_topic_data[$forum_id]) )
						{
							$forum_last_post_time = 0;
							while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
							{
								if ( empty($tracking_topics[$check_topic_id]) )
								{
									$unread_topics = true;
									$forum_last_post_time = max($check_post_time, $forum_last_post_time);
								}
								else
								{
									if ( $tracking_topics[$check_topic_id] < $check_post_time )
									{
										$unread_topics = true;
										$forum_last_post_time = max($check_post_time, $forum_last_post_time);
									}
								}
							} //  end while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
							if ( !empty($tracking_forums[$forum_id]) )
							{
								if ( $tracking_forums[$forum_id] > $forum_last_post_time )
								{
									$unread_topics = false;
								}
							}
							if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
							{
								if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
								{
									$unread_topics = false;
								}
							}
						} //  if ( $userdata['session_logged_in'] && !empty($new_topic_data[$forum_id]) )
					} //  if ($forum_data[$j]['forum_status'] != FORUM_LOCKED)

					$posts = $forum_data[$j]['forum_posts'];
					$topics = $forum_data[$j]['forum_topics'];

					$last_post = $lang['No_Posts'];
					if ( $forum_data[$j]['forum_last_post_id'] )
					{
						$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
						$last_post = $last_post_time . '<br />';
						$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
						$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
					}

				} //  if ($display_forums = $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'])

				// enhanced forum row
				$forum_data[$j]['display_forum'] = $display_forum;
				$forum_data[$j]['unread_topics'] = $unread_topics;
				$forum_data[$j]['last_post'] = $last_post;

				// ok : add forum informations to the category
				if ($forum_data[$j]['display_forum'])
				{
					//-- v 1.0.5
					$forums_desc .= empty($forums_desc) ? '':', ';
					$forums_desc .= $forum_data[$j]['forum_name'];
					//--
					$category_rows[$ind]['cat_display'] = true;
					if ( $forum_data[$j]['forum_status'] != FORUM_LOCKED ) $category_rows[$ind]['cat_locked'] = false;
					if ( $forum_data[$j]['unread_topics'] ) $category_rows[$ind]['unread_topics'] = true;
					$category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $forum_data[$j]['forum_posts'];
					$category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $forum_data[$j]['forum_topics'];
					if ( $forum_data[$j]['post_time'] > $category_rows[$ind]['post_time']) 
					{
						$category_rows[$ind]['post_time'] = $forum_data[$j]['post_time'];
						$category_rows[$ind]['last_post'] = $forum_data[$j]['last_post'];
					}
				} //  if ($display_forum)
			} // if ($forum_data['cat_id'] == $cat_id)
		} // for ($j=0;$j<count($forum_data);$j++)

		// all is done for the forums : add the sub-categories informations
		//-- v 1.0.5
		if ( empty($category_rows[$ind]['cat_desc']) )
		{
			$category_rows[$ind]['cat_desc']  = $forums_desc;
			$category_rows[$ind]['cat_desc'] .= ( empty($forums_desc) || empty($categories_desc) ) ? '': ', ';
			$category_rows[$ind]['cat_desc'] .= $categories_desc;
		}
		//--
		if ( $cat_display ) $category_rows[$ind]['cat_display'] = true;
		if ( !$cat_locked ) $category_rows[$ind]['cat_locked'] = false;
		if ( $cat_unread_topics ) $category_rows[$ind]['unread_topics'] = true;
		$category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $cat_posts;
		$category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $cat_topics;
		if ( $cat_post_time > $category_rows[$ind]['post_time']) 
		{
			$category_rows[$ind]['post_time'] = $cat_post_time;
			$category_rows[$ind]['last_post'] = $cat_last_post;
		}
	} // if ($ind > -1)
} // function enhance_cat_forum

function display_index_cat($catrow, $sub_forum, $main, $cur_depth = 0)
{
	global $total_categories, $category_rows, $total_forums, $forum_data, $forum_moderators, $images, $lang, $template, $phpEx;
	global $max_depth;
	if ( $sub_forum ) $cur_depth = 0;

	$cat_id = $catrow['cat_id'];
	if ($catrow['cat_display'])
	{
		// display cat title
		$class_catLeft = "catLeft";
		$class_rowpic  = "rowpic";
		if (!$sub_forum && $main)
		{
			$class_catLeft = "catRupt";
			$class_rowpic  = "catRupt";
		}
		$template->assign_block_vars('catrow', array(
			'INC_SPAN'		=> $max_depth-$cur_depth + 2,
			'CLASS_CATLEFT' => $class_catLeft,
			'CLASS_ROWPIC'  => $class_rowpic,
			'CAT_ID'        => $cat_id,
			'CAT_DESC'      => $catrow['cat_title'],
			'U_VIEWCAT'     => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
		);
		$color = true;
		$inc_row = true;
		for ($k=0; $k < $cur_depth; $k++ ) 
		{
			$template->assign_block_vars('catrow.inc', array('INC_ROW' => $inc_row ? "row1" : "row2" ) );
			$inc_row = !$inc_row;
		}

		// display forums
		for($j = 0; $j < $total_forums; $j++)
		{
			if ( ($forum_data[$j]['cat_id']==$cat_id) && $forum_data[$j]['display_forum'] )
			{
				$forum_id = $forum_data[$j]['forum_id'];
				$folder_image = ( $forum_data[$j]['unread_topics'] ) ? $images['forum_new'] : $images['forum']; 
				$folder_alt   = ( $forum_data[$j]['unread_topics'] ) ? $lang['New_posts'] : $lang['No_new_posts']; 
				if ($forum_data[$j]['forum_status'] == FORUM_LOCKED )
				{
					$folder_image = $images['forum_locked']; 
					$folder_alt = $lang['Forum_locked'];
				}
				$l_moderators = '&nbsp;';
				$moderator_list = '&nbsp;';
				if ( count($forum_moderators[$forum_id]) > 0 )
				{
					$l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
					$moderator_list = implode(', ', $forum_moderators[$forum_id]);
				}
				$row_color = ( $color ) ? $theme['td_color1'] : $theme['td_color2'];
				$row_class = ( $color ) ? $theme['td_class1'] : $theme['td_class2'];
				$color = !$color;
				$odd = ( $sub_forum || ( intval($cur_depth / 2) == ($cur_depth/2) ) );
				$template->assign_block_vars('catrow.forumrow',	array(
					'INC_SPAN'		=> $max_depth-$cur_depth+1,
					'INC_ROW'		=> ( $odd ? "row1" : "row2" ),
					'ROW_COLOR' => '#' . $row_color,
					'ROW_CLASS' => $row_class,
					'FORUM_FOLDER_IMG' => $folder_image, 
					'FORUM_NAME' => $forum_data[$j]['forum_name'],
					'FORUM_DESC' => $forum_data[$j]['forum_desc'],
					'POSTS' => $forum_data[$j]['forum_posts'],
					'TOPICS' => $forum_data[$j]['forum_topics'],
					'LAST_POST' => $forum_data[$j]['last_post'],
					'MODERATORS' => $moderator_list,
					'L_MODERATOR' => $l_moderators, 
					'L_FORUM_FOLDER_ALT' => $folder_alt, 
					'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
				);
				$inc_row = true;
				for ($k=0; $k < $cur_depth; $k++ ) 
				{
					$template->assign_block_vars('catrow.forumrow.inc', array('INC_ROW' => $inc_row ? "row1" : "row2" ) );
					$inc_row = !$inc_row;
				}
			} //  if ( ($forum_data[$j]['cat_id']==$cat_id) && $forum_data[$j]['display_forum'] )
		} //  for($j = 0; $j < $total_forums; $j++)

		// display sub-cat title 
		for ($j=0; $j < $total_categories; $j++)
		{
			if (($category_rows[$j]['cat_main']==$cat_id) && ($category_rows[$j]['cat_display']))
			{
				if (!$sub_forum)
				{
					display_index_cat($category_rows[$j], $sub_forum, false, $cur_depth+1);
				}
				if ($sub_forum)
				{
					$subcat_id = $category_rows[$j]['cat_id'];
					$folder_image = ( $category_rows[$j]['unread_topics'] ) ? $images['category_new'] : $images['category']; 
					$folder_alt   = ( $category_rows[$j]['unread_topics'] ) ? $lang['New_posts'] : $lang['No_new_posts']; 
					if ($category_rows[$j]['cat_locked'] )
					{
						$folder_image = $images['category_locked']; 
						$folder_alt = $lang['Forum_locked'];
					}
					$row_color = ( $color ) ? $theme['td_color1'] : $theme['td_color2'];
					$row_class = ( $color ) ? $theme['td_class1'] : $theme['td_class2'];
					$color = !$color;
					$template->assign_block_vars('catrow.forumrow',	array(
						'INC_ROW'   => "row1",
						'ROW_COLOR' => '#' . $row_color,
						'ROW_CLASS' => $row_class,
						'FORUM_FOLDER_IMG' => $folder_image, 
						'FORUM_NAME' => $category_rows[$j]['cat_title'],
						'FORUM_DESC' => $category_rows[$j]['cat_desc'],
						'POSTS' => $category_rows[$j]['posts'],
						'TOPICS' => $category_rows[$j]['topics'],
						'LAST_POST' => $category_rows[$j]['last_post'],
						'MODERATORS' => "",
						'L_MODERATOR' => "", 
						'L_FORUM_FOLDER_ALT' => $folder_alt, 
						'U_VIEWFORUM' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$subcat_id"))
					);
				} //  if ($sub_forum)
			} //  if ($category_rows[$j]['cat_main']==$cat_id)
		} // for ($j=0; $j < $total_categories; $j++)
	} //  if ($catrow['cat_display'])
} // end function display_index_cat($catrow, $sub_forum, $main)
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

//
// Start session management
//
#
#-----[ REPLACE WITH ]---------------------------------------- 
#

//
// Start session management
//
#
#-----[ FIND ]------------------------------------------------
#
$viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
$viewcat = intval($viewcat);
if ($viewcat <= 0) $viewcat = -1;
$viewcatkey = ($viewcat < 0) ? 'Root' : POST_CAT_URL . $viewcat;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	if ( $viewcat < 0 )
	{
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	if ( $viewcat < 0 )
	{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	}
	else
	{
		if( $userdata['session_logged_in'] )
		{
			// get the list of the involved cats
			$catrows = array();
			$catrows = get_cat($viewcat);

			// build the string list
			$catids = array();
			for ( $i=0; $i < count($catrows); $i++) $catids[] = $catrows[$i]['cat_id'];
			$s_cat = implode(', ', $catids);

			// get the list of the involved forums
			$forumids = array();
			$sql = "select * from " . FORUMS_TABLE . " where cat_id in ($s_cat)";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query new forums information', '', __LINE__, __FILE__, $sql);
			while ( $row = $db->sql_fetchrow($result) ) $forumids[] = $row;

			// mark each forums
			for ( $i=0; $i < count($forumids); $i++ )
			{
				$forum_id = $forumids[$i]['forum_id'];
				$sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id";
				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
				if ( $row = $db->sql_fetchrow($result) )
				{
					$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
					$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();

					if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
					{
						asort($tracking_forums);
						unset($tracking_forums[key($tracking_forums)]);
					}

					if ( $row['last_post'] > $userdata['user_lastvisit'] )
					{
						$tracking_forums[$forum_id] = time();
						setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
					}
				}
			}
		}

		$template->assign_vars(array(
			"META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("index.$phpEx?" . POST_CAT_URL . "=$viewcat") . '">')
		);
	}
//-- fin mod : hirarchie des rubriques -----------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	}
	else
	{
		if( $userdata['session_logged_in'] )
		{
			// get the list of object authorized
			$keys = array();
			$keys = get_auth_keys($viewcatkey);

			// mark each forums
			for ($i=0; $i < count($keys['id']); $i++) if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
			{
				$forum_id = $tree['id'][ $keys['idx'][$i] ];
				$sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id";
				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
				if ( $row = $db->sql_fetchrow($result) )
				{
					$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
					$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();

					if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
					{
						asort($tracking_forums);
						unset($tracking_forums[key($tracking_forums)]);
					}

					if ( $row['last_post'] > $userdata['user_lastvisit'] )
					{
						$tracking_forums[$forum_id] = time();
						setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
					}
				}
			}
		}

		$template->assign_vars(array(
			"META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("index.$phpEx?" . POST_CAT_URL . "=$viewcat") . '">')
		);
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
// $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//
// If you don't use these stats on your index you may want to consider
// removing them
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
include_once($phpbb_root_path . 'includes/mods_settings/mod_categories_hierarchy.' . $phpEx);
if (($board_config['display_viewonline'] == 2) || (($viewcat < 0) && ($board_config['display_viewonline'] == 1)))
{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//
// Start page proper
//
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------

#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
// $sql = "SELECT c.cat_id, c.cat_title, c.cat_order
// 	FROM " . CATEGORIES_TABLE . " c 
// 	ORDER BY c.cat_order";
// if( !($result = $db->sql_query($sql)) )
// {
// 	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
// }
// 
// while( $category_rows[] = $db->sql_fetchrow($result) );
//-- add
//
// get the nav sentence
$nav_cat_desc = make_cat_nav_tree($viewcat, false);
//
// categories array
$category_rows = get_cat($viewcat);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
/*
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
	FROM " . CATEGORIES_TABLE . " c 
	ORDER BY c.cat_order";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}

while( $category_rows[] = $db->sql_fetchrow($result) );
#
#-----[ FIND ]------------------------------------------------
#
	//
	// Find which forums are visible for this user
	//
	$is_auth_ary = array();
	$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- add
*/
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	//
	// Start output of page
	//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
// set the parm of the mark read func
$mark = ($viewcat == -1 ) ? '' : '&' . POST_CAT_URL . '=' . $viewcat;
// monitor the board statistic
if (($board_config['display_viewonline'] == 2) || (($viewcat < 0) && ($board_config['display_viewonline'] == 1)))
{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	define('SHOW_ONLINE', true);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
	if ($nav_cat_desc != "") $nav_cat_desc = $nav_separator . $nav_cat_desc;
	$mark = ($viewcat == -1 ) ? '' : '&' . POST_CAT_URL . '=' . $viewcat;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

	$template->assign_vars(array(
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$template->assign_vars(array(
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
//-- add v 1.0.9
		'U_MARK_READ' => append_sid("index.$phpEx?mark=forums$mark"))
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
	);

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
	$template->assign_vars(array(
		'NAV_CAT_DESC' => $nav_cat_desc)
	);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		'U_MARK_READ' => append_sid("index.$phpEx?mark=forums"))
//-- add
		'U_MARK_READ' => append_sid("index.$phpEx?mark=forums$mark"))
//-- fin mod : categories hierarchy ----------------------------------------------------------------
	);
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete : most of the original code has been reported in the functions enhance_cat() & display_index_cat()
/*
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
/*
#
#-----[ FIND ]------------------------------------------------
#
*/
//-- add v 1.0.9
	// rcuprer la profondeur max
	$max_depth = ( !$sub_forum ) ? get_max_depth($viewcat) : 0;
	$template->assign_vars(array(
		'INC_SPAN' => $max_depth + 2)
	);
//-- add v1.0.1
	//
	// enhance cat & forum informations
	enhance_cat($viewcat);

	// display the index
	$found=false;
	for ($i=0; ($i < $total_categories) && !$found; $i++)
	{
		if ( ($viewcat==-1 && $category_rows[$i]['cat_main']==0) || ($viewcat > 0 && $category_rows[$i]['cat_id']==$viewcat) )
		{
			display_index_cat($category_rows[$i], $sub_forum, true);
			$found = ($viewcat > 0);
		}
	} //  end for ($i=0; ($i < $total_categories) && !$found; $i++)
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

}// if ... total_categories
else
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	} // for ... categories

}// if ... total_categories
// else
//-- add
*/
// don't display the board statistics
if (($board_config['display_viewonline'] == 2) || (($viewcat < 0) && ($board_config['display_viewonline'] == 1)))
{
	$template->assign_block_vars('disable_viewonline', array());
}

// display the index
$display = display_index($viewcatkey);

if (!$display)
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
modcp.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
if (isset($HTTP_GET_VARS['selected_id']) || isset($HTTP_POST_VARS['selected_id']))
{
	$selected_id = isset($HTTP_POST_VARS['selected_id']) ? $HTTP_POST_VARS['selected_id'] : $HTTP_GET_VARS['selected_id'];
	$type	= substr($selected_id, 0, 1);
	$id		= intval(substr($selected_id, 1));
	if ($type == POST_FORUM_URL)
	{
		$forum_id = $id;
	}
	else if (($type == POST_CAT_URL) || ($selected_id == 'Root'))
	{
		$parm = ($id != 0) ? "?" . POST_CAT_URL . "=$id" : '';
		redirect(append_sid("./index.$phpEx" . $parm));
		exit;
	}
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//	$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
//		FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f 
//		WHERE t.topic_id = " . $topic_id . "
//			AND f.forum_id = t.forum_id";
//-- add v 1.0.7
	$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics, f.cat_id, t.topic_title 
		FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f 
		WHERE t.topic_id = " . $topic_id . "
			AND f.forum_id = t.forum_id";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
		FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
		WHERE t.topic_id = " . $topic_id . "
			AND f.forum_id = t.forum_id";
#
#-----[ FIND ]------------------------------------------------
#
	$forum_name = $topic_row['forum_name'];
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
	$cat_id = $topic_row['cat_id'];
	$topic_title = $topic_row['topic_title'];
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_name = $topic_row['forum_name'];
//-- add
	$forum_name = get_object_lang(POST_FORUM_URL . $topic_row['forum_id'], 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//	$sql = "SELECT forum_name, forum_topics
//		FROM " . FORUMS_TABLE . "
//		WHERE forum_id = " . $forum_id;
//-- add v 1.0.7
	$sql = "SELECT forum_name, forum_topics, cat_id 
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = " . $forum_id;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$sql = "SELECT forum_name, forum_topics
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = " . $forum_id;
#
#-----[ FIND ]------------------------------------------------
#
	$forum_name = $topic_row['forum_name'];
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
	$cat_id = $topic_row['cat_id'];
	$topic_title = '';
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_name = $topic_row['forum_name'];
//-- add
	$forum_name = get_object_lang(POST_FORUM_URL . $topic_row['forum_id'], 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
$nav_cat_desc = $nav_separator . make_cat_nav_tree($cat_id, true);
$nav_cat_desc .= $nav_separator . '<a href="'.append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id").'" class="nav">'.$forum_name.'</a>';
if ($topic_title != '') $nav_cat_desc .= $nav_separator . '<a href="'.append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id").'" class="nav">'.$topic_title.'</a>';
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
//
// Start session management
//
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//
// Start session management
//
#
#-----[ FIND ]------------------------------------------------
#
			$old_forum_id = $forum_id;

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
			if ($new_forum_id <= 0 ) message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$fid = $HTTP_POST_VARS['new_forum'];
			if ($fid == 'Root')
			{
				$type = POST_CAT_URL;
				$new_forum_id = 0;
			}
			else
			{
				$type = substr($fid, 0, 1);
				$new_forum_id = ($type == POST_FORUM_URL) ? intval(substr($fid, 1)) : 0;
			}
			if ($new_forum_id <= 0 ) message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			$old_forum_id = $forum_id;
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
				'NAV_CAT_DESC' => $nav_cat_desc,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
				'MESSAGE_TITLE' => $lang['Confirm'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				'MESSAGE_TITLE' => $lang['Confirm'],
#
#-----[ FIND ]------------------------------------------------
#
				'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 
//-- add
				'S_FORUM_SELECT' => selectbox('new_forum', $forum_id),
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
				$topic_time = time();
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
				if ($new_forum_id <= 0 ) message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				$new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
//-- add
				$fid = $HTTP_POST_VARS['new_forum_id'];
				if ($fid == 'Root')
				{
					$type = POST_CAT_URL;
					$new_forum_id = 0;
				}
				else
				{
					$type = substr($fid, 0, 1);
					$new_forum_id = ($type == POST_FORUM_URL) ? intval(substr($fid, 1)) : 0;
				}
				if ($new_forum_id <= 0 ) message_die(GENERAL_MESSAGE, $lang['Forum_not_exist']);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
				$topic_time = time();
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
					'NAV_CAT_DESC' => $nav_cat_desc,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
					'L_SPLIT_TOPIC' => $lang['Split_Topic'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
					'L_SPLIT_TOPIC' => $lang['Split_Topic'],
#
#-----[ FIND ]------------------------------------------------
#
					'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 

					'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
					'S_HIDDEN_FIELDS' => $s_hidden_fields,
					'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
				);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
					'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 

					'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
					'S_HIDDEN_FIELDS' => $s_hidden_fields,
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//					'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
//-- add
					'S_FORUM_SELECT' => selectbox("new_forum_id", false, $forum_id))
//-- fin mod : categories hierarchy ----------------------------------------------------------------
				);
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
			'NAV_CAT_DESC' => $nav_cat_desc,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

			'FORUM_NAME' => $forum_name,
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			'FORUM_NAME' => $forum_name,
#
#-----[ OPEN ]------------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = $post_info['forum_id'];
	$forum_name = $post_info['forum_name'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$forum_id = $post_info['forum_id'];
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_name = $post_info['forum_name'];
//-- add
	$forum_name = get_object_lang(POST_FORUM_URL . $post_info['forum_id'], 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
make_jumpbox('viewforum.'.$phpEx);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
//
// category name
$nav_cat_desc = "";
$cat_id = "";
if ($forum_id)
{
	$sqlw = "SELECT f.cat_id, c.cat_title FROM " . FORUMS_TABLE . " as f, ". CATEGORIES_TABLE ." as c WHERE f.forum_id=$forum_id and f.cat_id=c.cat_id";
	if ( !($resultw = $db->sql_query($sqlw)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sqlw);
	}
	if ( !($catrow = $db->sql_fetchrow($resultw)) )
	{
		message_die(GENERAL_ERROR, 'Catgorie inexistante', '', __LINE__, __FILE__, $sqlw);
	}
	$cat_id   = $catrow['cat_id'];
	//
	// get the nav sentence
	$nav_cat_desc = make_cat_nav_tree($cat_id, true);
	if ($nav_cat_desc != "") $nav_cat_desc = $nav_separator . $nav_cat_desc;
}
//
// topic title
$topic_title = "";
if ($topic_id)
{
	$sqlw = "SELECT * FROM ".TOPICS_TABLE. " WHERE topic_id=$topic_id";
	if ( !($resultw = $db->sql_query($sqlw)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sqlw);
	}
	if ( !($topicrowW = $db->sql_fetchrow($resultw)) )
	{
		message_die(GENERAL_ERROR, 'Topic inexistant', '', __LINE__, __FILE__, $sqlw);
	}
	$topic_title = $topicrowW['topic_title'];
}
if ($topic_title != "")
{
	$topic_title = '<a href="viewtopic.'.$phpEx.'?t='.$topic_id.'" class="maintitle">'.$topic_title.'</a>';
}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
make_jumpbox('viewforum.'.$phpEx);
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
$template->assign_vars(array(
	'NAV_CAT_DESC' => $nav_cat_desc,
	'U_VIEW_CAT' => append_sid("index.$phpEx?c=$cat_id"),
	'TOPIC_TITLE' => $topic_title
	)
);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

//
// This enables the forum/topic title to be output for posting
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//
// This enables the forum/topic title to be output for posting
#
#-----[ OPEN ]------------------------------------------------
#
search.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$search_cat = ( isset($HTTP_POST_VARS['search_cat']) ) ? intval($HTTP_POST_VARS['search_cat']) : -1;
$search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $search_cat = ( isset($HTTP_POST_VARS['search_cat']) ) ? intval($HTTP_POST_VARS['search_cat']) : -1;
// $search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1;
//-- add
$search_where =  ( isset($HTTP_POST_VARS['search_where']) ) ? $HTTP_POST_VARS['search_where'] : 'Root';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		if ( $search_forum != -1 )
		{
			$is_auth = auth(AUTH_READ, $search_forum, $userdata);

			if ( !$is_auth['auth_read'] )
			{
				message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
			}

			$auth_sql = "f.forum_id = $search_forum";
		}
		else
		{
			$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 

			if ( $search_cat != -1 )
			{
				$auth_sql = "f.cat_id = $search_cat";
			}

			$ignore_forum_sql = '';
			while( list($key, $value) = each($is_auth_ary) )
			{
				if ( !$value['auth_read'] )
				{
					$ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
				}
			}

			if ( $ignore_forum_sql != '' )
			{
				$auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
			}
		}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		if ( $search_forum != -1 )
//		{
//			$is_auth = auth(AUTH_READ, $search_forum, $userdata);
//
//			if ( !$is_auth['auth_read'] )
//			{
//				message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
//			}
//
//			$auth_sql = "f.forum_id = $search_forum";
//		}
//		else
//		{
//			$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 
//
//			if ( $search_cat != -1 )
//			{
//				$auth_sql = "f.cat_id = $search_cat";
//			}
//
//			$ignore_forum_sql = '';
//			while( list($key, $value) = each($is_auth_ary) )
//			{
//				if ( !$value['auth_read'] )
//				{
//					$ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
//				}
//			}
//
//			if ( $ignore_forum_sql != '' )
//			{
//				$auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN ($ignore_forum_sql) ";
//			}
//		}
//-- add
		// get the object list
		$keys = array();
		$keys = get_auth_keys($search_where);
		$s_flist = '';
		for ($i=0; $i < count($keys['id']); $i++)
		{
			if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
			{
				$s_flist .= (($s_flist != '') ? ', ' : '') . $tree['id'][ $keys['idx'][$i] ];
			}
		}
		if ($s_flist != '')
		{
			$auth_sql .= (( $auth_sql != '' ) ? " AND" : '') . " f.forum_id IN ($s_flist) ";
		}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
					'TOPIC_TITLE' => $topic_title,
					'FORUM_NAME' => $searchset[$i]['forum_name'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
					'TOPIC_TITLE' => $topic_title,
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//					'FORUM_NAME' => $searchset[$i]['forum_name'],
//-- add
					'FORUM_NAME' => get_object_lang(POST_FORUM_URL . $searchset[$i]['forum_id'], 'name'),
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$template->assign_block_vars('searchresults', array( 
					'FORUM_NAME' => $searchset[$i]['forum_name'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				$template->assign_block_vars('searchresults', array( 
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//					'FORUM_NAME' => $searchset[$i]['forum_name'],
//-- add
					'FORUM_NAME' => get_object_lang(POST_FORUM_URL . $searchset[$i]['forum_id'], 'name'),
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id  
	FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
	WHERE f.cat_id = c.cat_id 
	ORDER BY c.cat_id, f.forum_order";
$result = $db->sql_query($sql);
if ( !$result )
{
	message_die(GENERAL_ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql);
}

$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

$s_forums = '';
while( $row = $db->sql_fetchrow($result) )
{
	if ( $is_auth_ary[$row['forum_id']]['auth_read'] )
	{
		$s_forums .= '<option value="' . $row['forum_id'] . '">' . $row['forum_name'] . '</option>';
		if ( empty($list_cat[$row['cat_id']]) )
		{
			$list_cat[$row['cat_id']] = $row['cat_title'];
		}
	}
}

if ( $s_forums != '' )
{
	$s_forums = '<option value="-1">' . $lang['All_available'] . '</option>' . $s_forums;

	//
	// Category to search
	//
	$s_categories = '<option value="-1">' . $lang['All_available'] . '</option>';
	while( list($cat_id, $cat_title) = @each($list_cat))
	{
		$s_categories .= '<option value="' . $cat_id . '">' . $cat_title . '</option>';
	}
}
else
{
	message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id  
//	FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
//	WHERE f.cat_id = c.cat_id 
//	ORDER BY c.cat_id, f.forum_order";
// $result = $db->sql_query($sql);
// if ( !$result )
// {
//	message_die(GENERAL_ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql);
// }
//
// $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
//
// $s_forums = '';
// while( $row = $db->sql_fetchrow($result) )
// {
//	if ( $is_auth_ary[$row['forum_id']]['auth_read'] )
//	{
//		$s_forums .= '<option value="' . $row['forum_id'] . '">' . $row['forum_name'] . '</option>';
//		if ( empty($list_cat[$row['cat_id']]) )
//		{
//			$list_cat[$row['cat_id']] = $row['cat_title'];
//		}
//	}
// }
//
// if ( $s_forums != '' )
// {
//	$s_forums = '<option value="-1">' . $lang['All_available'] . '</option>' . $s_forums;
//
//	//
//	// Category to search
//	//
//	$s_categories = '<option value="-1">' . $lang['All_available'] . '</option>';
//	while( list($cat_id, $cat_title) = @each($list_cat))
//	{
//		$s_categories .= '<option value="' . $cat_id . '">' . $cat_title . '</option>';
//	}
// }
// else
// {
//	message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
// }
//-- add
$s_forums = get_tree_option();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = '';
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
define('IN_VIEWFORUM', true);
if (isset($HTTP_GET_VARS['selected_id']) || isset($HTTP_POST_VARS['selected_id']))
{
	$selected_id = isset($HTTP_POST_VARS['selected_id']) ? $HTTP_POST_VARS['selected_id'] : $HTTP_GET_VARS['selected_id'];
	$type	= substr($selected_id, 0, 1);
	$id		= intval(substr($selected_id, 1));
	if ($type == POST_FORUM_URL)
	{
		$forum_id = $id;
	}
	else if (($type == POST_CAT_URL) || ($selected_id == 'Root'))
	{
		$parm = ($id != 0) ? "?" . POST_CAT_URL . "=$id" : '';
		redirect(append_sid("./index.$phpEx" . $parm));
		exit;
	}
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//	$sql = "SELECT *
//		FROM " . FORUMS_TABLE . "
//		WHERE forum_id = $forum_id";
//-- add
	$sql = "SELECT *, c.cat_title 
		FROM " . FORUMS_TABLE . " as f, ". CATEGORIES_TABLE ." as c 
		WHERE f.forum_id = $forum_id and f.cat_id = c.cat_id";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
#
#-----[ FIND ]------------------------------------------------
#
//
// Start session management
//
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
//  get cat info
$cat_id = $forum_row['cat_id'];
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//
// Start session management
//
#
#-----[ FIND ]------------------------------------------------
#
//
// End session management
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
// handle forum link type
$selected_id = POST_FORUM_URL . $forum_id;
$this = isset($tree['keys'][$selected_id]) ? $tree['keys'][$selected_id] : -1;
if ( ($this > -1) && !empty($tree['data'][$this]['forum_link']))
{
	// add 1 to hit if count ativated
	if ($tree['data'][$this]['forum_link_hit_count'])
	{
		$sql = "UPDATE " . FORUMS_TABLE . " 
					SET forum_link_hit = forum_link_hit + 1 
					WHERE forum_id=$forum_id";
		if (!$db->sql_query($sql)) message_die(GENERAL_ERROR, 'Could not increment forum hits information', '', __LINE__, __FILE__, $sql);
	}

	// prepare url
	$url = $tree['data'][$this]['forum_link'];
	if ($tree['data'][$this]['forum_link_internal'])
	{
		$part = explode( '?', $url);
		$url .= ((count($part) > 1) ? '&' : '?') . 'sid=' . $userdata['session_id'];
		$url = append_sid($url);

		// redirect to url
		redirect($url);
	}

	// Redirect via an HTML form for PITA webservers
	if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))
	{
		header('Refresh: 0; URL=' . $url);
		echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $url . '"><title>' . $lang['Redirect'] . '</title></head><body><div align="center">' . sprintf($lang['Rediect_to'], '<a href="' . $url . '">', '</a>') . '</div></body></html>';
		exit;
	}

	// Behave as per HTTP/1.1 spec for others
	header('Location: ' . $url);
	exit;
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//
// Dump out the page header and load viewforum template
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
$forum_row['forum_name'] = get_object_lang(POST_FORUM_URL . $forum_id, 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
// get nav sentence
$nav_cat_desc = make_cat_nav_tree($cat_id, true);
if ($nav_cat_desc != "") $nav_cat_desc = $nav_separator . $nav_cat_desc;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
// display the sub-cats
display_index(POST_FORUM_URL . $forum_id);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"))
);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
$template->assign_vars(array(
	'NAV_CAT_DESC' => $nav_cat_desc
	)
);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"))
);
#
#-----[ OPEN ]------------------------------------------------
#
viewonline.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$forum_data[$row['forum_id']] = $row['forum_name'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$forum_data[$row['forum_id']] = $row['forum_name'];
//-- add
		$forum_data[$row['forum_id']] = get_object_lang(POST_FORUM_URL . $row['forum_id'], 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
// $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
//	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . " 
//	WHERE $join_sql
//		AND f.forum_id = t.forum_id
//		$order_sql";
//-- add
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments, f.cat_id, c.cat_title" . $count_sql . "
	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f," . CATEGORIES_TABLE . " c" . $join_sql_table . " 
	WHERE $join_sql
		AND f.forum_id = t.forum_id
		AND c.cat_id = f.cat_id
		$order_sql";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
	WHERE $join_sql
		AND f.forum_id = t.forum_id
		$order_sql";
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
$cat_id   = $forum_topic_data['cat_id'];
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

$forum_name = $forum_topic_data['forum_name'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $forum_name = $forum_topic_data['forum_name'];
//-- add
$forum_name = get_object_lang(POST_FORUM_URL . $forum_topic_data['forum_id'], 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
// get the nav sentence
$nav_cat_desc = make_cat_nav_tree($cat_id, true);
if ($nav_cat_desc != "") $nav_cat_desc = $nav_separator . $nav_cat_desc;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
//
// If we've got a hightlight set pass it on to pagination,
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//
// If we've got a hightlight set pass it on to pagination,
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
	'NAV_CAT_DESC' => $nav_cat_desc,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

	'FORUM_ID' => $forum_id,
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	'FORUM_ID' => $forum_id,
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------------
#
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : "";
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.2
$sub_forum_yes = ( $new['sub_forum'] ) ? "checked=\"checked\"" : "";
$sub_forum_no = ( !$new['sub_forum'] ) ? "checked=\"checked\"" : "";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : "";
#
#-----[ FIND ]------------------------------------------------
#
	"S_CONFIG_ACTION" => append_sid("admin_board.$phpEx"),
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.2
	"SUB_FORUM_YES" => $sub_forum_yes,
	"SUB_FORUM_NO" => $sub_forum_no,
	"L_SUB_FORUM" => $lang['Use_sub_forum'],
//-- add v1.0.7
	"L_HIERARCHY_SETTINGS" => $lang['Hierarchy_setting'],
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	"S_CONFIG_ACTION" => append_sid("admin_board.$phpEx"),
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forum_prune.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = ( isset($HTTP_POST_VARS[POST_FORUM_URL]) ) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL];
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	$cat_id = -1;
	if ( substr($forum_id, 0, 1) == 'C' ) $cat_id = intval( substr($forum_id, 1) );
	$forum_sql = '';
	if ( $cat_id > -1 )
	{
		$catrows = get_cat($cat_id);
		$catids = array();
		for ( $i = 0; $i < count($catrows); $i++ ) $catids[] = $catrows[$i]['cat_id'];
		$s_cat = implode(', ', $catids);
		if ( $s_cat != '' ) $forum_sql = " AND f.cat_id in ($s_cat)";
	}
	else
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

	if( $forum_id == -1 )
	{
		$forum_sql = '';
	}
	else
	{
		$forum_id = intval($forum_id);
		$forum_sql = "AND forum_id = $forum_id";
	}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_id = ( isset($HTTP_POST_VARS[POST_FORUM_URL]) ) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL];
//
//	if( $forum_id == -1 )
//	{
//		$forum_sql = '';
//	}
//	else
//	{
//		$forum_id = intval($forum_id);
//		$forum_sql = "AND forum_id = $forum_id";
//	}
//-- add
	$fid = ( isset($HTTP_POST_VARS[POST_FORUM_URL]) ) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL];
	$type = substr($fid, 0, 1);
	$id = intval(substr($fid, 1));
	$cat_id = -1;
	$forum_id = -1;
	if ($fid == 'Root') $type = POST_CAT_URL;
	if ($type == POST_CAT_URL)
	{
		$cat_id = $id;
	}
	else
	{
		$forum_id = $id;
	}

	// set the sql request
	$tkeys = array();
	$tkeys = get_auth_keys($fid, true);
	$forum_rows = array();
	for ($i=0; $i < count($tkeys['id']); $i++)
	{
		if ($tree['type'][$tkeys['idx'][$i]] == POST_FORUM_URL)
		{
			$forum_rows[] = $tree['data'][$tkeys['idx'][$i]];
		}
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = '';
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	$forum_rows = array();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT f.*
	FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
	WHERE c.cat_id = f.cat_id
	$forum_sql
	ORDER BY c.cat_order ASC, f.forum_order ASC";
if( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain list of forums for pruning', '', __LINE__, __FILE__, $sql);
}

$forum_rows = array();
while( $row = $db->sql_fetchrow($result) )
{
	$forum_rows[] = $row;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $sql = "SELECT f.*
//	FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
//	WHERE c.cat_id = f.cat_id
//	$forum_sql
//	ORDER BY c.cat_order ASC, f.forum_order ASC";
// if( !($result = $db->sql_query($sql)) )
// {
//	message_die(GENERAL_ERROR, 'Could not obtain list of forums for pruning', '', __LINE__, __FILE__, $sql);
// }
//
// $forum_rows = array();
// while( $row = $db->sql_fetchrow($result) )
// {
//	$forum_rows[] = $row;
// }
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			'FORUM_NAME' => $forum_rows[$i]['forum_name'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			'FORUM_NAME' => $forum_rows[$i]['forum_name'],
//-- add
			'FORUM_NAME' => get_object_lang(POST_FORUM_URL . $forum_rows[$i]['forum_id'], 'name'),
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		$select_list = '<select name="' . POST_FORUM_URL . '">';
//		$select_list .= '<option value="-1">' . $lang['All_Forums'] . '</option>';
//
//		for($i = 0; $i < count($forum_rows); $i++)
//		{
//			$select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>';
//		}
//		$select_list .= '</select>';
//-- add v 1.0.9
		$select_list = make_forum_select(POST_FORUM_URL, false, '', true);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$select_list = '<select name="' . POST_FORUM_URL . '">';
//		$select_list .= '<option value="-1">' . $lang['All_Forums'] . '</option>';
//
//		for($i = 0; $i < count($forum_rows); $i++)
//		{
//			$select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>';
//		}
//		$select_list .= '</select>';
//-- add
		$select_list = selectbox(POST_FORUM_URL, false, '', true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		$forum_id = intval($HTTP_POST_VARS[POST_FORUM_URL]);
//-- add v 1.0.9
		$forum_id = $HTTP_POST_VARS[POST_FORUM_URL];
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$forum_id = intval($HTTP_POST_VARS[POST_FORUM_URL]);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$forum_name = ( $forum_id == -1 ) ? $lang['All_Forums'] : $forum_rows[0]['forum_name'];
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
		if ( $cat_id > -1 )
		{
			if ( $cat_id == 0)
			{
				$forum_name = $lang['All_Forums'];
			}
			else
			{
				$sql = "select * from " . CATEGORIES_TABLE . " where cat_id = $cat_id";
				if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query category', '', __LINE__, __FILE__, $sql);
				if ( $row = $db->sql_fetchrow($result) ) $forum_name = $row['cat_title'];
			}
		}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$forum_name = ( $forum_id == -1 ) ? $lang['All_Forums'] : $forum_rows[0]['forum_name'];
//-- add
		$forum_name = ($fid == 'Root') ? $lang['All_Forums'] : get_object_lang($fid, 'name');
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$prune_data .= '<input class="post" type="text" name="prunedays" size="4"> ' . $lang['Days'];

		$hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		$prune_data .= '<input class="post" type="text" name="prunedays" size="4"> ' . $lang['Days'];

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
//-- add
		$hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $fid . '" />';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			'L_FORUM' => $lang['Forum'], 
//-- add v 1.0.9
			'L_FORUM' => ( $cat_id > 0 ) ? $lang['Category'] : $lang['Forum'], 
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			'L_FORUM' => $lang['Forum'],
//-- add
			'L_FORUM' => ( $cat_id > 0 ) ? $lang['Category'] : $lang['Forum'],
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forumauth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
require('./pagestart.' . $phpEx);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
require('./pagestart.' . $phpEx);
#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
	$forum_sql = "AND forum_id = $forum_id";
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
//	$forum_sql = "AND forum_id = $forum_id";
//-- add
	$fid = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL];
	$f_type = substr($fid, 0, 1);
	if ($f_type == POST_FORUM_URL)
	{
		$forum_id = intval(substr($fid, 1));
		$forum_sql = " WHERE forum_id = $forum_id";
	}
	else
	{
		unset($forum_id);
		$forum_sql = '';
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT f.*
	FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
	WHERE c.cat_id = f.cat_id
	$forum_sql
	ORDER BY c.cat_order ASC, f.forum_order ASC";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Couldn't obtain forum list", "", __LINE__, __FILE__, $sql);
}

$forum_rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
// if( empty($forum_id) )
//-- add v 1.0.9
if ( empty($forum_id) || ( $forum_id <= 0 ) )
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $sql = "SELECT f.*
//	FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
//	WHERE c.cat_id = f.cat_id
//	$forum_sql
//	ORDER BY c.cat_order ASC, f.forum_order ASC";
// if ( !($result = $db->sql_query($sql)) )
// {
//	message_die(GENERAL_ERROR, "Couldn't obtain forum list", "", __LINE__, __FILE__, $sql);
// }
//
// $forum_rows = $db->sql_fetchrowset($result);
// $db->sql_freeresult($result);
//-- fin mod : categories hierarchy ----------------------------------------------------------------

if( empty($forum_id) )
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//	$select_list = '<select name="' . POST_FORUM_URL . '">';
//	for($i = 0; $i < count($forum_rows); $i++)
//	{
//		$select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>';
//	}
//	$select_list .= '</select>';
//-- add v 1.0.9
	$select_list = make_forum_select(POST_FORUM_URL);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$select_list = '<select name="' . POST_FORUM_URL . '">';
//	for($i = 0; $i < count($forum_rows); $i++)
//	{
//		$select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>';
//	}
//	$select_list .= '</select>';
//-- add
	$select_list = selectbox(POST_FORUM_URL);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$forum_name = $forum_rows[0]['forum_name'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$forum_name = $forum_rows[0]['forum_name'];
//-- add
	$forum_rows[0] = $tree['data'][$tree['keys'][POST_FORUM_URL . $forum_id]];
	$forum_name_trad = get_object_lang(POST_FORUM_URL . $forum_id, 'name');
	$forum_name = $forum_rows[0]['forum_name'];
	if ($forum_name != $forum_name_trad)
	{
		$forum_name = '(' . $forum_name . ') ' . $forum_name_trad;
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&adv=". $adv_mode);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&adv=". $adv_mode);
//-- add
	$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=f" . $forum_id . "&adv=". $adv_mode);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
//-- add
	$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="f' . $forum_id . '">';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
//
// check and fix parm
function admin_check_cat()
{
	global $db;

	$res = false;
	// build the cat list
	$sql = "select * from " . CATEGORIES_TABLE . " order by cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	$last_cat = -1;
	while ( $row = $db->sql_fetchrow($result) ) 
	{
		// corriger la valeur de cat_main
		if ( $row['cat_main'] == $row['cat_id'] ) $row['cat_main'] = 0;
		// alimenter le tableau de hierarchie
		$cat_main[ $row['cat_id'] ] = $row['cat_main'];
		// rcuprer l'indice de catgorie le plus grand
		if ( $row['cat_id'] > $last_cat ) $last_cat = $row['cat_id'];
	}  // end while ( $row = $db->sql_fetchrow($result) )
	//
	// push each cat
	for ($i=0; $i <= $last_cat; $i++) if ( isset($cat_main[$i]) )
	{
		$root = false;
		$cur_cat = $i;
		$stack = array();
		$stack[0] = $cur_cat;
		while ( !$root )
		{
			$err = false;
			// la catgorie parente n'existe pas
			$err = ( ($cat_main[$cur_cat] != 0 ) && !isset($cat_main[ $cat_main[$cur_cat] ]) );
			// la catgorie parente est dj dans la pile (erreur dans le paramtrage)
			for ( $j = 0; ( !$err && ($j < count($stack)) ); $j++ ) $err = ( $cat_main[$cur_cat] == $stack[$j] );
			// corriger la catgorie parente en cas d'erreur
			if ( $err ) $cat_main[$cur_cat] = 0;
			// empiler la valeur du parent
			$stack[] = $cat_main[$cur_cat];
			// remonter d'un niveau
			$root = ($cat_main[$cur_cat] == 0);
			$cur_cat = $cat_main[$cur_cat];
			// signaler qu'il y avait une erreur de paramtrage qui a t corrige
			if ( $err ) $res = true;
		}  // while ( !$root )
		// mettre  niveau la bdd
		$sql = "update " . CATEGORIES_TABLE . " set cat_main = " . $cat_main[$i] . " where cat_id = $i";
		if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't update list of Categories", "", __LINE__, __FILE__, $sql);
	}  // end for ($i=0; $i <= $last_cat_id; $i++) if ( isset($cat_main[$i]) )
	return $res;
}  // end
//
// get daughter cat per level
function admin_get_cat_list($cat_main, &$cat_row, $level=0, $cat_except=-1)
{
	global $db;

	// lire les catgories filles
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_main = $cat_main order by cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) ) $rowlevel[] = $row;
	// empiler ces catgories filles et chercher leurs petites-filles
	for ($i = 0; $i < count($rowlevel); $i++ )
	{
		if ( $rowlevel[$i]['cat_id'] != $cat_except )
		{
			$rowlevel[$i]['level'] = $level;
			$cat_row[] = $rowlevel[$i];
			admin_get_cat_list( $rowlevel[$i]['cat_id'], $cat_row, ($level+1), $cat_except );
		}
	}
}
//
// renumber
function admin_renum_cat()
{
	global $db;

	// fix the param
	$err = admin_check_cat();
	// lire les catgories " plat"
	$cat_row = array();
	admin_get_cat_list(0, $cat_row);
	// renum
	for ($i=0; $i < count($cat_row); $i++) 
	{
		// get the order number
		$cat_row[$i]['cat_order'] = ($i+1)*10;
		// update db
		$sql = "update " . CATEGORIES_TABLE . " set cat_order = " . $cat_row[$i]['cat_order'] . 
					" where cat_id = " . $cat_row[$i]['cat_id'];
		if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't update list of Categories", "", __LINE__, __FILE__, $sql);
	}
	return $err;
}
//-- add v 1.0.8
//
// move a cat
function admin_move_cat($cat_id, $inc)
{
	global $db;
	//
	// fix the param
	admin_renum_cat();
	//
	// read the cat
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_id = $cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	if ( !$row = $db->sql_fetchrow($result) ) message_die(GENERAL_ERROR, "Couldn't access Categorie $cat_id", "", __LINE__, __FILE__, $sql);
	//
	// get cat main id and order
	$cat_main  = $row['cat_main'];
	$cat_order = $row['cat_order'];
	//
	// get the prec or next cat
	$sql  = "SELECT * FROM "  . CATEGORIES_TABLE . " WHERE cat_main = $cat_main AND ";
	$sql .= ( $inc < 0 ) ? "cat_order < $cat_order ORDER BY cat_order DESC" : "cat_order > $cat_order ORDER BY cat_order ASC";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories on the same level", "", __LINE__, __FILE__, $sql);
	//
	// first or last of the main category
	if ( !$row = $db->sql_fetchrow($result) ) return false;
	//
	// get a new order
	$new_order = ( $inc < 0 ) ? $row['cat_order'] - 5 : $row['cat_order'] + 5;
	//
	// update db
	$sql = "update " . CATEGORIES_TABLE . " set cat_order = $new_order where cat_id = $cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't update Categories order", "", __LINE__, __FILE__, $sql);
}
//-- add v 1.0.9
function admin_get_list($mode, $id, $select, $with_index=false)
{
	global $lang;

	if ($mode == 'forum') return get_list($mode, $id, $select);

	$row = array();
	admin_get_cat_list( 0, $row, NULL, ( ($select == 0) ? $id : NULL ) );

	$cat_list = "";

	// add Index
	if ($with_index)
	{
		$s = "";
		if ($id == 0) $s = ' selected="selected"';
		$cat_list .= '<option value="0"' . $s . '>' . $lang['Forum_index'] . '</option>\n';
	}

	// add other categories except the current one
	for ($i=0; $i < count($row); $i++ ) if ( ($select != 0) || ($row[$i]['cat_id'] != $id) )
	{
		$s = "";
		if ($row[$i]['cat_id'] == $id) $s = ' selected="selected"';
		$inc = '';
		for ($j=1; $j < $row[$i]['level']; $j++) $inc = '|&nbsp;&nbsp;&nbsp;' . $inc;
		if ( $with_index ) $inc = ( ($row[$i]['level'] > 0) ? '|&nbsp;&nbsp;&nbsp;' : '|--&nbsp;' ) . $inc;
		$inc .= ($row[$i]['level'] > 0) ? '|--&nbsp;' : '';
		$cat_list .= '<option value="' . $row[$i]['cat_id'] . '"' . $s . '>' . $inc . $row[$i]['cat_title'] . '</option>\n';
	}

	return $cat_list;
}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add

// check the presence of the attachment of the forum
$sql = "SELECT main_type FROM " . FORUMS_TABLE;
if ( $db->sql_query($sql) )
{
	define('SUB_FORUM_ATTACH', true);
}

// get the ids
$cat_id = 0;
if (isset($HTTP_POST_VARS[POST_CAT_URL]) || isset($HTTP_GET_VARS[POST_CAT_URL]))
{
	$cat_id = isset($HTTP_POST_VARS[POST_CAT_URL]) ? intval($HTTP_POST_VARS[POST_CAT_URL]) : intval($HTTP_GET_VARS[POST_CAT_URL]);
}

$forum_id = 0;
if (isset($HTTP_POST_VARS[POST_FORUM_URL]) || isset($HTTP_GET_VARS[POST_FORUM_URL]))
{
	$forum_id = isset($HTTP_POST_VARS[POST_FORUM_URL]) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
}

// check and fix parm
function admin_check_cat()
{
	global $db;

	$res = false;
	// build the cat list
	$mains = array();

	// from cats
	$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) ) 
	{
		// fix cat_main value
		if (empty($row['cat_main_type'])) 
		{
			$row['cat_main_type'] = POST_CAT_URL;
		}
		if ( $row['cat_main'] == $row['cat_id'] )
		{
			$row['cat_main_type'] = POST_CAT_URL;
			$row['cat_main'] = 0;
		}
		// fill hierarchy array
		$mains[ POST_CAT_URL . $row['cat_id'] ] = $row['cat_main_type'] . $row['cat_main'];
	}  // end while ( $row = $db->sql_fetchrow($result) )

	// from forums
	$sql = "SELECT * FROM " . FORUMS_TABLE . " ORDER BY forum_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Forums", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) ) 
	{
		// fill hierarchy array
		if (empty($row['main_type'])) $row['main_type'] = POST_CAT_URL;
		$mains[POST_FORUM_URL . $row['forum_id'] ] = $row['main_type'] . $row['cat_id'];
	}  // end while ( $row = $db->sql_fetchrow($result) )

	// no forums nor cats
	if (empty($mains)) return false;

	// push each cat
	reset($mains);
	while (list($id, $main) = each($mains) )
	{
		$root		= false;
		$cur		= $id;

		$stack		= array();
		$stack[]	= $cur;
		$error		= false;
		while ( !$root )
		{
			// parent catagory doesn't exists
			if ( ($mains[$cur] != 'c0' ) && !isset($mains[ $mains[$cur] ]) )
			{
				$error = true;
				$mains[$cur] = 'c0';
			}

			// the parent category is already in the stack (recursive attachement)
			if ( in_array($mains[$cur], $stack) )
			{
				$error = true;
				$mains[$cur] = 'c0';
			}

			// push parent category id
			$stack[] = $mains[$cur];

			// climb up a level
			$root = ($mains[$cur] == 'c0');
			$cur = $mains[$cur];

		}  // while ( !$root )

		// update database
		$type		= substr($id, 0, 1);
		$i			= intval(substr($id, 1));
		$main_type	= substr($mains[$id], 0, 1);
		$main_id	= intval(substr($mains[$id], 1));
		if ( $i != 0)
		{
			switch( $type )
			{
				case POST_CAT_URL:
					$sql = "UPDATE " . CATEGORIES_TABLE . " SET cat_main_type='$main_type', cat_main=$main_id WHERE cat_id=$i";
					if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't update list of Categories", "", __LINE__, __FILE__, $sql);
					break;
				case POST_FORUM_URL:
					$sql = "UPDATE " . FORUMS_TABLE . " SET cat_id=$main_id WHERE forum_id=$i";
					if (defined('SUB_FORUM_ATTACH'))
					{
						$sql = "UPDATE " . FORUMS_TABLE . " SET main_type='$main_type, cat_id=$main_id' WHERE forum_id=$i";
					}
					if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't update list of Forums", "", __LINE__, __FILE__, $sql);
					break;
				default:
					$sql = '';
					break;
			}
		}
	}
	return $error;
}  // end

function move_tree($type, $id, $move)
{
	global $db;
	global $tree;

	// search the object
	$this = (isset($tree['keys'][ $type . $id ])) ? $tree['keys'][ $type . $id ] : -1;

	// get the root id
	$main = ($this < 0) ? 'Root' : $tree['main'][$this];

	// renum objects of the same level and regenerate all
	$cats = array();
	$forums = array();
	$order = 0;
	for ($i=0; $i < count($tree['data']); $i++) 
	{
		if ($tree['main'][$i] == $main)
		{
			$order = $order + 10;
			$worder = ($i == $this) ? $order + $move : $order;
			$field_name = ($tree['type'][$i] == POST_CAT_URL) ? 'cat_order' : 'forum_order';
			$tree['data'][$i][$field_name] = $worder;
		}
		if ($tree['type'][$i] == POST_CAT_URL)
		{
			$cats[] = $tree['data'][$i];
		}
		else
		{
			$forums[] = $tree['data'][$i];
		}
	}

	// build the tree
	$tree = array();
	$new_topic_data = array();
	$tracking_topics = array();
	$tracking_forums = array();
	$tracking_all = -1;
	build_tree($cats, $forums, $new_topic_data, $tracking_topic, $tracking_forums, $tracking_all);

	// re-order all
	$order = 0;
	for ($i=0; $i < count($tree['data']); $i++)
	{
		$order = $order + 10;
		if ($tree['type'][$i] == POST_CAT_URL)
		{
			$sql = "UPDATE " . CATEGORIES_TABLE . " SET cat_order=$order WHERE cat_id=" . $tree['id'][$i];
		}
		else
		{
			$sql = "UPDATE " . FORUMS_TABLE . " SET forum_order=$order WHERE forum_id=" . $tree['id'][$i];
		}
		if ( !$db->sql_query($sql) ) message_die(GENERAL_ERROR, 'Couldn\'t update cat/forum order', '', __LINE__, __FILE__, $sql);
	}
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$forumname = stripslashes($HTTP_POST_VARS['forumname'][$cat_id]);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$forumname = stripslashes($HTTP_POST_VARS['forumname'][$cat_id]);
//-- add
		$forumname = stripslashes($HTTP_POST_VARS['name'][$cat_id]);
	}
	
	if( $mode == "addcat" )
	{
		list($cat_id) = each($HTTP_POST_VARS['addcategory']);
		$cat_title = stripslashes($HTTP_POST_VARS['name'][$cat_id]);
		$cat_main = $cat_id;
		$cat_id = -1;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
if( !empty($mode) ) 
{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	admin_check_cat();
	get_user_tree($userdata);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				//
				// start forum prune stuff.
				//
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				$main_type = $row['main_type'];
				if (!defined('SUB_FORUM_ATTACH'))
				{
					if (empty($main_type)) $main_type = POST_CAT_URL;
				}
				$forum_link				= $row['forum_link'];
				$forum_link_internal	= intval($row['forum_link_internal']);
				$forum_link_hit_count	= intval($row['forum_link_hit_count']);
				$forum_link_hit			= intval($row['forum_link_hit']);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			}

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$catlist = get_list('category', $cat_id, TRUE);
//-- add v 1.0.9
			$catlist = admin_get_list('category', $cat_id, TRUE);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			}
//
//			$catlist = get_list('category', $cat_id, TRUE);
//-- add
				$main_type = POST_CAT_URL;
				$prune_enabled = '';
				$forum_link				= '';
				$forum_link_internal	= 0;
				$forum_link_hit_count	= 0;
				$forum_link_hit			= 0;
			}
			$catlist = get_tree_option( $main_type . $cat_id, true );
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				'PRUNE_DAYS' => ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7,
				'PRUNE_FREQ' => ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				'L_LINK'							=> $lang['Forum_link'],
				'L_FORUM_LINK'						=> $lang['Forum_link_url'],
				'L_FORUM_LINK_EXPLAIN'				=> $lang['Forum_link_url_explain'],
				'FORUM_LINK'						=> $forum_link,
				'L_FORUM_LINK_INTERNAL'				=> $lang['Forum_link_internal'],
				'L_FORUM_LINK_INTERNAL_EXPLAIN'		=> $lang['Forum_link_internal_explain'],
				'FORUM_LINK_INTERNAL_YES'			=> ( $forum_link_internal) ? ' checked="checked"' : '',
				'FORUM_LINK_INTERNAL_NO'			=> (!$forum_link_internal) ? ' checked="checked"' : '',
				'L_FORUM_LINK_HIT_COUNT'			=> $lang['Forum_link_hit_count'],
				'L_FORUM_LINK_HIT_COUNT_EXPLAIN'	=> $lang['Forum_link_hit_count_explain'],
				'FORUM_LINK_HIT_COUNT_YES'			=> ( $forum_link_hit_count) ? ' checked="checked"' : '',
				'FORUM_LINK_HIT_COUNT_NO'			=> (!$forum_link_hit_count) ? ' checked="checked"' : '',
				'L_YES'								=> $lang['Yes'],
				'L_NO'								=> $lang['No'],
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				message_die(GENERAL_ERROR, "Can't create a forum without a name");
			}

			$sql = "SELECT MAX(forum_order) AS max_order
				FROM " . FORUMS_TABLE . "
				WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql);
			}
			$row = $db->sql_fetchrow($result);

			$max_order = $row['max_order'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				message_die(GENERAL_ERROR, "Can't create a forum without a name");
//			}
//
//			$sql = "SELECT MAX(forum_order) AS max_order
//				FROM " . FORUMS_TABLE . "
//				WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
//			if( !$result = $db->sql_query($sql) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql);
//			}
//			$row = $db->sql_fetchrow($result);
//
//			$max_order = $row['max_order'];
//-- add
				message_die(GENERAL_ERROR, $lang['Forum_name_missing']);
			}

			// get ids
			$fid = $HTTP_POST_VARS[POST_CAT_URL];
			$type = substr($fid, 0, 1);
			$id = intval(substr($fid, 1));
			if ($fid == 'Root')
			{
				$id = 0;
				$type = POST_CAT_URL;
				if (!defined('SUB_FORUM_ATTACH'))
				{
					message_die(GENERAL_ERROR, $lang['Attach_root_wrong']);
				}
			}
			if ($type != POST_CAT_URL)
			{
				if (!defined('SUB_FORUM_ATTACH'))
				{
					message_die(GENERAL_ERROR, $lang['Attach_forum_wrong']);
				}
				if ($type == POST_FORUM_URL)
				{
					$this = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this]['forum_link']))
					{
						message_die(GENERAL_ERROR, $lang['Forum_attached_to_link_denied']);
					}
				}
			}
			$cat_id = $id;

			// get the last order
			$max_order = 0;
			$last = count($tree['data'])-1;
			if ($last >= 0) 
			{
				$max_order = ($tree['type'][$last] == POST_CAT_URL) ? $tree['data'][$last]['cat_order'] : $tree['data'][$last]['forum_order'];
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			// There is no problem having duplicate forum names so we won't check for it.
			$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
				VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql);
			}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			if (defined('SUB_FORUM_ATTACH'))
			{
				$field_sql .= ", main_type";
				$value_sql .= ", '$type'";
			}
			$forum_link				= isset($HTTP_POST_VARS['forum_link']) ? trim(stripslashes($HTTP_POST_VARS['forum_link'])) : '';
			$forum_link_internal	= isset($HTTP_POST_VARS['forum_link_internal']) ? intval($HTTP_POST_VARS['forum_link_internal']) : 0;
			$forum_link_hit_count	= isset($HTTP_POST_VARS['forum_link_hit_count']) ? intval($HTTP_POST_VARS['forum_link_hit_count']) : 0;
			$field_sql .= ", forum_link";
			$value_sql .= ", '$forum_link'";
			$field_sql .= ", forum_link_internal";
			$value_sql .= ", $forum_link_internal";
			$field_sql .= ", forum_link_hit_count";
			$value_sql .= ", $forum_link_hit_count";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
//-- mod : categories hierarchy --------------------------------------------------------------------
// here we replaced
//	" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
// with
//	$cat_id
//-- modify
			$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
				VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', $cat_id, '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql);
			}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			admin_check_cat();
			get_user_tree($userdata);
			move_tree('Root', 0, 0);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'modforum':
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			if( trim($HTTP_POST_VARS['forumname']) == "" )
			{
				message_die(GENERAL_ERROR, $lang['Forum_name_missing']);
			}

			$fid = $HTTP_POST_VARS[POST_CAT_URL];
			$type = substr($fid, 0, 1);
			$id = intval(substr($fid, 1));
			if ($fid == 'Root')
			{
				$id = 0;
				$type = POST_CAT_URL;
				if (!defined('SUB_FORUM_ATTACH'))
				{
					message_die(GENERAL_ERROR, $lang['Attach_root_wrong']);
				}
			}
			if ($type != POST_CAT_URL)
			{
				if (!defined('SUB_FORUM_ATTACH'))
				{
					message_die(GENERAL_ERROR, $lang['Attach_forum_wrong']);
				}
				if ($type == POST_FORUM_URL)
				{
					$this = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this]['forum_link']))
					{
						message_die(GENERAL_ERROR, $lang['Forum_attached_to_link_denied']);
					}
				}
			}
			$cat_id = $id;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
					$HTTP_POST_VARS['prune_enable'] = 0;
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$field_value_sql = '';
			$forum_link				= isset($HTTP_POST_VARS['forum_link']) ? trim(stripslashes($HTTP_POST_VARS['forum_link'])) : '';
			$forum_link_internal	= isset($HTTP_POST_VARS['forum_link_internal']) ? intval($HTTP_POST_VARS['forum_link_internal']) : 0;
			$forum_link_hit_count	= isset($HTTP_POST_VARS['forum_link_hit_count']) ? intval($HTTP_POST_VARS['forum_link_hit_count']) : 0;

			// check if link nothing is attached to the forum
			if (!empty($forum_link))
			{
				// forum_id
				$forum_id = intval($HTTP_POST_VARS[POST_FORUM_URL]);

				// search in tree if something is attached to
				if (isset($tree['sub'][POST_FORUM_URL . $forum_id]))
				{
					message_die(GENERAL_MESSAGE, $lang['Forum_link_with_attachment_deny']);
				}

				// is there some topics attached to ?
				$sql = "SELECT * FROM " . TOPICS_TABLE . " WHERE forum_id=$forum_id";
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'Couldn\'t access topics table', '', __LINE__, __FILE__, $sql);
				}
				if ($row = $db->sql_fetchrow($result))
				{
					message_die(GENERAL_MESSAGE, $lang['Forum_link_with_topics_deny']);
				}
			}

			$field_value_sql .= ", forum_link='$forum_link'";
			$field_value_sql .= ", forum_link_internal=$forum_link_internal";
			$field_value_sql .= ", forum_link_hit_count=$forum_link_hit_count";
			if (defined('SUB_FORUM_ATTACH'))
			{
				$field_value_sql .= ", main_type = '$type'";
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------

//-- mod : categories hierarchy --------------------------------------------------------------------
// here we replaced
//	" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
// with
//	$cat_id
//
// and added
//	. $field_value_sql
//--- modify
#
#-----[ FIND ]------------------------------------------------
#
			$sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
				WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			$sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = $cat_id, forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . $field_value_sql . "
				WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'addcat':
			// Create a category in the DB
			if( trim($HTTP_POST_VARS['categoryname']) == '')
			{
				message_die(GENERAL_ERROR, "Can't create a category without a name");
			}

			$sql = "SELECT MAX(cat_order) AS max_order
				FROM " . CATEGORIES_TABLE;
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't get order number from categories table", "", __LINE__, __FILE__, $sql);
			}
			$row = $db->sql_fetchrow($result);

			$max_order = $row['max_order'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		case 'addcat':
//			// Create a category in the DB
//			if( trim($HTTP_POST_VARS['categoryname']) == '')
//			{
//				message_die(GENERAL_ERROR, "Can't create a category without a name");
//			}
//
//			$sql = "SELECT MAX(cat_order) AS max_order
//				FROM " . CATEGORIES_TABLE;
//			if( !$result = $db->sql_query($sql) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't get order number from categories table", "", __LINE__, __FILE__, $sql);
//			}
//			$row = $db->sql_fetchrow($result);
//
//			$max_order = $row['max_order'];
//-- add
		case 'createcat':
			// Create a category in the DB
			if( trim($HTTP_POST_VARS['cat_title']) == '')
			{
				message_die(GENERAL_ERROR, $lang['Category_name_missing']);
			}
			$main = $HTTP_POST_VARS['cat_main'];
			if ($main == 'Root')
			{
				$cat_main_type = POST_CAT_URL;
				$cat_main = 0;
			}
			else
			{
				$cat_main_type = substr($main, 0, 1);
				$cat_main = intval(substr($main, 1));
			}
			if ($cat_main_type == POST_FORUM_URL)
			{
				$this = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this]['forum_link']))
				{
					message_die(GENERAL_ERROR, $lang['Forum_attached_to_link_denied']);
				}
			}

			// get the last order
			$max_order = 0;
			$last = count($tree['data'])-1;
			if ($last >= 0) 
			{
				$max_order = ($tree['type'][$last] == POST_CAT_URL) ? $tree['data'][$last]['cat_order'] : $tree['data'][$last]['forum_order'];
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $next_order)";
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in categories table", "", __LINE__, __FILE__, $sql);
			}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
//				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $next_order)";
//-- add
			$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_main_type, cat_main, cat_desc, cat_order)
				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', '" . $cat_main_type . "', " . $cat_main . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "', $next_order)";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in categories table", "", __LINE__, __FILE__, $sql);
			}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			admin_check_cat();
			get_user_tree($userdata);
			move_tree('Root', 0, 0);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'editcat':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		case 'addcat':
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			//
			// Show form to edit a category
			//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			if ($mode == 'editcat')
			{
				$l_title = $lang['Edit_Category'];
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
			//-- v 1.0.5
			$cat_desc  = $row['cat_desc'];
			//--
			$cat_main  = $row['cat_main'];
			if ($cat_main <= 0) $cat_main = 0;
//-- add v 1.0.9
			$catlist = admin_get_list('category', $cat_main, TRUE, true);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				$cat_desc	= $row['cat_desc'];
				$cat_main	= $row['cat_main'];
				$cat_main_type = $row['cat_main_type'];
				if ($cat_main <= 0)
				{
					$cat_main = 0;
					$cat_main_type = POST_CAT_URL;
				}
			}
			else
			{
				$l_title = $lang['Create_category'];
				$newmode = 'createcat';
				$buttonvalue = $lang['Create_category'];

				$cat_desc  = '';
				$cat_main_type = POST_CAT_URL;
				if ($cat_main <= 0)
				{
					$cat_main = 0;
				}
			}

			// get the list of cats/forums
			$catlist = get_tree_option($cat_main_type . $cat_main, true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add
				//-- v 1.0.5
				'L_CAT_DESCRIPTION' => $lang['Category_desc'],
				'CAT_DESCRIPTION' => $cat_desc,
				//--
				'S_CAT_LIST' => $catlist,
				'L_CATEGORY_ATTACHMENT' => $lang['Category_attachment'],
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
				'CAT_TITLE' => $cat_title,

				'L_EDIT_CATEGORY' => $lang['Edit_Category'], 
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				'CAT_TITLE' => $cat_title,

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				'L_EDIT_CATEGORY' => $lang['Edit_Category'],
//-- add
				'L_CAT_DESCRIPTION'			=> $lang['Category_desc'],
				'CAT_DESCRIPTION'			=> $cat_desc,
				'S_CAT_LIST'				=> $catlist,
				'L_CATEGORY_ATTACHMENT'		=> $lang['Category_attachment'],

				'L_EDIT_CATEGORY'			=> $l_title,
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$sql = "UPDATE " . CATEGORIES_TABLE . "
//				SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "'
//				WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
//-- add
			//-- v 1.0.5
			$sql = "UPDATE " . CATEGORIES_TABLE . "
				SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', cat_main = ".intval($HTTP_POST_VARS['cat_main']). ", cat_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "' ".
				" WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql);
			}

			$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
			$err = admin_renum_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			if( trim($HTTP_POST_VARS['cat_title']) == '')
			{
				message_die(GENERAL_ERROR, $lang['Category_name_missing']);
			}
			$main = $HTTP_POST_VARS['cat_main'];
			if ($main == 'Root')
			{
				$cat_main_type = POST_CAT_URL;
				$cat_main = 0;
			}
			else
			{
				$cat_main_type = substr($main, 0, 1);
				$cat_main = intval(substr($main, 1));
			}
			if ($cat_main_type == POST_FORUM_URL)
			{
				$this = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this]['forum_link']))
				{
					message_die(GENERAL_ERROR, $lang['Forum_attached_to_link_denied']);
				}
			}

			// update db
//-- fin mod : categories hierarchy ----------------------------------------------------------------

//-- mod : categories hierarchy --------------------------------------------------------------------
// here we added
//	, cat_main_type='" . $cat_main_type . "', cat_main = " . $cat_main . ", cat_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "' ".
//-- modify
			$sql = "UPDATE " . CATEGORIES_TABLE . "
				SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', cat_main_type='" . $cat_main_type . "', cat_main = " . $cat_main . ", cat_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "'
				WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql);
			}

			$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$err = admin_check_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$select_to .= get_list('forum', $forum_id, 0);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$select_to .= get_list('forum', $forum_id, 0);
//-- add
			$select_to .= '<option value=""></option>';
			$select_to .= get_tree_option('', true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$foruminfo = get_info('forum', $forum_id);
			$name = $foruminfo['forum_name'];
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$foruminfo = get_info('forum', $forum_id);
//			$name = $foruminfo['forum_name'];
//-- add
			$this = $tree['keys'][POST_FORUM_URL . $forum_id];
			$name = $tree['data'][$this]['forum_name'];
			$desc = $tree['data'][$this]['forum_desc'];

			$name_trad = get_object_lang(POST_FORUM_URL . $forum_id, 'name');
			$desc_trad = get_object_lang(POST_FORUM_URL . $forum_id, 'desc');
			if ($name != $name_trad) $name = '(' . $name . ') ' . $name_trad;
			if ($desc != $desc_trad) $desc = '(' . $desc . ') ' . $desc_trad;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$template->pparse("body");
			break;

		case 'movedelforum':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$template->assign_vars(array(
				'DESC'			=> $desc,
				'L_FORUM_DESC'	=> $lang['Forum_desc'],
				)
			);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			//
			// Move or delete a forum in the DB
			//
			$from_id = intval($HTTP_POST_VARS['from_id']);
			$to_id = intval($HTTP_POST_VARS['to_id']);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			//
			// Move or delete a forum in the DB
			//
			$from_id = intval($HTTP_POST_VARS['from_id']); 
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$to_id = intval($HTTP_POST_VARS['to_id']);
//-- add
			$to_fid = $HTTP_POST_VARS['to_id'];
			if (intval($to_fid) == -1)
			{
				$to_type = '';
				$to_id = -1;
			}
			else
			{
				$to_type	= substr($to_fid, 0, 1);
				$to_id		= intval(substr($to_fid, 1));
				if (($to_type != POST_FORUM_URL) || ($to_fid == 'Root'))
				{
					message_die(GENERAL_MESSAGE, $lang['Only_forum_for_topics']);
				}
			}

			// check if sub-levels present
			if (!empty($tree['sub'][POST_FORUM_URL. $from_id]))
			{
				message_die(GENERAL_MESSAGE, $lang['Delete_forum_with_attachment_denied']);
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$catinfo = get_info('category', $cat_id);
			$name = $catinfo['cat_title'];

			if ($catinfo['number'] == 1)
			{
				$sql = "SELECT count(*) as total
					FROM ". FORUMS_TABLE;
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't get Forum count", "", __LINE__, __FILE__, $sql);
				}
				$count = $db->sql_fetchrow($result);
				$count = $count['total'];

				if ($count > 0)
				{
					message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
				}
				else
				{
					$select_to = $lang['Nowhere_to_move'];
				}
			}
			else
			{
				$select_to = '<select name="to_id">';
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//				$select_to .= get_list('category', $cat_id, 0);
//-- add v 1.0.9
				$select_to .= admin_get_list('category', $cat_id, 0);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
				$select_to .= '</select>';
			}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$catinfo = get_info('category', $cat_id);
//			$name = $catinfo['cat_title'];
//
//			if ($catinfo['number'] == 1)
//			{
//				$sql = "SELECT count(*) as total
//					FROM ". FORUMS_TABLE;
//				if( !$result = $db->sql_query($sql) )
//				{
//					message_die(GENERAL_ERROR, "Couldn't get Forum count", "", __LINE__, __FILE__, $sql);
//				}
//				$count = $db->sql_fetchrow($result);
//				$count = $count['total'];
//
//				if ($count > 0)
//				{
//					message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
//				}
//				else
//				{
//					$select_to = $lang['Nowhere_to_move'];
//				}
//			}
//			else
//			{
//				$select_to = '<select name="to_id">';
//				$select_to .= get_list('category', $cat_id, 0);
//				$select_to .= '</select>';
//			}
//-- add
			$this = $tree['keys'][POST_CAT_URL . $cat_id];
			$name = $tree['data'][$this]['cat_title'];
			$desc = $tree['data'][$this]['cat_desc'];

			$name_trad = get_object_lang(POST_CAT_URL . $cat_id, 'name');
			$desc_trad = get_object_lang(POST_CAT_URL . $cat_id, 'desc');
			if ($name != $name_trad) $name = '(' . $name . ') ' . $name_trad;
			if ($desc != $desc_trad) $desc = '(' . $desc . ') ' . $desc_trad;

			// chek main category deletation
			if ($tree['main'][$this] == 'Root')
			{
				// check if other main categories
				$found = false;
				for ($i=0; (($i < count($tree['data'])) && !$found); $i++)
				{
					$found = (($i != $this) && ($tree['main'][$i] == 'Root'));
				}
				// no other main cats : check if forums presents
				if (!$found)
				{
					$found = false;
					for ($i=0; $i < count($tree['sub'][POST_CAT_URL . $from_id]); $i++)
					{
						$found = ($tree['type'][$tree['keys'][$tree['sub'][POST_CAT_URL . $cat_id][$i]]] == POST_FORUM_URL);
					}
					if ($found)
					{
						message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
					}
				}
			}
			
			// get cat list
			$s_cat_list = get_tree_option('', true);
			$select_to = '<select name="to_id">' . $s_cat_list . '</select>';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$template->set_filenames(array(
				"body" => "admin/forum_delete_body.tpl")
			);

			$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $cat_id . '" />';

			$template->assign_vars(array(
				'NAME' => $name, 

				'L_FORUM_DELETE' => $lang['Forum_delete'], 
				'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'], 
				'L_MOVE_CONTENTS' => $lang['Move_contents'], 
				'L_FORUM_NAME' => $lang['Forum_name'], 
				
				'S_HIDDEN_FIELDS' => $s_hidden_fields,
				'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), 
				'S_SELECT_TO' => $select_to,
				'S_SUBMIT_VALUE' => $buttonvalue)
			);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			$template->set_filenames(array(
				"body" => "admin/forum_delete_body.tpl")
			);

			$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $cat_id . '" />';

			$template->assign_vars(array(
				'NAME' => $name, 

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				'L_FORUM_DELETE' => $lang['Forum_delete'], 
//				'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'], 
//-- add
				'L_FORUM_DELETE' => $lang['Category_delete'],
				'L_FORUM_DELETE_EXPLAIN' => $lang['Category_delete_explain'],
//-- fin mod : categories hierarchy ----------------------------------------------------------------
				'L_MOVE_CONTENTS' => $lang['Move_contents'], 
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				'L_FORUM_NAME' => $lang['Forum_name'], 
//-- add
				'L_FORUM_NAME' => $lang['Category'],
//-- fin mod : categories hierarchy ----------------------------------------------------------------
				
				'S_HIDDEN_FIELDS' => $s_hidden_fields,
				'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), 
				'S_SELECT_TO' => $select_to,
				'S_SUBMIT_VALUE' => $buttonvalue)
			);

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$template->assign_vars(array(
				'L_FORUM_DESC'	=> $lang['Category_desc'],
				'DESC'			=> $desc,
				)
			);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'movedelcat':
			//
			// Move or delete a category in the DB
			//
			$from_id = intval($HTTP_POST_VARS['from_id']);
			$to_id = intval($HTTP_POST_VARS['to_id']);

#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		case 'movedelcat':
			//
			// Move or delete a category in the DB
			//
			$from_id = intval($HTTP_POST_VARS['from_id']); 
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$to_id = intval($HTTP_POST_VARS['to_id']); 
//-- add
			$to_fid		= $HTTP_POST_VARS['to_id'];
			$to_type	= substr($to_fid, 0, 1);
			$to_id		= intval(substr($to_fid, 1));
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
					message_die(GENERAL_ERROR, "Ambiguous category ID's", "", __LINE__, __FILE__);
				}

				$sql = "UPDATE " . FORUMS_TABLE . "
					SET cat_id = $to_id
					WHERE cat_id = $from_id";
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
					message_die(GENERAL_ERROR, "Ambiguous category ID's", "", __LINE__, __FILE__);
				}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				// check that there is no forum attached to the from cat (will issue to forum attached to forums)
				if (($to_type == POST_FORUM_URL) && !defined('SUB_FORUM_ATTACH'))
				{
					$found = false;
					for ($i=0; $i < count($tree['sub'][POST_CAT_URL . $from_id]); $i++)
					{
						$found = ($tree['type'][$tree['keys'][$tree['sub'][POST_CAT_URL . $from_id][$i]]] == POST_FORUM_URL);
					}
					if ($found)
					{
						message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
					}
				}

				$sql_feed = '';
				$sql_where = '';
				if (defined('SUB_FORUM_ATTACH'))
				{
					$sql_feed = ", main_type='$to_type'";
					$sql_where = " AND main_type='" . POST_CAT_URL . "'";
				}
//-- fin mod : categories hierarchy ----------------------------------------------------------------

//-- mod : categories hierarchy --------------------------------------------------------------------
// here we added
//	" . $sql_feed . "
// and
//	 . $sql_where
//-- modify
				$sql = "UPDATE " . FORUMS_TABLE . "
					SET cat_id = $to_id" . $sql_feed . "
					WHERE cat_id = $from_id" . $sql_where;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				}
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
				$sql = "UPDATE " . CATEGORIES_TABLE . "
					SET cat_main = $to_id
					WHERE cat_main = $from_id";
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't move sub-categories to other category", "", __LINE__, __FILE__, $sql);
				}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				}
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
			$err = admin_renum_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$err = admin_check_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'forum_order':
			//
			// Change order of forums in the DB
			//
			$move = intval($HTTP_GET_VARS['move']);
			$forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);

			$forum_info = get_info('forum', $forum_id);

			$cat_id = $forum_info['cat_id'];

			$sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_order = forum_order + $move
				WHERE forum_id = $forum_id";
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
			}

			renumber_order('forum', $forum_info['cat_id']);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		case 'forum_order':
			//
			// Change order of forums in the DB
			//
			$move = intval($HTTP_GET_VARS['move']);
			$forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$forum_info = get_info('forum', $forum_id);
//
//			$cat_id = $forum_info['cat_id'];
//
//			$sql = "UPDATE " . FORUMS_TABLE . "
//				SET forum_order = forum_order + $move
//				WHERE forum_id = $forum_id";
//			if( !$result = $db->sql_query($sql) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
//			}
//
//			renumber_order('forum', $forum_info['cat_id']);
//-- add
			// update the level order
			move_tree(POST_FORUM_URL, $forum_id, $move);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$sql = "UPDATE " . CATEGORIES_TABLE . "
//				SET cat_order = cat_order + $move
//				WHERE cat_id = $cat_id";
//			if( !$result = $db->sql_query($sql) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
//			}
//
//			renumber_order('category');
//-- add v 1.0.8
			admin_move_cat($cat_id, $move);
//-- add v 1.0.7
			admin_renum_cat();
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$sql = "UPDATE " . CATEGORIES_TABLE . "
//				SET cat_order = cat_order + $move
//				WHERE cat_id = $cat_id";
//			if( !$result = $db->sql_query($sql) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
//			}
//
//			renumber_order('category');
//-- add
			// update the level order
			move_tree(POST_CAT_URL, $cat_id, $move);

			// get ids
			$main	= $tree['main'][ $tree['keys'][POST_CAT_URL . $cat_id] ];
			$cat_id = $tree['id'][ $tree['keys'][$main] ];
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$template->set_filenames(array(
	"body" => "admin/forum_admin_body.tpl")
);

$template->assign_vars(array(
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	'L_ACTION' => $lang['Action'],
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
// $sql = "SELECT cat_id, cat_title, cat_order
//	FROM " . CATEGORIES_TABLE . "
//	ORDER BY cat_order";
//-- delete v 1.0.9
// if( !$q_categories = $db->sql_query($sql) )
// {
//	message_die(GENERAL_ERROR, "Could not query categories list", "", __LINE__, __FILE__, $sql);
// }
// if( $total_categories = $db->sql_numrows($q_categories) )
// {
//	$category_rows = $db->sql_fetchrowset($q_categories);
//-- add v 1.0.7
admin_renum_cat();
//-- add v 1.0.9
// get cats array
$category_rows = array();
admin_get_cat_list(0, $category_rows);
// get max inc level
$max_inc = 0;
for ($i=0; $i < count($category_rows); $i++)
{
	if ( $max_inc < $category_rows[$i]['level'] ) $max_inc = $category_rows[$i]['level'];
}
$template->assign_vars(array(
	'INC_SPAN' => ($max_inc+7),
	)
);

// display cats and forums
if( $total_categories = count($category_rows) )
{
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
/*

$sql = "SELECT cat_id, cat_title, cat_order
	FROM " . CATEGORIES_TABLE . "
	ORDER BY cat_order";
if( !$q_categories = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, "Could not query categories list", "", __LINE__, __FILE__, $sql);
}

if( $total_categories = $db->sql_numrows($q_categories) )
{
	$category_rows = $db->sql_fetchrowset($q_categories);
#
#-----[ FIND ]------------------------------------------------
#
		$cat_id = $category_rows[$i]['cat_id'];
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
		$class_catLeft   = "catLeft";
		$class_catMiddle = "cat";
		$class_catRight  = "catRight";
		if ( ($category_rows[$i]['cat_main'] == $cat_id) || ($category_rows[$i]['cat_main'] == 0) )
		{
			$class_catLeft   = "catRupt";
			$class_catMiddle = "catRupt";
			$class_catRight  = "catRupt";
		}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		$cat_id = $category_rows[$i]['cat_id'];
#
#-----[ FIND ]------------------------------------------------
#
			'CAT_DESC' => $category_rows[$i]['cat_title'],
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.7
			'CAT_DESCRIPTION' => $category_rows[$i]['cat_desc'],
			'CLASS_CATLEFT'   => $class_catLeft,
			'CLASS_CATMIDDLE' => $class_catMiddle,
			'CLASS_CATRIGHT'  => $class_catRight,
//-- add v 1.0.9
			'INC_SPAN' => $max_inc - $category_rows[$i]['level']+3,
			'INC_SPAN_ALL' => $max_inc - $category_rows[$i]['level']+7,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
			'CAT_DESC' => $category_rows[$i]['cat_title'],
#
#-----[ FIND ]------------------------------------------------
#
		);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
		for ($k=0; $k < $category_rows[$i]['level']; $k++) $template->assign_block_vars("catrow.inc", array());
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		);
#
#-----[ FIND ]------------------------------------------------
#
					'NUM_POSTS' => $forum_rows[$j]['forum_posts'],
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
					'INC_SPAN' => $max_inc - $category_rows[$i]['level']+1,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
					'NUM_POSTS' => $forum_rows[$j]['forum_posts'],
#
#-----[ FIND ]------------------------------------------------
#
				);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
				for ($k=0; $k < $category_rows[$i]['level']; $k++) $template->assign_block_vars("catrow.forumrow.inc", array());
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				);
#
#-----[ FIND ]------------------------------------------------
#
}// if ... total_categories
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- add
*/
function display_admin_index($cur='Root', $level=0, $max_level=-1)
{
	global $template, $phpEx, $lang, $images;
	global $tree;

	// display the level
	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;

	// root level
	if ($max_level==-1)
	{
		// get max inc level
		$keys = array();
		$max_level = get_max_depth($cur, true, -1, $keys);
		if ($cur != 'Root') $max_level++;
		$template->assign_vars(array(
			'INC_SPAN'		=> ($max_level+3),
			'INC_SPAN_ALL'	=> ($max_level+7),
			)
		);
	}

	// if forum index, omit one level
	if ($cur == 'Root') $level=-1;

	// sub-levels
	if ($this >= -1)
	{
		// cat header row
		if ($tree['type'][$this] == POST_CAT_URL)
		{
			// display a cat row
			$cat = $tree['data'][$this];
			$cat_id = $tree['id'][$this];

			// get the class colors
			$class_catLeft   = "cat";
			$class_catMiddle = "cat";
			$class_catRight  = "cat";

			$cat_title = $cat['cat_title'];
			$cat_title_trad = get_object_lang(POST_CAT_URL . $cat_id, 'name');
			if ($cat_title != $cat_title_trad) $cat_title = '(' . $cat_title . ') ' . $cat_title_trad;

			// send to template
			$template->assign_block_vars('catrow', array());
			$template->assign_block_vars('catrow.cathead', array(
				'CAT_ID'			=> $cat_id,
				'CAT_TITLE'			=> $cat_title,

				'CLASS_CATLEFT'		=> $class_catLeft,
				'CLASS_CATMIDDLE'	=> $class_catMiddle,
				'CLASS_CATRIGHT'	=> $class_catRight,
				'INC_SPAN'			=> $max_level - $level+3,
				'WIDTH'				=> ($max_level == $level) ? 'width="50%"' : '',

				'U_CAT_EDIT'		=> append_sid("admin_forums.$phpEx?mode=editcat&amp;" . POST_CAT_URL . "=$cat_id"),
				'U_CAT_DELETE'		=> append_sid("admin_forums.$phpEx?mode=deletecat&amp;" . POST_CAT_URL . "=$cat_id"),
				'U_CAT_MOVE_UP'		=> append_sid("admin_forums.$phpEx?mode=cat_order&amp;move=-15&amp;" . POST_CAT_URL . "=$cat_id"),
				'U_CAT_MOVE_DOWN'	=> append_sid("admin_forums.$phpEx?mode=cat_order&amp;move=15&amp;" . POST_CAT_URL . "=$cat_id"),
				'U_VIEWCAT'			=> append_sid("admin_forums.$phpEx?" . POST_CAT_URL . "=$cat_id"))
			);
			// add indentation to the display
			$rowspan = empty($cat['cat_desc']) ? 1 : 2;
			for ($k=1; $k <= $level; $k++) $template->assign_block_vars('catrow.cathead.inc', array('ROWSPAN' => $rowspan));

			if (!empty($cat['cat_desc']))
			{
				$cat_desc = $cat['cat_desc'];
				$cat_desc_trad = get_object_lang(POST_CAT_URL . $cat_id, 'desc');
				if ($cat_desc != $cat_desc_trad) $cat_desc = '(' . $cat_desc . ') ' . $cat_desc_trad;

				$template->assign_block_vars('catrow', array());
				$template->assign_block_vars('catrow.cattitle', array(
					'CAT_DESCRIPTION'	=> $cat_desc,
					'INC_SPAN_ALL'		=> $max_level - $level+7,
					)
				);
			}
		}

		// forum header row
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$forum = $tree['data'][$this];
			$forum_id = $tree['id'][$this];
			$forum_link_img = '';
			if (!empty($tree['data'][$this]['forum_link']))
			{
				$forum_link_img = '<img src="../' . $images['link'] . '" border="0" />';
			}
			else
			{
				$sub = (isset($tree['sub'][POST_FORUM_URL . $forum_id]));
				$forum_link_img = '<img src="../' . (($sub) ? $images['category'] : $images['forum']) . '" border="0" />';
				if ($tree['data'][$this]['forum_status'] == FORUM_LOCKED)
				{
					$forum_link_img = '<img src="../' . (($sub) ? $images['category_locked'] : $images['forum_locked']) . '" border="0" />';
				}
			}

			$forum_name = $forum['forum_name'];
			$forum_name_trad = get_object_lang(POST_FORUM_URL . $forum_id, 'name');
			if ($forum_name != $forum_name_trad) $forum_name = '(' . $forum_name . ') ' . $forum_name_trad;

			$forum_desc = $forum['forum_desc'];
			$forum_desc_trad = get_object_lang(POST_FORUM_URL . $forum_id, 'desc');
			if ($forum_desc != $forum_desc_trad) $forum_desc = '(' . $forum_desc . ') ' . $forum_desc_trad;
			$template->assign_block_vars('catrow', array());
			$template->assign_block_vars('catrow.forumrow', array(
				'LINK_IMG'			=> $forum_link_img,
				'FORUM_NAME'		=> $forum_name,
				'FORUM_DESC'		=> $forum_desc,
				'NUM_TOPICS'		=> $forum['forum_topics'],
				'NUM_POSTS'			=> $forum['forum_posts'],

				'INC_SPAN'			=> $max_level - $level+1,
				'WIDTH'				=> ($max_level == $level) ? 'width="50%"' : '',

				'U_VIEWFORUM'		=> append_sid("admin_forums.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
				'U_FORUM_EDIT'		=> append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=$forum_id"),
				'U_FORUM_DELETE'	=> append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" . POST_FORUM_URL . "=$forum_id"),
				'U_FORUM_MOVE_UP'	=> append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" . POST_FORUM_URL . "=$forum_id"),
				'U_FORUM_MOVE_DOWN'	=> append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" . POST_FORUM_URL . "=$forum_id"),
				'U_FORUM_RESYNC'	=> append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" . POST_FORUM_URL . "=$forum_id"))
			);
			// add indentation to the display
			for ($k=1; $k <= $level; $k++) $template->assign_block_vars('catrow.forumrow.inc', array());
		}

		// display the sub-level
		for ($i=0; $i < count($tree['sub'][$cur]); $i++)
		{
			display_admin_index($tree['sub'][$cur][$i], $level+1, $max_level);
		}

		// forum footer

		// cat footer
		if ($tree['type'][$this] == POST_CAT_URL)
		{
			// add the footer
			$template->assign_block_vars('catrow', array());
			$template->assign_block_vars('catrow.catfoot', array(
				'S_ADD_FORUM_SUBMIT'	=> "addforum[$cat_id]",
				'S_ADD_CAT_SUBMIT'		=> "addcategory[$cat_id]",
				'S_ADD_NAME'			=> "name[$cat_id]",
				'INC_SPAN'				=> $max_level - $level+3,
				'INC_SPAN_ALL'			=> $max_level - $level+7,
				)
			);
			// add indentation to the display
			for ($k=1; $k <= $level; $k++) $template->assign_block_vars('catrow.catfoot.inc', array());
		}

		// board index footer
		if ($cur == 'Root')
		{
			$template->assign_block_vars('switch_board_footer', array());
			if (defined('SUB_FORUM_ATTACH'))
			{
				$template->assign_block_vars('switch_board_footer.sub_forum_attach', array());
			}
		}
	}
}

// fix the cat_main value
admin_check_cat();

// read the cats/forums tree
get_user_tree($userdata);

// get the values of level selected
$main = 'Root';
if (!empty($cat_id))
{
	$main = POST_CAT_URL . $cat_id;
}
else if (!empty($forum_id))
{
	$main = $tree['main'][$forum_id];
	$main = $tree['main'][ $tree['keys'][POST_FORUM_URL . $forum_id] ];
}
if (!isset($tree['keys'][$main])) $main = 'Root';

// get the nav cat sentence
$nav_cat_desc = make_cat_nav_tree($main, 'admin_forums');
if ($nav_cat_desc != '') $nav_cat_desc = $nav_separator . $nav_cat_desc;
$template->assign_vars(array(
	'SPACER'			=> $images['spacer'],
	'NAV_CAT_DESC'		=> $nav_cat_desc,
	'L_INDEX'			=> sprintf($lang['Forum_Index'], $board_config['sitename']),
	)
);

// display the tree
display_admin_index($main);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ug_auth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
require('./pagestart.' . $phpEx);
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
include_once( $phpbb_root_path . 'includes/functions.' . $phpEx );
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
require('./pagestart.' . $phpEx);
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$sql = "SELECT * 
//				FROM " . FORUMS_TABLE . " f
//				ORDER BY forum_order";
//-- add v 1.0.7
			$sql = "SELECT f.*, c.cat_title, c.cat_main 
				FROM " . FORUMS_TABLE . " f, " .CATEGORIES_TABLE." as c 
				WHERE f.cat_id = c.cat_id 
				ORDER BY c.cat_order, f.forum_order";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
			}

			$forum_access = array();
			while( $row = $db->sql_fetchrow($result) )
			{
				$forum_access[] = $row;
			}
			$db->sql_freeresult($result);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$sql = "SELECT * 
//				FROM " . FORUMS_TABLE . " f
//				ORDER BY forum_order";
//			if ( !($result = $db->sql_query($sql)) )
//			{
//				message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
//			}
//
//			$forum_access = array();
//			while( $row = $db->sql_fetchrow($result) )
//			{
//				$forum_access[] = $row;
//			}
//			$db->sql_freeresult($result);
//-- add
			// get all sorted by level
			$keys = array();
			$keys = get_auth_keys('Root', true);
			$forum_access = array();

			// extract forums
			$forum_access = array();
			for ($i=0; $i < count($keys['id']); $i++)
			{
				if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
				{
					$forum_access[] = $tree['data'][ $keys['idx'][$i] ];
				}
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		$sql = "SELECT * 
//			FROM " . FORUMS_TABLE . " f
//			ORDER BY forum_order";
//-- add v 1.0.9
	// get cat ids
	$catids = array();
	$sql = "select * from " . CATEGORIES_TABLE;
	if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Couldn't obtain cats information", "", __LINE__, __FILE__, $sql);
	while( $row = $db->sql_fetchrow($result) ) $catids[] = $row['cat_id'];

	// get cats array sorted, with level
	$catrows = array();
	get_auth_cat_order( $catrows, $catids );

	// create a keyed by cat_id array
	$categories = array();
	$inc_max = 0;
	for ($i=0; $i < count($catrows); $i++)
	{
		$categories[ $catrows[$i]['cat_id'] ] = $catrows[$i];
		if ( $catrows[$i]['level'] > $inc_max ) $inc_max = $catrows[$i]['level'];
	}
//-- add v 1.0.7
	$sql = "SELECT f.*, c.cat_title, c.cat_main 
			FROM " . FORUMS_TABLE . " f, " .CATEGORIES_TABLE." as c 
			WHERE f.cat_id = c.cat_id 
			ORDER BY c.cat_order, f.forum_order";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
	}

	$forum_access = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_access[] = $row;
	}
	$db->sql_freeresult($result);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$sql = "SELECT * 
//		FROM " . FORUMS_TABLE . " f
//		ORDER BY forum_order";
//	if ( !($result = $db->sql_query($sql)) )
//	{
//		message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
//	}
//
//	$forum_access = array();
//	while( $row = $db->sql_fetchrow($result) )
//	{
//		$forum_access[] = $row;
//	}
//	$db->sql_freeresult($result);
//-- add
	// get all sorted by level
	$keys = array();
	$keys = get_auth_keys('Root', true);

	// get the maximum level
	$max_level = 0;
	for ($i=0; $i < count($keys['id']); $i++)
	{
		if ($keys['real_level'][$i] > $max_level) $max_level = $keys['real_level'][$i];
	}

	// extract forums
	$forum_access = array();
	for ($i=0; $i < count($keys['id']); $i++)
	{
		if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
		{
			$forum_access[] = $tree['data'][ $keys['idx'][$i] ];
		}
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#	
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete : fix 1.1.0
//	$i = 0;
//	@reset($auth_ug);
//	while( list($forum_id, $user_ary) = @each($auth_ug) )
//	{
//-- add v 1.0.9
	$s_column_span = 3 + $inc_max +1; // Two columns always present
	if( $adv ) $s_column_span = $s_column_span + count($forum_auth_fields)-1;
//-- add : fix 1.1.0
	@reset($categories);
	while ( list($cat_id, $catrow) = each($categories) )
	{
		// get the inc level
		$inc_col = $catrow['level'];
		$class_cat = "catLeft";
		if ( $catrow['cat_main'] == 0 ) $class_cat = "catRupt";

		$template->assign_block_vars('categorie', array(
			'CLASS_CAT' => $class_cat,
			'CAT_TITLE' => $catrow['cat_title'],
			'INC_SPAN' => $s_column_span - $inc_col,
			)
		);
		for ($k=1; $k <= $inc_col; $k++) $template->assign_block_vars('categorie.inc', array());

		for ($i=0; $i < count($forum_access); $i++) if ($forum_access[$i]['cat_id'] == $cat_id)
		{
			$forum_id = $forum_access[$i]['forum_id'];
			$user_ary = $auth_ug[$forum_id];
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#	
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//	$i = 0;
//	@reset($auth_ug);
//	while( list($forum_id, $user_ary) = @each($auth_ug) )
//	{
//-- add
	$s_column_span = 2 + $max_level; // Two columns always present
	if( $adv ) $s_column_span = $s_column_span + count($forum_auth_fields)-1;

	// read the objects without the index forum (i=0)
	for ($i=1; $i < count($keys['id']); $i++)
	{
		$this	= $keys['idx'][$i];
		$level	= $keys['real_level'][$i];
		if ($tree['type'][$this] == POST_CAT_URL)
		{
			$class_cat = "cat";
			$template->assign_block_vars('row', array());
			$template->assign_block_vars('row.cathead', array(
				'CLASS_CAT' => $class_cat,
				'CAT_TITLE' => get_object_lang( $tree['type'][$this] . $tree['id'][$this], 'name'),
				'INC_SPAN'	=> $max_level - $level+1,
				)
			);
			for ($k=1; $k <= $level; $k++) $template->assign_block_vars('row.cathead.inc', array());
			if ($adv)
			{
				for ($j=0; $j < count($forum_auth_fields); $j++)
				{
					$template->assign_block_vars('row.cathead.aclvalues', array());
				}
			}
			else
			{
				$template->assign_block_vars('row.cathead.aclvalues', array());
			}
		}

		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$forum_id = $tree['data'][ $keys['idx'][$i] ]['forum_id'];
			$user_ary = $auth_ug[$forum_id];
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		$template->assign_block_vars('forums', array(
//-- add v 1.0.9
		$template->assign_block_vars('categorie.forums', array(
			'INC_SPAN' => $inc_max - $inc_col +1,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$template->assign_block_vars('forums', array(
//-- add
		$template->assign_block_vars('row', array());
		$template->assign_block_vars('row.forums', array(
			'INC_SPAN' => $max_level - $level+1,
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			'FORUM_NAME' => $forum_access[$i]['forum_name'],

			'U_FORUM_AUTH' => append_sid("admin_forumauth.$phpEx?f=" . $forum_access[$i]['forum_id']),
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			'FORUM_NAME' => $forum_access[$i]['forum_name'],
//
//			'U_FORUM_AUTH' => append_sid("admin_forumauth.$phpEx?f=" . $forum_access[$i]['forum_id']),
//-- add
			'FORUM_NAME'	=> get_object_lang(POST_FORUM_URL . $tree['data'][ $keys['idx'][$i] ]['forum_id'], 'name'),
			'U_FORUM_AUTH'	=> append_sid("admin_forumauth.$phpEx?f=" . $tree['data'][ $keys['idx'][$i] ]['forum_id']),
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
		// get the inc level
		$inc_col = $categories[$forum_access[$i]['cat_id']]['level'];
		for ($k=0; $k <= $inc_col; $k++) $template->assign_block_vars('categorie.forums.inc', array());
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		for ($k=1; $k <= $level; $k++) $template->assign_block_vars('row.forums.inc', array());
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$template->assign_block_vars('forums.aclvalues', array(
//-- add
			$template->assign_block_vars('categorie.forums.aclvalues', array(
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

				'S_ACL_SELECT' => $optionlist_acl)
			);
		}
		else
		{
			for($j = 0; $j < count($forum_auth_fields); $j++)
			{

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//			$template->assign_block_vars('forums.aclvalues', array(
//-- add
			$template->assign_block_vars('categorie.forums.aclvalues', array(
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//			$template->assign_block_vars('forums.aclvalues', array(
//-- add
			$template->assign_block_vars('row.forums.aclvalues', array(
//-- fin mod : categories hierarchy ----------------------------------------------------------------
				'S_ACL_SELECT' => $optionlist_acl)
			);
		}
		else
		{
			for($j = 0; $j < count($forum_auth_fields); $j++)
			{
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//				$template->assign_block_vars('forums.aclvalues', array(
//-- add
				$template->assign_block_vars('row.forums.aclvalues', array(
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete : fix 1.1.0
//		$i++;
//-- add : fix 1.1.0
	}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$i++;
//-- add
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		'S_COLUMN_SPAN' => $s_column_span,
//-- add v 1.0.9
		'INC_SPAN' => $inc_max+2,
		'S_COLUMN_SPAN' => $s_column_span + $inc_max+1,
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		'S_COLUMN_SPAN' => $s_column_span,
//-- add
		'SPACER'		=> $images['spacer'],
		'INC_SPAN'		=> $max_level+1,
		'S_COLUMN_SPAN' => $s_column_span + $max_level+2,
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//		$sql = "SELECT group_id, group_name
//			FROM " . GROUPS_TABLE . "
//			WHERE group_single_user <> " . TRUE;
//-- add v 1.0.7
		$sql = "SELECT group_id, group_name
			FROM " . GROUPS_TABLE . "
			WHERE group_single_user <> " . TRUE . "
			ORDER BY group_name";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		$sql = "SELECT group_id, group_name
//			FROM " . GROUPS_TABLE . "
//			WHERE group_single_user <> " . TRUE;
//-- add
		$sql = "SELECT group_id, group_name
			FROM " . GROUPS_TABLE . "
			WHERE group_single_user <> " . TRUE . "
			ORDER BY group_name";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
$nav_separator = "&nbsp;->&nbsp;";
$nav_link_active = true;

// get the depth level
function get_max_depth($cat_id)
{
	global $db;
	if ($cat_id < 0) $cat_id = 0;
	$local_depth = 0;
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_main = $cat_id";
	if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie parm', '', __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		$branch_depth = get_max_depth( $row['cat_id'] );
		if ( $cat_id > 0 ) $branch_depth++;
		if ( $branch_depth > $local_depth ) $local_depth = $branch_depth;
	}
	return $local_depth;
}

// build the cat list sorted
function get_auth_cat_order(&$cat_row, &$cat_list, $cat_main=0, $level=0)
{
	global $db;

	// read daughter cats
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_main = $cat_main order by cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) ) $rowlevel[] = $row;
	// push and get the sub- daughter cat
	for ($i = 0; $i < count($rowlevel); $i++ )
	{
		if ( in_array( $rowlevel[$i]['cat_id'], $cat_list ) )
		{
			$rowlevel[$i]['level'] = $level;
			$cat_row[] = $rowlevel[$i];
			get_auth_cat_order( $cat_row, $cat_list, $rowlevel[$i]['cat_id'], ($level+1) );
		}
	}
}

// build the auth cat list
function get_auth_cat()
{
	global $db, $userdata;

	// get the cat id of all auth forums
	$catlist = array();
	$sql = "select * from " . FORUMS_TABLE;
	if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Couldn't obtain forum list.", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		$is_auth = array();
		$is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
		if ( $is_auth['auth_view'] ) $catlist[] = $row['cat_id'];
	}

	// get the mother cat
	$t_cat = $catlist;
	while ( count($t_cat) > 0 )
	{
		$s_cat = implode( ', ', $t_cat );
		$t_cat = array();
		$sql = "select * from " . CATEGORIES_TABLE . " where cat_id in ($s_cat)";
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
		while ( $row = $db->sql_fetchrow($result) )
		{
			if ( !in_array($row['cat_main'], $catlist) )
			{
				$catlist[] = $row['cat_main'];
				$t_cat[] =  $row['cat_main'];
			}
		}
	}

	// read cat sorted
	$catrows = array();
	get_auth_cat_order( $catrows, $catlist );

	return $catrows;
}
//-- add
// build the nav sentence
function make_cat_nav_tree($cat_id, $with_link)
{
	global $db,$phpEx;
	global $nav_separator, $nav_link_active;

	if ($nav_link_active) $with_link = true;

	$this_cat = "";
	if ($cat_id > 0)
	{
		$sql = "SELECT * FROM ".CATEGORIES_TABLE." WHERE cat_id=$cat_id";
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie parm '.$sql, '', __LINE__, __FILE__, $sql);
		if ( $catw = $db->sql_fetchrow($result) )
		{
			$cat_main  = $catw['cat_main'];
			$cat_title = $catw['cat_title'];
			$this_cat = ($with_link) ? '<a href="'.append_sid("index.$phpEx?c=$cat_id").'" class="nav">'.$cat_title.'</a>' : $cat_title;
			// vrifier si un parent
			if ($cat_main != $cat_id && $cat_main > 0)
			{
				$this_cat = make_cat_nav_tree($cat_main, true) . $nav_separator . $this_cat;
			}
		}
	}
	return $this_cat;
}

//
// build sub categories list
function get_sub_cat($cat_main, $catrow )
{
	global $db;

	if ($cat_main > 0)
	{
		// lire les rubriques dpendantes
		$sql= "SELECT * FROM ".CATEGORIES_TABLE." WHERE cat_id <> $cat_main AND cat_main=$cat_main";
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie sons '.$sql, '', __LINE__, __FILE__, $sql);
		while ( $catw = $db->sql_fetchrow($result) )
		{
			// ajouter la catgorie
			$i = count($catrow);
			$catrow[$i] = $catw;
			// aller chercher les sous-catgories
			if ($catw['cat_id'] > 0) $catrow = get_sub_cat($catw['cat_id'],$catrow);
		}
	}
	return $catrow;
}

// build sorted cats array
function get_cat($cat_id)
{
	global $db;

	// vrifier la catgorie
	if ($cat_id <= 0) $cat_id = -1;
	if ($cat_id > 0)
	{
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id=$cat_id";
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query this categories', '', __LINE__, __FILE__, $sql);
		if ( !($row = $db->sql_fetchrow($result)) ) $cat_id = -1;
	}
	//
	// no cat selected : get all
	if ($cat_id <= 0)
	{
		//-- v 1.0.5
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
		//-- 
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
		while ( $row = $db->sql_fetchrow($result) ) $category_rows[] = $row;
	}
	//
	// a cat selected : get it and its sub-cats
	if ($cat_id > 0)
	{
		// add the current one
		$catrow[] = $row;
		// get sub-cats
		$catrow = get_sub_cat($cat_id,$catrow);
		// get cats
		//-- v 1.0.5
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
		//--
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
		while ($row = $db->sql_fetchrow($result) )
		{
			$found = false;
			for ($i=0;( $i<count($catrow) && (!$found) );$i++) $found = ($row['cat_id'] == $catrow[$i]['cat_id']);
			if ($found) $category_rows[] = $row;
		}
	}
	return $category_rows;
}
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
//--------------------------------------------------------------------------------------------------
//
// $nav_separator : used in the navigation sentence : ie Forum Index -> MainCat -> Forum -> Topic
// --------------
//--------------------------------------------------------------------------------------------------
$nav_separator = "&nbsp;->&nbsp;";

//--------------------------------------------------------------------------------------------------
//
// $tree : designed to get all the hierarchy
// ------
//
//	indexes :
//		- id : full designation : ie Root, f3, c20
//		- idx : rank order
//
//	$tree['keys'][id]			=> idx,
//	$tree['auth'][id]			=> auth_value array : ie tree['auth'][id]['auth_view'],
//	$tree['sub'][id]			=> array of sub-level ids,
//	$tree['main'][idx]			=> parent id,
//	$tree['type'][idx]			=> type of the row, can be 'c' for categories or 'f' for forums,
//	$tree['id'][idx]			=> value of the row id : cat_id for cats, forum_id for forums,
//	$tree['data'][idx]			=> db table row,
//	$tree['unread_topics'][idx]	=> boolean value to true if there is new topics
//--------------------------------------------------------------------------------------------------
$tree = array();

//--------------------------------------------------------------------------------------------------
//
// get_object_lang() : return the translated value of field depending on row type in the hierarchy
//
//--------------------------------------------------------------------------------------------------
function get_object_lang($cur, $field)
{
	global $board_config, $lang, $tree;
	$res	= '';
	$this	= $tree['keys'][$cur];
	$type	= $tree['type'][$this];
	if ($cur == 'Root')
	{
		switch($field)
		{
			case 'name':
				if (isset($lang[$board_config['sitename']]))
				{
					$res = sprintf($lang['Forum_Index'], $lang[$board_config['sitename']]);
				}
				else
				{
					$res = sprintf($lang['Forum_Index'], $board_config['sitename']);
				}
				break;
			case 'desc':
				if (isset($lang[$board_config['site_desc']]))
				{
					$res = $lang[$board_config['site_desc']];
				}
				else
				{
					$res = $board_config['site_desc'];
				}
				break;
		}
	}
	else
	{
		switch($field)
		{
			case 'name':
				$field = ($type == POST_CAT_URL) ? 'cat_title' : 'forum_name';
				break;
			case 'desc':
				$field = ($type == POST_CAT_URL) ? 'cat_desc' : 'forum_desc';
				break;
		}
		$res = $tree['data'][$this][$field];
		if (isset($lang[$res])) $res = $lang[$res];
	}
	return $res;
}

//--------------------------------------------------------------------------------------------------
//
// build_tree() : fill each level of the hierarchy tree recursivly : use read_tree() as entry point
//
//--------------------------------------------------------------------------------------------------
function build_tree(&$cats, &$forums, &$new_topic_data, &$tracking_topics, &$tracking_forums, &$tracking_all, $level=-1, $main='Root')
{
	global $db;
	global $tree;

	$tree_level = array();

	// get the forums of the level
	for ($i=0; $i < count($forums); $i++)
	{
		if ($forums[$i]['main'] == $main)
		{
			$tree_level['type'][]	= POST_FORUM_URL;
			$tree_level['id'][]		= $forums[$i]['forum_id'];
			$tree_level['sort'][]	= $forums[$i]['forum_order'];
			$tree_level['data'][]	= $forums[$i];
		}
	}
	// add the categories of this level
	for ($i=0; $i < count($cats); $i++)
	{
		if ($cats[$i]['main'] == $main)
		{
			$tree_level['type'][]	= POST_CAT_URL;
			$tree_level['id'][]		= $cats[$i]['cat_id'];
			$tree_level['sort'][]	= $cats[$i]['cat_order'];
			$tree_level['data'][]	= $cats[$i];
		}
	}

	// sort both
	if (!empty($tree_level['data'])) array_multisort($tree_level['sort'], $tree_level['type'], $tree_level['id'], $tree_level['data']);

	// add the tree_level to the tree
	$level++;
	$order = 0;
	for ($i=0; $i < count($tree_level['data']); $i++)
	{
		$this = count($tree['data']);
		$key = $tree_level['type'][$i] . $tree_level['id'][$i];
		$order = $order + 10;
		$tree['keys'][$key] = $this;
		$tree['main'][]		= $main;
		$tree['type'][]		= $tree_level['type'][$i];
		$tree['id'][]		= $tree_level['id'][$i];
		$tree['data'][]		= $tree_level['data'][$i];

		$tree['sub'][$main][] = $key;

		// cookies only set on forums
		$unread_topics = false;
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$forum_id = $tree['id'][$this];
			if (!empty($new_topic_data[$forum_id]) )
			{
				$forum_last_post_time = 0;
				while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
				{
					if ( empty($tracking_topics[$check_topic_id]) )
					{
						$unread_topics = true;
						$forum_last_post_time = max($check_post_time, $forum_last_post_time);
					}
					else
					{
						if ( $tracking_topics[$check_topic_id] < $check_post_time )
						{
							$unread_topics = true;
							$forum_last_post_time = max($check_post_time, $forum_last_post_time);
						}
					}
				} //  end while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
				if ( !empty($tracking_forums[$forum_id]) )
				{
					if ( $tracking_forums[$forum_id] > $forum_last_post_time )
					{
						$unread_topics = false;
					}
				}
				if ( $tracking_all > $forum_last_post_time )
				{
					$unread_topics = false;
				}
			} //  if (!empty($new_topic_data[$forum_id]) )
		}
		$tree['unread_topics'][$this] = $unread_topics;

		// add sub levels
		build_tree($cats, $forums, $new_topic_data, $tracking_topics, $tracking_forums, $tracking_all, $level, $tree_level['type'][$i] . $tree_level['id'][$i]);
	}

	return;
}

//--------------------------------------------------------------------------------------------------
//
// read_tree() : read the tables and fill the hierarchical tree
//
//--------------------------------------------------------------------------------------------------
function read_tree()
{
	global $db, $userdata, $board_config, $HTTP_COOKIE_VARS;
	global $tree;

	// get censored words
	$orig_word = array();
	$remplacement_word = array();
	obtain_word_list($orig_word, $replacement_word);

	// read cats
	$cats = array();
	$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['cat_main'] == $row['cat_id']) $row['cat_main'] = 0;
		if (empty($row['cat_main_type'])) 
		{
			$row['cat_main_type'] = POST_CAT_URL;
			$row['cat_order'] = $row['cat_order'] + 9000000;
		}
		$row['main'] = ($row['cat_main'] == 0) ? 'Root' : $row['cat_main_type'] . $row['cat_main'];
		$cats[] = $row;
	}

	// read forums
	$forums = array();
	$sql = "SELECT 
					f.*, 
					p.post_time, p.post_username, 
					u.username, u.user_id, 
					t.topic_last_post_id, t.topic_title 
				FROM ((( " . FORUMS_TABLE . " f 
				LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id ) 
				LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) 
				LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id AND t.forum_id = f.forum_id)
				ORDER BY f.forum_order, f.forum_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Forums", "", __LINE__, __FILE__, $sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$main_type = (empty($row['main_type'])) ? POST_CAT_URL : $row['main_type'];
		$row['main'] = ($row['cat_id'] == 0) ? 'Root' : $main_type . $row['cat_id'];
		if ( count($orig_word) )
		{
			$row['topic_title'] = preg_replace($orig_word, $replacement_word, $row['topic_title']);
		}
		$forums[] = $row;
	}

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
	$new_topic_data = array();
	if ( $userdata['session_logged_in'] )
	{
		$user_lastvisit = $userdata['user_lastvisit'];
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
			WHERE p.post_id = t.topic_last_post_id 
				AND p.post_time > $user_lastvisit 
				AND t.topic_moved_id = 0"; 
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
	}

	// read the user cookie
	$tracking_topics	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
	$tracking_forums	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
	$tracking_all		= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : -1;

	// build the tree
	$tree = array();
	build_tree($cats, $forums, $new_topic_data, $tracking_topics, $tracking_forums, $tracking_all);

	return;
}

//--------------------------------------------------------------------------------------------------
//
// set_tree_user_auth() : enhance each row with auths and other things : use get_user_tree() as entry point
//
//--------------------------------------------------------------------------------------------------
function set_tree_user_auth($cur='Root')
{
	global $board_config, $userdata, $lang;
	global $tree;

	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;

	// last post information and auth
	$res = array();
	$res['auth_view']			= false;
	$res['locked']				= false;
	$res['topic_last_post_id']	= 0;
	$res['post_time']			= 0;
	$res['post_user_id']		= 0;
	$res['post_username']		= '';
	$res['topic_title']			= '';
	$res['forum_posts']			= 0;
	$res['forum_topics']		= 0;
	$res['unread_topics']		= false;

	// get the info from forums
	if ( ($this > -1) && $tree['auth'][$cur]['auth_view'] )
	{
		$res['auth_view']		= $tree['auth'][$cur]['auth_view'];
		$res['locked']			= ($tree['data'][$this]['forum_status'] == FORUM_LOCKED);
		$res['forum_posts']		= $tree['data'][$this]['forum_posts'];
		$res['forum_topics']	= $tree['data'][$this]['forum_topics'];

		if ( !empty($tree['data'][$this]['topic_last_post_id']) )
		{
			$res['topic_last_post_id']	= $tree['data'][$this]['topic_last_post_id'];
			$res['post_time']			= $tree['data'][$this]['post_time'];
			$res['post_user_id']		= $tree['data'][$this]['user_id'];
			$res['post_username']		= ($tree['data'][$this]['user_id'] != ANONYMOUS) ? $tree['data'][$this]['username'] : ( (!empty($tree['data'][$this]['post_username'])) ? $tree['data'][$this]['post_username'] : $lang['Guest'] );
			$res['topic_title']			= $tree['data'][$this]['topic_title'];
			$res['unread_topics']		= $tree['unread_topics'][$this];
		}
	}

	// read sub-levels
	$count = count($tree['sub'][$cur]);
	$sub_locked = true;
	for ($i=0; $i < $count; $i++)
	{
		// climb up the tree
		$res_sub = array();
		$res_sub = set_tree_user_auth($tree['sub'][$cur][$i]);

		// get the auth
		$res['auth_view'] = $res['auth_view'] || $res_sub['auth_view'];
		// locked status
		if (!$res_sub['locked']) $sub_locked = false;

		// count topics and posts
		$res['forum_posts']		= $res['forum_posts'] + $res_sub['forum_posts'];
		$res['forum_topics']	= $res['forum_topics'] + $res_sub['forum_topics'];

		// check if there is a more recent post in the sub-tree
		if ( !empty($res_sub['topic_last_post_id']) && (empty($res['topic_last_post_id']) || ($res_sub['post_time'] > $res['post_time'])) )
		{
			$res['topic_last_post_id']	= $res_sub['topic_last_post_id'];
			$res['post_time']			= $res_sub['post_time'];
			$res['post_user_id']		= $res_sub['post_user_id'];
			$res['post_username']		= $res_sub['post_username'];
			$res['topic_title']			= $res_sub['topic_title'];
			$res['unread_topics']		= $res_sub['unread_topics'] || $res['unread_topics'];
		}
	}

	// overide the level
	$tree['auth'][$cur]['tree.auth_view'] = $res['auth_view'];
	if ($this > -1)
	{
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$res['locked'] = ($tree['data'][$this]['forum_status'] == FORUM_LOCKED) && $sub_locked;
		}
		else
		{
			$res['locked']	= $sub_locked;
		}
		$tree['data'][$this]['tree.locked']				= $res['locked'];
		$tree['data'][$this]['tree.topic_last_post_id']	= $res['topic_last_post_id'];
		$tree['data'][$this]['tree.post_time']			= $res['post_time'];
		$tree['data'][$this]['tree.post_user_id']		= $res['post_user_id'];
		$tree['data'][$this]['tree.post_username']		= $res['post_username'];
		$tree['data'][$this]['tree.topic_title']		= $res['topic_title'];
		$tree['data'][$this]['tree.forum_posts']		= $res['forum_posts'];
		$tree['data'][$this]['tree.forum_topics']		= $res['forum_topics'];
		$tree['data'][$this]['tree.unread_topics']		= $res['unread_topics'];
	}

	return $res;
}

//--------------------------------------------------------------------------------------------------
//
// get_user_tree() : generate the hierarchy tree - called in init_userprefs()
//
//--------------------------------------------------------------------------------------------------
function get_user_tree(&$userdata)
{
	global $tree;

	if (empty($tree)) read_tree();

	// read the user auth if requiered
	if (empty($tree['auth']))
	{
		$tree['auth'] = array();
		$wauth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
		if (!empty($wauth))
		{
			reset($wauth);
			while (list($key, $data) = each($wauth))
			{
				$tree['auth'][POST_FORUM_URL . $key] = $data;
			}
		}

		// enhanced each level
		set_tree_user_auth();
	}

	return;
}

//--------------------------------------------------------------------------------------------------
//
// get_auth_keys() : return an array() with only the viewable row id
// returned array :
//		$keys['keys'][id]		=> n,
//		$keys['id'][n]			=> id (used by $tree),
//		$keys['real_level'][n]	=> level in this auth-tree (root=-1),
//		$keys['level'][n]		=> level adjust for display (sub-level=parent level under certain conditions)
//		$keys['idx'][n]			=> idx (used by $tree)
//--------------------------------------------------------------------------------------------------
function get_auth_keys($cur='Root', $all=false, $level=-1, $max=-1, $auth_key='auth_view')
{
	global $board_config;
	global $tree;

	$keys = array();
	$last_i = -1;

	// use tree auth if auth view asked
	if ($auth_key == 'auth_view')
	{
		$auth_key = 'tree.' . $auth_key;
	}

	// add the level
	if ( ($cur == 'Root') || $tree['auth'][$cur][$auth_key] || $all)
	{
		// push the level
		if (($max < 0) || ($level < $max) || (($level==$max) && ((substr($tree['main'][$tree['keys'][$cur]], 0, 1) == POST_CAT_URL) || ($tree['main'][$tree['keys'][$cur]] == 'Root') )))
		{
			// if child of cat, align the level on the parent one
			$orig_level = $level;
			if (!$all)
			{
				if (($level > 0) && ((substr($cur, 0, 1) == POST_FORUM_URL) || (intval($board_config['sub_forum']) > 0)) && (substr($tree['main'][$tree['keys'][$cur]], 0, 1) == POST_CAT_URL)) $level = $level-1;
			}

			// store this level
			$last_i++;
			$keys['keys'][$cur]				= $last_i;
			$keys['id'][$last_i]			= $cur;
			$keys['real_level'][$last_i]	= $orig_level;
			$keys['level'][$last_i]			= $level;
			$keys['idx'][$last_i]			= (isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1);

			// get sub-levels
			for ($i=0; $i < count($tree['sub'][$cur]); $i++)
			{
				$tkeys = array();
				$tkeys = get_auth_keys($tree['sub'][$cur][$i], $all, $orig_level+1, $max, $auth_key);

				// add sub-levels
				for ($j=0; $j < count($tkeys['id']); $j++)
				{
					$last_i++;
					$keys['keys'][$tkeys['id'][$j]] = $last_i;
					$keys['id'][$last_i]			= $tkeys['id'][$j];
					$keys['real_level'][$last_i]	= $tkeys['real_level'][$j];
					$keys['level'][$last_i]			= $tkeys['level'][$j];
					$keys['idx'][$last_i]			= $tkeys['idx'][$j];
				}
			}
		}
	}

	return $keys;
}

//--------------------------------------------------------------------------------------------------
//
// get_max_depth() : return the maximum level in the branch of the tree
//
//--------------------------------------------------------------------------------------------------
function get_max_depth($cur='Root', $all=false, $level=-1, &$keys, $max=-1)
{
	global $tree;
	if (empty($keys['id']))
	{
		$keys = array();
		$keys = get_auth_keys($cur, $all);
	}

	$max_level = 0;
	for ($i=0; $i < count($keys['id']); $i++)
	{
		if ($keys['level'][$i] > $max_level)
		{
			$max_level = $keys['level'][$i];
		}
	}
	return $max_level;
}

//--------------------------------------------------------------------------------------------------
//
// get_tree_option() : return a drop down menu list of <option></option>
//
//--------------------------------------------------------------------------------------------------
function get_tree_option($cur='', $all=false)
{
	global $tree, $lang;

	$keys = array();
	$keys = get_auth_keys('Root', $all);
	$res = '';
	for ($i=0; $i < count($keys['id']); $i++)
	{
		// only get object that are not forum links type
		if ( ($tree['type'][ $keys['idx'][$i] ] != POST_FORUM_URL) || empty($tree['data'][ $keys['idx'][$i] ]['forum_link']) )
		{
			$selected = ($cur == $keys['id'][$i]) ? ' selected="selected"' : '';
			$res .= '<option value="' . $keys['id'][$i] . '"' .  $selected . '>';

			// name
			$name = get_object_lang($keys['id'][$i], 'name');

			// increment
			$inc = '';
			for ($k=1; $k <= $keys['real_level'][$i]; $k++)
			{
				$inc .= '|&nbsp;&nbsp;&nbsp;';
			}
			if ($keys['level'][$i] >=0) $inc .= '|--';
			$name = $inc . $name;

			$res .= $name . '</option>';
		}
	}
	return $res;
}

//--------------------------------------------------------------------------------------------------
//
// build_index() : display a level and its sublevels : use dislay_index() as entry point
//
//--------------------------------------------------------------------------------------------------
function build_index($cur='Root', $cat_break=false, &$forum_moderators, $real_level=-1, $max_level=-1, &$keys)
{
	global $template, $phpEx, $board_config, $lang, $images;
	global $tree;
	//
	// init
	//
	$display = false;

	// get the sub_forum switch value
	$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
	$this = 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'][$this]))
				{
					$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(
			'L_FORUM'	=> ($this < 0) ? $lang['Forum'] : get_object_lang($cur, 'name'),
			'INC_SPAN'	=> $max_level+2,
			)
		);
	}

	// 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'][$this] == POST_CAT_URL) && $pull_down)
		{
			// display a cat row
			$cat = $tree['data'][$this];
			$cat_id = $tree['id'][$this];

			// 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_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',
					)
				);
			}

			// something displayed
			$display = true;
		}
	}

	// forum header row
	if ($level >= 0)
	{
		if ( ($tree['type'][$this] == POST_FORUM_URL) || (($tree['type'][$this] == POST_CAT_URL) && !$pull_down))
		{
			// get the data
			$data	= $tree['data'][$this];
			$id		= $tree['id'][$this];
			$type	= $tree['type'][$this];
			$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'][$this] == POST_FORUM_URL) && !empty($tree['data'][$this]['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'];
			}

			// front icon
			$folder_image = ( $data['tree.unread_topics'] ) ? $i_new : $i_norm;
			$folder_alt   = ( $data['tree.unread_topics'] ) ? $a_new : $a_norm;
			if ($data['tree.locked'])
			{
				$folder_image	= $i_locked;
				$folder_alt		= $a_locked;
			}

			// moderators list
			$l_moderators	= '&nbsp;';
			$moderator_list = '&nbsp;';
			if ($type == POST_FORUM_URL)
			{
				if ( count($forum_moderators[$id]) > 0 )
				{
					$l_moderators = ( count($forum_moderators[$id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
					$moderator_list = implode(', ', $forum_moderators[$id]);
				}
			}

			// last post
			$last_post = $lang['No_Posts'];
			if ( $data['tree.topic_last_post_id'] )
			{
				// resize
				$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 = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . "=" . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '" title="' . $data['tree.topic_title'] . '">' . $topic_title . '</a><br />';

				$last_post_time = create_date($board_config['default_dateformat'], $data['tree.post_time'], $board_config['board_timezone']);
				$last_post  = (($board_config['last_topic_title']) ? $topic_title : '');
				$last_post .= $last_post_time . '<br />';
				$last_post .= ( $data['tree.post_user_id'] == ANONYMOUS ) ? $data['tree.post_username'] . ' ' : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $data['tree.post_user_id']) . '">' . $data['tree.post_username'] . '</a> ';
				$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $data['tree.topic_last_post_id']) . '#' . $data['tree.topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
			}

			// links to sub-levels
			$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] ]['tree.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 != '') $link = '<a href="' . $wpgm . '" title="' . $wdesc . '" class="gensmall">' . $wname . '</a>';

					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['icon_minipost'];
							$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
						$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  = '<a href="' . append_sid("./viewtopic.$phpEx?"  . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">';
						$wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" align="middle" /></a>';
					}
					if ($link != '') $links .= (($links != '') ? ', ' : '') . $wlast_post . $link;
				}
			}

			// send to template
			$template->assign_block_vars('catrow', array());
			$template->assign_block_vars('catrow.forumrow',	array(
				'FORUM_FOLDER_IMG'		=> $folder_image, 
				'FORUM_NAME'			=> $title,
				'FORUM_DESC'			=> $desc,
				'POSTS'					=> $data['tree.forum_posts'],
				'TOPICS'				=> $data['tree.forum_topics'],
				'LAST_POST'				=> $last_post,
				'MODERATORS'			=> $moderator_list,
				'L_MODERATOR'			=> $l_moderators, 
				'L_FORUM_FOLDER_ALT'	=> $folder_alt, 
				'U_VIEWFORUM'			=> ($type == POST_FORUM_URL) ? append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$id") : append_sid("index.$phpEx?" . POST_CAT_URL . "=$id"),
				
				'INC_SPAN'				=> $max_level- $level+1,
				'INC_CLASS'				=> ( !($level % 2) ) ? 'row1' : 'row2',
				)
			);

			// add indentation to the display
			for ($k=1; $k <= $level; $k++)
			{
				$template->assign_block_vars('catrow.forumrow.inc', array(
					'INC_CLASS' => ($k % 2) ?  'row1' : 'row2',
					)
				);
			}

			// add the links row
			if (!empty($links))
			{
				$template->assign_block_vars('catrow.forumrow.links', array(
					'L_LINKS'	=> (empty($moderator_list) ? '' : '<br />'),
					'LINKS'		=> $links,
					)
				);
			}

			// forum link type
			if (($tree['type'][$this] == POST_FORUM_URL) && !empty($tree['data'][$this]['forum_link']))
			{
				$s_hit_count = '';
				if ($tree['data'][$this]['forum_link_hit_count'])
				{
					$s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$this]['forum_link_hit']);
				}
				$template->assign_block_vars('catrow.forumrow.forum_link', array(
					'HIT_COUNT' => $s_hit_count,
					)
				);
			}
			else
			{
				$template->assign_block_vars('catrow.forumrow.forum_link_no', array());
			}

			// something displayed
			$display = true;
		}
	}

	// display sub-levels
	for ($i=0; $i < count($tree['sub'][$cur]); $i++) if (!empty($keys['keys'][$tree['sub'][$cur][$i]]))
	{
		$wdisplay = build_index($tree['sub'][$cur][$i], $cat_break, $forum_moderators, $level+1, $max_level, $keys);
		if ($wdisplay) $display = true;
	}

	if ($level >=0 )
	{
		// forum footer row
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
		}
	}

	if ($level >=0 )
	{
		// cat footer
		if ( ($tree['type'][$this] == POST_CAT_URL) && $pull_down)
		{
			$template->assign_block_vars('catrow', array());
			$template->assign_block_vars('catrow.catfoot', array('INC_SPAN' => $max_level - $level+5));

			// add indentation to the display
			for ($k=1; $k <= $level; $k++)
			{
				$template->assign_block_vars('catrow.catfoot.inc', array(
					'INC_SPAN' => $max_level - $level+5,
					'INC_CLASS' => ($k % 2) ?  'row1' : 'row2',
					)
				);
			}
		}
	}

	// root level footer
	if (($board_config['split_cat'] && $cat_break && $real_level==0) || ((!$board_config['split_cat'] || !$cat_break) && $real_level==-1))
	{
		$template->assign_block_vars('catrow', array());
		$template->assign_block_vars('catrow.tablefoot', array());
	}

	return $display;
}

//--------------------------------------------------------------------------------------------------
//
// display_index() : display the index using the tpl var {BOARD_INDEX}, return true if the index is not empty
//
//--------------------------------------------------------------------------------------------------
function display_index($cur='Root')
{
	global $board_config, $template, $userdata, $lang, $db, $nav_links, $phpEx;
	global $images, $nav_separator, $nav_cat_desc;

	$template->set_filenames(array(
		'index' => 'index_box.tpl')
	);

	//
	// Obtain list of moderators of each forum
	// First users, then groups ... broken into two queries
	//
	$sql = "SELECT aa.forum_id, u.user_id, u.username 
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
		WHERE aa.auth_mod = " . TRUE . " 
			AND g.group_single_user = 1 
			AND ug.group_id = aa.group_id 
			AND g.group_id = aa.group_id 
			AND u.user_id = ug.user_id 
		GROUP BY u.user_id, u.username, aa.forum_id 
		ORDER BY aa.forum_id, u.user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	$forum_moderators = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
	}

	$sql = "SELECT aa.forum_id, g.group_id, g.group_name 
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
		WHERE aa.auth_mod = " . TRUE . " 
			AND g.group_single_user = 0 
			AND g.group_type <> " . GROUP_HIDDEN . "
			AND ug.group_id = aa.group_id 
			AND g.group_id = aa.group_id 
		GROUP BY g.group_id, g.group_name, aa.forum_id 
		ORDER BY aa.forum_id, g.group_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
	}

	// let's dump all of this on the template
	$keys = array();
	$display = build_index($cur, $board_config['split_cat'], $forum_moderators, -1, -1, $keys);

	// constants
	$template->assign_vars(array(
		'L_FORUM' => $lang['Forum'],
		'L_TOPICS' => $lang['Topics'],
		'L_POSTS' => $lang['Posts'],
		'L_LASTPOST' => $lang['Last_Post'],
		)
	);
	$template->assign_vars(array(
		'SPACER'		=> $images['spacer'],
		'NAV_SEPARATOR' => $nav_separator,
		'NAV_CAT_DESC'	=> $nav_cat_desc,
		)
	);
	if ($display) $template->assign_var_from_handle('BOARD_INDEX', 'index');

	return $display;
}

//--------------------------------------------------------------------------------------------------
//
// make_cat_nav_tree() : build the nav sentence
//
//--------------------------------------------------------------------------------------------------
function make_cat_nav_tree($cur, $pgm='', $nav_class='nav')
{
	global $phpbb_root_path, $phpEx, $db;
	global $global_orig_word, $global_replacement_word;
	global $nav_separator;
	global $tree;

	// get topic or post level
	$type = substr($cur, 0, 1);
	$id = intval(substr($cur,1));
	$topic_title = '';
	$fcur = '';
	switch ($type)
	{
		case POST_TOPIC_URL:
			$sql = "SELECT forum_id, topic_title 
						FROM " . TOPICS_TABLE . " WHERE topic_id = $id";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query topics information', '', __LINE__, __FILE__, $sql);
			if ($row = $db->sql_fetchrow($result))
			{
				$fcur = POST_FORUM_URL . $row['forum_id'];
				$topic_title = $row['topic_title'];
				$orig_word = array();
				$remplacement_word = array();
				obtain_word_list($orig_word, $replacement_word);
				if ( count($orig_word) )
				{
					$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
				}
			}
			break;
		case POST_POST_URL:
			$sql = "SELECT t.forum_id, t.topic_title 
						FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t 
						WHERE t.topic_id=p.topic_id AND post_id = $id";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query posts information', '', __LINE__, __FILE__, $sql);
			if ($row = $db->sql_fetchrow($result))
			{
				$fcur = POST_FORUM_URL . $row['forum_id'];
				$topic_title = $row['topic_title'];
				$orig_word = array();
				$remplacement_word = array();
				obtain_word_list($orig_word, $replacement_word);
				if ( count($orig_word) )
				{
					$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
				}
			}
			break;
	}

	// keep the compliancy with prec versions
	if (!isset($tree['keys'][$cur])) $cur = isset($tree['keys'][POST_CAT_URL . $cur]) ? POST_CAT_URL . $cur : $cur;

	// find the object
	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;

	$res = '';
	while (($this >= 0) || ($fcur != ''))
	{
		$type = (substr($fcur, 0, 1) != '') ? substr($cur, 0, 1) : $tree['type'][$this];
		switch($type)
		{
			case POST_CAT_URL:
				$field_name		= get_object_lang($cur, 'name');
				$param_type		= POST_CAT_URL;
				$param_value	= $tree['id'][$this];
				$pgm_name		= "index.$phpEx";
				break;
			case POST_FORUM_URL:
				$field_name		= get_object_lang($cur, 'name');
				$param_type		= POST_FORUM_URL;
				$param_value	= $tree['id'][$this];
				$pgm_name		= "viewforum.$phpEx";
				break;
			case POST_TOPIC_URL:
				$field_name		= $topic_title;
				$param_type		= POST_TOPIC_URL;
				$param_value	= $id;
				$pgm_name		= "viewtopic.$phpEx";
				break;
			case POST_POST_URL:
				$field_name		= $topic_title;
				$param_type		= POST_POST_URL;
				$param_value	= $id . '#' . $id;
				$pgm_name		= "viewtopic.$phpEx";
				break;
			default :
				$field_name		= '';
				$param_type		= '';
				$param_value	= '';
				$pgm_name		= "index.$phpEx";
				break;
		}
		if ($pgm != '') $pgm_name = "$pgm.$phpEx";

		$res = '<a href="' . append_sid('./' . $pgm_name . (($field_name != '') ? "?$param_type=$param_value" : '')) . '" class="' . $nav_class . '">' . $field_name . '</a>' . (($res != '') ? $nav_separator . $res : '');

		// find parent object
		if ($fcur != '')
		{
			$cur	= $fcur;
			$pgm	= '';
			$fcur	= '';
			$topic_title = '';
		}
		else
		{
			$cur = $tree['main'][$this];
		}
		$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
	}

	return $res;
}

//--------------------------------------------------------------------------------------------------
//
// jumpbox() : replace the original phpBB make_jumpbox()
//
//--------------------------------------------------------------------------------------------------
function jumpbox($action, $match_forum_id = 0)
{
	global $template, $userdata, $lang, $db, $nav_links, $phpEx, $SID;
	global $links;

	// build the jumpbox
	$boxstring  = '<select name="selected_id" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }">';
	$boxstring .= '<option value="-1">' . $lang['Select_forum'] . '</option><option value="-1"></option>' . get_tree_option(POST_FORUM_URL . $match_forum_id);
	$boxstring .= '</select>';

	// add SID if missing
	if ( !empty($SID) )
	{
		$boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
	}

	// dump this to template
	$template->set_filenames(array(
		'jumpbox' => 'jumpbox.tpl')
	);
	$template->assign_vars(array(
		'L_GO' => $lang['Go'],
		'L_JUMP_TO' => $lang['Jump_to'],
		'L_SELECT_FORUM' => $lang['Select_forum'],

		'S_JUMPBOX_SELECT' => $boxstring,
		'S_JUMPBOX_ACTION' => append_sid($action))
	);
	$template->assign_var_from_handle('JUMPBOX', 'jumpbox');

	return;
}

//--------------------------------------------------------------------------------------------------
//
// selectbox() : replace the original phpBB function_admin/make_forum_select()
//
//--------------------------------------------------------------------------------------------------
function selectbox($box_name, $ignore_forum = false, $select_forum = '')
{
	$s_id = ($select_forum != '') ? POST_FORUM_URL . $select_forum : '';
	$s_list = get_tree_option($select_forum);
	$res = '<select name="' . $box_name . '">' . $s_list . '</select>';
	return $res;
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function make_jumpbox($action, $match_forum_id = 0)
{
	global $template, $userdata, $lang, $db, $nav_links, $phpEx;

//	$is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//	$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
//		FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
//		WHERE f.cat_id = c.cat_id
//		GROUP BY c.cat_id, c.cat_title, c.cat_order
//		ORDER BY c.cat_order";
//	if ( !($result = $db->sql_query($sql)) )
//	{
//		message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
//	}
//	
//	$category_rows = array();
//	while ( $row = $db->sql_fetchrow($result) )
//	{
//		$category_rows[] = $row;
//	}
//-- add v 1.0.9
	$category_rows = array();
	$category_rows = get_auth_cat();
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

	if ( $total_categories = count($category_rows) )
	{
		$sql = "SELECT *
			FROM " . FORUMS_TABLE . "
			ORDER BY cat_id, forum_order";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
		}

		$boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option>';

		$forum_rows = array();
		while ( $row = $db->sql_fetchrow($result) )
		{
			$forum_rows[] = $row;
		}

		if ( $total_forums = count($forum_rows) )
		{
			for($i = 0; $i < $total_categories; $i++)
			{
				$boxstring_forums = '';
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
				$inc = '';
				for ($k = 1; $k < $category_rows[$i]['level']; $k++) $inc = '|&nbsp;&nbsp;&nbsp;' . $inc;
				$inc = ( ($category_rows[$i]['level'] > 0) ? '|&nbsp;&nbsp;&nbsp;' : '|--' ) . $inc;
				$inc .= ($category_rows[$i]['level'] > 0) ? '|--' : '';
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
				for($j = 0; $j < $total_forums; $j++)
				{
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete v 1.0.9
//					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
//					{
//-- add v 1.0.9
					$do_it = false;
					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] )
					{
						$is_auth = array();
						$is_auth = auth(AUTH_ALL, $forum_rows[$j]['forum_id'], $userdata);
						$do_it = $is_auth['auth_view'];
					}
					if ( $do_it )
					{
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

//					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
//					{
						$selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete
//						$boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>';
//-- add v 1.0.9
						$boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . '|&nbsp;&nbsp;&nbsp;' . $inc . '&nbsp;' . $forum_rows[$j]['forum_name'] . '</option>';
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

						//
						// Add an array to $nav_links for the Mozilla navigation bar.
						// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
						//
						$nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
							'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
							'title' => $forum_rows[$j]['forum_name']
						);
								
					}
				}

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- delete v 1.0.9
//				if ( $boxstring_forums != '' )
//				{
//					$boxstring .= '<option value="-1">&nbsp;</option>';
//					$boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
//					$boxstring .= '<option value="-1">----------------</option>';
//					$boxstring .= $boxstring_forums;
//				}
//-- add v 1.0.9
				if ( $i == 0 )
				{
					$boxstring .= '<option value="-1">&nbsp;</option>';
					$boxstring .= '<option value="-1">' . $lang['Forum_index'] . '</option>';
				}
				$boxstring .= '<option value="-1">' . $inc . '[' . $category_rows[$i]['cat_title'] . ']</option>';
				$boxstring .= $boxstring_forums;
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

			}
		}

		$boxstring .= '</select>';
	}
	else
	{
		$boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"></select>';
	}

	if ( !empty($SID) )
	{
		$boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
	}

	$template->set_filenames(array(
		'jumpbox' => 'jumpbox.tpl')
	);
	$template->assign_vars(array(
		'L_GO' => $lang['Go'],
		'L_JUMP_TO' => $lang['Jump_to'],
		'L_SELECT_FORUM' => $lang['Select_forum'],

		'S_JUMPBOX_SELECT' => $boxstring,
		'S_JUMPBOX_ACTION' => append_sid($action))
	);
	$template->assign_var_from_handle('JUMPBOX', 'jumpbox');

	return;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
function make_jumpbox($action, $match_forum_id = 0)
{
	global $template, $userdata, $lang, $db, $nav_links, $phpEx;

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	return jumpbox($action, $match_forum_id);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
//	$is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);

	$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
		FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
		WHERE f.cat_id = c.cat_id
		GROUP BY c.cat_id, c.cat_title, c.cat_order
		ORDER BY c.cat_order";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
	}
	
	$category_rows = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$category_rows[] = $row;
	}

	if ( $total_categories = count($category_rows) )
	{
		$sql = "SELECT *
			FROM " . FORUMS_TABLE . "
			ORDER BY cat_id, forum_order";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
		}

		$boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option>';

		$forum_rows = array();
		while ( $row = $db->sql_fetchrow($result) )
		{
			$forum_rows[] = $row;
		}

		if ( $total_forums = count($forum_rows) )
		{
			for($i = 0; $i < $total_categories; $i++)
			{
				$boxstring_forums = '';
				for($j = 0; $j < $total_forums; $j++)
				{
					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
					{

//					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
//					{
						$selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
						$boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>';

						//
						// Add an array to $nav_links for the Mozilla navigation bar.
						// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
						//
						$nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
							'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
							'title' => $forum_rows[$j]['forum_name']
						);
								
					}
				}

				if ( $boxstring_forums != '' )
				{
					$boxstring .= '<option value="-1">&nbsp;</option>';
					$boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
					$boxstring .= '<option value="-1">----------------</option>';
					$boxstring .= $boxstring_forums;
				}
			}
		}

		$boxstring .= '</select>';
	}
	else
	{
		$boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"></select>';
	}

	if ( !empty($SID) )
	{
		$boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
	}

	$template->set_filenames(array(
		'jumpbox' => 'jumpbox.tpl')
	);
	$template->assign_vars(array(
		'L_GO' => $lang['Go'],
		'L_JUMP_TO' => $lang['Jump_to'],
		'L_SELECT_FORUM' => $lang['Select_forum'],

		'S_JUMPBOX_SELECT' => $boxstring,
		'S_JUMPBOX_ACTION' => append_sid($action))
	);
	$template->assign_var_from_handle('JUMPBOX', 'jumpbox');

	return;
}
#
#-----[ FIND ]------------------------------------------------
#
	//
	// Set up style
	//
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $tree;
	if (empty($tree['auth'])) get_user_tree($userdata);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	//
	// Define censored word matches
	//
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $global_orig_word, $global_replacement_word;

	if (isset($global_orig_word))
	{
		$orig_word			= $global_orig_word;
		$replacement_word	= $global_replacement_word;
	}
	else
	{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$replacement_word[] = $row['replacement'];
		}
		while ( $row = $db->sql_fetchrow($result) );
	}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		$global_orig_word			= $orig_word;
		$global_replacement_word	= $replacement_word;
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	if(defined('HAS_DIED'))
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $tree;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
include_once( $phpbb_root_path . 'includes/functions.' . $phpEx );
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

//
// Simple version of jumpbox, just lists authed forums
//
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//--delete
// function make_forum_select($box_name, $ignore_forum = false, $select_forum = '')
//-- add v 1.0.9
function make_forum_select($box_name, $ignore_forum = false, $select_forum = '', $for_prune=false)
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
{
	global $db, $userdata;

	$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	global $phpEx, $lang;

	$category_rows = array();
	$category_rows = get_auth_cat();

	// add Index
	$forum_list .= '<option value="' . ( ($for_prune) ? 'C0' : -1 ) . '">[' . $lang['Forum_index'] . ']</option>';

	// get cats
	for ( $i = 0; $i < count($category_rows); $i++ )
	{
		// increment
		$inc = '';
		for ($k = 1; $k < $category_rows[$i]['level']; $k++) $inc = '|&nbsp;&nbsp;&nbsp;' . $inc;
		$inc = ( ($category_rows[$i]['level'] > 0) ? '|&nbsp;&nbsp;&nbsp;' : '|--' ) . $inc;
		$inc .= ($category_rows[$i]['level'] > 0) ? '|--' : '';

		// add cat
		$forum_list .= '<option value="' . ( ($for_prune) ? 'C' . $category_rows[$i]['cat_id'] : -1 ) . '">' . $inc . '[' . $category_rows[$i]['cat_title'] . ']' . '</option>';

		$sql = "select * from " . FORUMS_TABLE . " where cat_id = " . $category_rows[$i]['cat_id'];
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql);
		while( $row = $db->sql_fetchrow($result) )
		{
			if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] )
			{
				$selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : '';
				$forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . '|&nbsp;&nbsp;&nbsp;' . $inc . '&nbsp;' . $row['forum_name'] . '</option>';
			}
		}
	}

//-- delete
//	$sql = "SELECT forum_id, forum_name
//		FROM " . FORUMS_TABLE . " 
//		ORDER BY cat_id, forum_order";
//	if ( !($result = $db->sql_query($sql)) )
//	{
//		message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql);
//	}
//
//	$forum_list = '';
//	while( $row = $db->sql_fetchrow($result) )
//	{
//		if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] )
//		{
//			$selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : '';
//			$forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . $row['forum_name'] . '</option>';
//		}
//	}
//
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------

	$forum_list = ( $forum_list == '' ) ? '<option value="-1">-- ! No Forums ! --</option>' : '<select name="' . $box_name . '">' . $forum_list . '</select>';

	return $forum_list;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//
// Simple version of jumpbox, just lists authed forums
//
function make_forum_select($box_name, $ignore_forum = false, $select_forum = '')
{
	global $db, $userdata;

	$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);

	$sql = "SELECT forum_id, forum_name
		FROM " . FORUMS_TABLE . " 
		ORDER BY cat_id, forum_order";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql);
	}

	$forum_list = '';
	while( $row = $db->sql_fetchrow($result) )
	{
		if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] )
		{
			$selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : '';
			$forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . $row['forum_name'] . '</option>';
		}
	}

	$forum_list = ( $forum_list == '' ) ? '<option value="-1">-- ! No Forums ! --</option>' : '<select name="' . $box_name . '">' . $forum_list . '</select>';

	return $forum_list;
}
#
#-----[ OPEN ]------------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.2
if (!isset($board_config['sub_forum']) )
{
	$sqlw = "insert into ".CONFIG_TABLE." (config_name,config_value) VALUES('sub_forum','1')";
	if ( !($resultw = $db->sql_query($sqlw)) ) message_die(GENERAL_ERROR, 'Could not add key sub_forum in config table', '', __LINE__, __FILE__, $sql);
}
$sub_forum = (isset($board_config['sub_forum'])) ? intval($board_config['sub_forum']) : true;
//-- add v 1.0.9
$template->assign_vars(array(
	'NAV_SEPARATOR' => $nav_separator,
	)
);
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
include_once($phpbb_root_path . 'includes/mods_settings/mod_categories_hierarchy.' . $phpEx);

// get the nav sentence
$nav_key = '';
if (isset($HTTP_POST_VARS[POST_CAT_URL]) || isset($HTTP_GET_VARS[POST_CAT_URL]))
{
	$nav_key = POST_CAT_URL . ((isset($HTTP_POST_VARS[POST_CAT_URL])) ? intval($HTTP_POST_VARS[POST_CAT_URL]) : intval($HTTP_GET_VARS[POST_CAT_URL]));
}
if (isset($HTTP_POST_VARS[POST_FORUM_URL]) || isset($HTTP_GET_VARS[POST_FORUM_URL]))
{
	$nav_key = POST_FORUM_URL . ((isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]));
}
if (isset($HTTP_POST_VARS[POST_TOPIC_URL]) || isset($HTTP_GET_VARS[POST_TOPIC_URL]))
{
	$nav_key = POST_TOPIC_URL . ((isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]));
}
if (isset($HTTP_POST_VARS[POST_POST_URL]) || isset($HTTP_GET_VARS[POST_POST_URL]))
{
	$nav_key = POST_POST_URL . ((isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]));
}
if ( empty($nav_key) && (isset($HTTP_POST_VARS['selected_id']) || isset($HTTP_GET_VARS['selected_id'])) )
{
   $nav_key = isset($HTTP_GET_VARS['selected_id']) ? $HTTP_GET_VARS['selected_id'] : $HTTP_POST_VARS['selected_id'];
}
if (empty($nav_key)) $nav_key = 'Root';
$nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm);
if ($nav_cat_desc != '') $nav_cat_desc = $nav_separator . $nav_cat_desc;

// send to template
$template->assign_vars(array(
	'SPACER'		=> $images['spacer'],
	'NAV_SEPARATOR' => $nav_separator,
	'NAV_CAT_DESC'	=> $nav_cat_desc,
	)
);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/topic_review.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	global $starttime;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
//-- fix
	global $tree;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : mods settings ---------------------------------------------------------------------------
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.1
$lang['Category_attachment'] = 'Attached to Category';
//-- add v 1.0.2
$lang['Use_sub_forum'] = 'Display the sub-categories as forums';
//-- add v 1.0.5
$lang['Category_desc'] = 'Description';
//-- add v 1.0.7
$lang['Hierarchy_setting'] = 'Categories Hierarchy settings';
$lang['Category_config_error_fixed'] = 'An error in the category setup has been fixed';
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
$lang['Category_attachment']					= 'Attached to';
$lang['Category_desc']							= 'Description';
$lang['Category_config_error_fixed']			= 'An error in the category setup has been fixed';
$lang['Attach_forum_wrong']						= 'You can\'t attach a forum to a forum';
$lang['Attach_root_wrong']						= 'You can\'t attach a forum to the forum index';
$lang['Forum_name_missing']						= 'You can\'t create a forum without a name';
$lang['Category_name_missing']					= 'You can\'t create a category without a name';
$lang['Only_forum_for_topics']					= 'Topics can only be found in forums';
$lang['Delete_forum_with_attachment_denied']	= 'You can\'t delete forums having sub-levels';

$lang['Category_delete']						= 'Delete Category';
$lang['Category_delete_explain']				= 'The form below will allow you to delete a category and decide where you want to put all forums and categories it contained.';
// forum links type
$lang['Forum_link_url']							= 'Link URL';
$lang['Forum_link_url_explain']					= 'You can set here an URI to a phpBB prog, or a full URL to an external server';
$lang['Forum_link_internal']					= 'phpBB prog';
$lang['Forum_link_internal_explain']			= 'Choose yes if you invoke a program that stands in the phpBB dirs';
$lang['Forum_link_hit_count']					= 'Hit count';
$lang['Forum_link_hit_count_explain']			= 'Choose yes if you want the board to count and display the number of hit using this link';
$lang['Forum_link_with_attachment_deny']		= 'You can\'t set a forum as a link if it has already sub-levels';
$lang['Forum_link_with_topics_deny']			= 'You can\'t set a forum as a link if it has already topics in';
$lang['Forum_attached_to_link_denied']			= 'You can\'t attach a forum or a category to a forum link';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
//-- mod : mods settings ---------------------------------------------------------------------------
//-- add
$lang['Configuration_extend']	= 'Configuration +';
$lang['Override_user_choices']	= 'Override user choices';
//-- fin mod : mods settings -----------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//
// That's all, Folks!
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
$lang['Forum_link']					= 'Link redirection';
$lang['Forum_link_visited']			= 'This link has been visited %d times';
$lang['Redirect']					= 'Redirect';
$lang['Redirect_to']				= 'If your browser does not support meta redirection please click %sHERE% to be redirected';

$lang['Use_sub_forum']				= 'Index packing';
$lang['Hierarchy_setting']			= 'Categories Hierarchy settings';
$lang['Index_packing_explain']		= 'Choose the level of packing you want for the index';
$lang['Medium']						= 'Medium';
$lang['Full']						= 'Full';
$lang['Split_categories']			= 'Split categories on index';
$lang['Use_last_topic_title']		= 'Show the last topic titles on index';
$lang['Last_topic_title_length']	= 'Title length of the last topic on index';
$lang['Sub_level_links']			= 'Sub-level links on index';
$lang['Sub_level_links_explain']	= 'Add the links to the sub-levels in the forum or category description';
$lang['With_pics']					= 'With icons';
$lang['Display_viewonline']			= 'Display viewonline information box on index';
$lang['Never']						= 'Never';
$lang['Root_index_only']			= 'On root index only';
$lang['Always']						= 'Always';
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
  <tr> 

<!-- mod : hirarchie v 1.0.9 : colspan 2->INC_SPAN -->
	<th colspan="{INC_SPAN}" class="thCornerL" height="25" nowrap="nowrap">&nbsp;{L_FORUM}&nbsp;</th>

	<th width="50" class="thTop" nowrap="nowrap">&nbsp;{L_TOPICS}&nbsp;</th>
	<th width="50" class="thTop" nowrap="nowrap">&nbsp;{L_POSTS}&nbsp;</th>
	<th class="thCornerR" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
  </tr>

  <!-- BEGIN catrow -->

<!-- mod : hirarchie des rubriques -->
  <tr> 
<!-- mod : hirarchie v 1.0.9 : colspan 2->INC_SPAN -->
	<!-- BEGIN inc -->
	<td class="{catrow.inc.INC_ROW}" width="46">&nbsp;</td>
	<!-- END inc -->
	<td class="{catrow.CLASS_CATLEFT}" colspan="{catrow.INC_SPAN}" height="28"><span class="cattitle"><a href="{catrow.U_VIEWCAT}" class="cattitle">{catrow.CAT_DESC}</a></span></td> 
	<td class="{catrow.CLASS_ROWPIC}" colspan="3" align="right">&nbsp;</td> 
  </tr>
<!-- fin mod : hirarchie des rubriques -->

  <!-- BEGIN forumrow -->
  <tr> 

<!-- add v 1.0.9 -->
    <!-- BEGIN inc -->
	<td class="{catrow.forumrow.inc.INC_ROW}">&nbsp;</td>
    <!-- END inc -->
	<td class="{catrow.forumrow.INC_ROW}" align="center" valign="middle" height="50"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="46" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td>
<!-- add v 1.0.9 : colspan -->
	<td class="row1" width="100%" height="50" colspan="{catrow.forumrow.INC_SPAN}"><span class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />

	  </span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
	  </span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span></td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOPICS}</span></td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.POSTS}</span></td>
	<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
  </tr>
  <!-- END forumrow -->
  <!-- END catrow -->
</table>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
{BOARD_INDEX}
#
#-----[ FIND ]------------------------------------------------
#
	<td align="right"><span class="gensmall">{S_TIMEZONE}</span></td>
  </tr>
</table>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN disable_viewonline -->
#
#-----[ FIND ]------------------------------------------------
#
<!-- BEGIN switch_user_logged_out -->
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- END disable_viewonline -->

#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/modcp_move.tpl
#
#-----[ FIND ]------------------------------------------------
#
	  <td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></td>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	  <td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/modcp_split.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
	<td align="left">
		<span class="nav">
			<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}{NAV_SEPARATOR}<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
		</span>
	</td>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	  <td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/overall_header.tpl
#
#-----[ FIND ]------------------------------------------------
#
/*-- mod : hirarchie des rubriques */
td.catRupt {
         background-color:#BCCED7;
         background-image: url(templates/subSilver/images/cellpic4.gif);
}
/*-- fin mod : hirarchie des rubriques */

/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/posting_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
		<td align="left" valign="bottom">
			<span class="nav">
				<a href="{U_INDEX}" class="nav">{L_INDEX}</a>
				<!-- BEGIN switch_not_privmsg -->
				{NAV_CAT_DESC}{NAV_SEPARATOR}<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
				<br />
				<span class="maintitle">{TOPIC_TITLE}</span>
				<!-- END switch_not_privmsg -->
			</span>
		</td>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		<td align="left"><span  class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>
		<!-- BEGIN switch_not_privmsg -->
		{NAV_CAT_DESC}
		<!-- END switch_not_privmsg -->
		</span></td>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/search_body.tpl
#
#-----[ FIND ]------------------------------------------------
# at top of the file
<form action="{S_SEARCH_ACTION}" method="POST"><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : categories hierarchy v 2 -->
#
#-----[ FIND ]------------------------------------------------
#
		<td class="row2"><span class="genmed"><select class="post" name="search_forum">{S_FORUM_OPTIONS}</select></span></td>
#
#-----[ REPLACE WITH ]----------------------------------------
#
		<td class="row2"><span class="genmed"><select class="post" name="search_where">{S_FORUM_OPTIONS}</select></span></td>
#
#-----[ FIND ]------------------------------------------------
#
		<td class="row1" align="right"><span class="gen">{L_CATEGORY}:&nbsp;</span></td>
		<td class="row2"><span class="genmed"><select class="post" name="search_cat">{S_CATEGORY_OPTIONS}
		</select></span></td>
		<td class="row1" align="right"><span class="gen">{L_SORT_BY}:&nbsp;</span></td>
		<td class="row2" valign="middle" nowrap="nowrap"><span class="genmed"><select class="post" name="sort_by">{S_SORT_OPTIONS}</select><br /><input type="radio" name="sort_dir" value="ASC" /> {L_SORT_ASCENDING}<br /><input type="radio" name="sort_dir" value="DESC" checked /> {L_SORT_DESCENDING}</span>&nbsp;</td>
	</tr>
	<tr> 
		<td class="row1" align="right" nowrap="nowrap"><span class="gen">{L_DISPLAY_RESULTS}:&nbsp;</span></td>
		<td class="row2" nowrap="nowrap"><input type="radio" name="show_results" value="posts" /><span class="genmed">{L_POSTS}<input type="radio" name="show_results" value="topics" checked="checked" />{L_TOPICS}</span></td>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		<td class="row1" align="right" nowrap="nowrap"><span class="gen">{L_DISPLAY_RESULTS}:&nbsp;</span></td>
		<td class="row2" nowrap="nowrap"><input type="radio" name="show_results" value="posts" /><span class="genmed">{L_POSTS}<input type="radio" name="show_results" value="topics" checked="checked" />{L_TOPICS}</span></td>
		<td class="row1" align="right" rowspan="2"><span class="gen">{L_SORT_BY}:&nbsp;</span></td>
		<td class="row2" valign="middle" nowrap="nowrap" rowspan="2"><span class="genmed"><select class="post" name="sort_by">{S_SORT_OPTIONS}</select><br /><input type="radio" name="sort_dir" value="ASC" /> {L_SORT_ASCENDING}<br /><input type="radio" name="sort_dir" value="DESC" checked /> {L_SORT_DESCENDING}</span>&nbsp;</td>
	</tr>
	<tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/subSilver.cfg
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : hirarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.1
$images['category_new'] = "$current_template_images/cat_folder_new_big.gif";
$images['category'] = "$current_template_images/cat_folder_big.gif";
//-- add v 1.0.9
$images['category_locked'] = "$current_template_images/cat_folder_locked_big.gif";
//-- fin mod : hirarchie des rubriques ------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
$images['category'] = "$current_template_images/cat_folder_big.gif";
$images['category_new'] = "$current_template_images/cat_folder_new_big.gif";
$images['category_locked'] = "$current_template_images/cat_folder_locked_big.gif";
$images['icon_minicat'] = "$current_template_images/icon_minicat.gif";
$images['icon_minicat_new'] = "$current_template_images/icon_minicat_new.gif";
$images['icon_minicat_locked'] = "$current_template_images/icon_minicat_lock.gif";
$images['icon_minipost_lock'] = "$current_template_images/icon_minipost_lock.gif";
$images['link'] = "$current_template_images/link_folder.gif";
$images['icon_minilink'] = "$current_template_images/icon_minilink.gif";

$images['spacer'] = "$current_template_images/spacer.gif";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/subSilver.css
#
#-----[ FIND ]------------------------------------------------
#
/*-- mod : hirarchie des rubriques */
td.catRupt {
         background-color:#BCCED7;
         background-image: url(images/cellpic4.gif);
}
/*-- fin mod : hirarchie des rubriques */

/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
  <!-- affichage de la phrase d'index -->
  <table width="100%" cellspacing="2" cellpadding="2" border="0">
    <tr>
	  <td align="left" valign="middle" width="100%">
		<span class="nav">
			<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}{NAV_SEPARATOR}<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
		</span>
	  </td>
    </tr>
  </table>
  <br />

  <!-- affichage "new" | mods + users | "mark read" and pagination -->
  <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr>
	  <td align="left" valign="middle" width="0%">
		<a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" /></a>
	  </td>
	  <td align="left" valign="bottom" width="100%">
		<span class="gensmall">
			<b>{L_MODERATOR}: {MODERATORS}<br />
			{LOGGED_IN_USER_LIST}</b>
		</span>
	  </td>
	  <td align="right" valign="bottom" nowrap>
		<span class="gensmall">
			<a href="{U_MARK_READ}">{L_MARK_TOPICS_READ}</a><br />
			<b>{PAGINATION}</b>
		</span>
	  </td>
	</tr>
  </table>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
  <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr> 
	  <td align="left" valign="middle" class="nav" width="100%"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
	</tr>
  </table>

{BOARD_INDEX}

  <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr> 
	  <td align="left" valign="middle" width="50"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" /></a></td>
	  <td align="left" valign="bottom" width="100%"><span class="gensmall"><b>{L_MODERATOR}: {MODERATORS}<br /><br />{LOGGED_IN_USER_LIST}</b></span></td>
	  <td align="right" valign="bottom" nowrap="nowrap"><span class="gensmall"><b>{PAGINATION}</b><br /><a href="{U_MARK_READ}">{L_MARK_TOPICS_READ}</a></span></td>
	</tr>
  </table>
#
#-----[ FIND ]------------------------------------------------
#
	  <th align="center" class="thCornerR" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	  <th width="150" align="center" class="thCornerR" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
  <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2">
	<tr> 
	  <td align="left" valign="middle" width="50"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" /></a></td>
	  <td align="left" valign="middle" width="100%">
		<span class="nav">
			<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}{NAV_SEPARATOR}<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
		</span>
	  </td>
	  <td align="right" valign="middle" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
	</tr>
	<tr>
	  <td align="left" colspan="3"><span class="nav">{PAGE_NUMBER}</span></td>
	</tr>
  </table>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
  <table width="100%" cellspacing="2" border="0" align="center" cellpadding="2">
	<tr> 
	  <td align="left" valign="middle" width="50"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" /></a></td>
	  <td align="left" valign="middle" width="100%"><span class="nav">&nbsp;&nbsp;&nbsp;<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
	  <td align="right" valign="middle" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
	</tr>
	<tr>
	  <td align="left" colspan="3"><span class="nav">{PAGE_NUMBER}</span></td>
	</tr>
  </table>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr>
	<td align="left" valign="bottom">
		<span class="nav">
			<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}{NAV_SEPARATOR}
			<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
		</span>
	</td>
  </tr>
  <tr>
	<td align="left" valign="bottom">
		<a class="maintitle" href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a>
	</td>
  </tr>
</table>

<!-- affichage "new", "reply" | pagination -->
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr>
	<td align="left" valign="top" nowrap>
		<span class="nav">
			<a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>
			&nbsp;&nbsp;&nbsp;
			<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a>
		</span>
	</td>
	<td align="right" valign="bottom" width="100%">
		<span class="gensmall">
			<b>{PAGINATION}</b>
		</span>
      </td>
  </tr>
</table>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr> 
	<td align="left" valign="middle" class="nav" width="100%"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
  </tr>
  <tr>
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
	<td align="right" valign="bottom" width="100%" nowrap="nowrap"><span class="gensmall"><b>{PAGINATION}</b></span></td>
  </tr>
</table>
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
  <tr> 
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="bottom">
		<span class="nav">
			<a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}{NAV_SEPARATOR}
			<a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a>
		</span>
	</td>
	<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
  </tr>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
  <tr> 
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" class="nav" width="100%"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
	<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
  </tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/auth_ug_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
<!-- replace v 1.0.7 -->
	<!-- BEGIN categorie -->
	<tr> 
<!-- add v1.0.9 -->
		<!-- BEGIN inc -->
		<td class="row2"><span class="gen">&nbsp;&nbsp;</span></td>
		<!-- END inc -->
<!-- v 1.0.9 : colspan=20 -> colspan=INC_SPAN -->
	  <td colspan="{categorie.INC_SPAN}" class="{categorie.CLASS_CAT}" align="left" nowrap> <span class="cattitlemed">{categorie.CAT_TITLE}</span></td>
	</tr>
	<!-- BEGIN forums -->
	<tr> 
<!-- add v1.0.9 -->
		<!-- BEGIN inc -->
		<td class="row2"></td>
		<!-- END inc -->
<!-- add v 1.0.9 : colspan={INC_SPAN} -->
	  <td class="row1" align="left" colspan="{categorie.forums.INC_SPAN}"><span class="gentbl">{categorie.forums.FORUM_NAME}</span></td>
	  <!-- BEGIN aclvalues -->
	  <td class="row2" align="center">{categorie.forums.aclvalues.S_ACL_SELECT}</td>
	  <!-- END aclvalues -->
	  <td class="row1" align="center">{categorie.forums.S_MOD_SELECT}</td>
	</tr>
	<!-- END forums -->
	<!-- END categorie -->
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	<!-- BEGIN row -->
	<!-- BEGIN cathead -->
	<tr> 
		<!-- BEGIN inc -->
		<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
		<!-- END inc -->
		<td colspan="{row.cathead.INC_SPAN}" class="{row.cathead.CLASS_CAT}" align="left" nowrap> <span class="cattitlemed">{row.cathead.CAT_TITLE}</span></td>
		<!-- BEGIN aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap><span class="cattitlemed">&nbsp;</span></td>
		<!-- END aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap><span class="cattitlemed">&nbsp;</span></td>
	</tr>
	<!-- END cathead -->
	<!-- BEGIN forums -->
	<tr>
		<!-- BEGIN inc -->
		<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
		<!-- END inc -->
		<td class="row1" align="left" colspan="{row.forums.INC_SPAN}"><span class="gentbl">{row.forums.FORUM_NAME}</span></td>
		<!-- BEGIN aclvalues -->
		<td class="row2" align="center">{row.forums.aclvalues.S_ACL_SELECT}</td>
		<!-- END aclvalues -->
		<td class="row1" align="center">{row.forums.S_MOD_SELECT}</td>
	</tr>
	<!-- END forums -->
	<!-- END row -->
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- mod : hirarchie des rubriques -->
<!-- add v1.0.7 -->
	<tr>
		<th class="thHead" colspan="2">{L_HIERARCHY_SETTINGS}</th>
	</tr>
<!-- add v1.0.2 -->
	<tr>
		<td class="row1">{L_SUB_FORUM}</td>
		<td class="row2"><input type="radio" name="sub_forum" value="1" {SUB_FORUM_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="sub_forum" value="0" {SUB_FORUM_NO} /> {L_NO}</td>
	</tr>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	<tr>
		<th class="thHead" colspan="2">{L_HIERARCHY_SETTINGS}</th>
	</tr>
	<tr>
		<td class="row1">{L_SUB_FORUM}<br /><span class="gensmall">{L_SUB_FORUM_EXPLAIN}</span></td>
		<td class="row2">
			<input type="radio" name="sub_forum" value="0" {SUB_FORUM_NONE} /> {L_SUB_FORUM_NONE}&nbsp;&nbsp;
			<input type="radio" name="sub_forum" value="1" {SUB_FORUM_MEDIUM} /> {L_SUB_FORUM_MEDIUM}&nbsp;&nbsp;
			<input type="radio" name="sub_forum" value="2" {SUB_FORUM_FULL} /> {L_SUB_FORUM_FULL}
		</td>
	</tr>
	<tr>
		<td class="row1">{L_SPLIT_CAT}</td>
		<td class="row2">
			<input type="radio" name="split_cat" value="0" {SPLIT_CAT_NO} /> {L_NO}&nbsp;&nbsp;
			<input type="radio" name="split_cat" value="1" {SPLIT_CAT_YES} /> {L_YES}
		</td>
	</tr>
	<tr>
		<td class="row1">{L_LAST_TOPIC_TITLE}</td>
		<td class="row2">
			<input type="radio" name="last_topic_title" value="0" {LAST_TOPIC_TITLE_NO} /> {L_NO}&nbsp;&nbsp;
			<input type="radio" name="last_topic_title" value="1" {LAST_TOPIC_TITLE_YES} /> {L_YES}
		</td>
	</tr>
	<tr>
		<td class="row1">{L_LAST_TOPIC_TITLE_LENGTH}</td>
		<td class="row2"><input class="post" type="text" name="last_topic_title_length" size="3" maxlength="4" value="{LAST_TOPIC_TITLE_LENGTH}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_SUB_LINKS}<br /><span class="gensmall">{L_SUB_LINKS_EXPLAIN}</span></td>
		<td class="row2">
			<input type="radio" name="sub_level_links" value="0" {SUB_LINKS_NO} /> {L_NO}&nbsp;&nbsp;
			<input type="radio" name="sub_level_links" value="1" {SUB_LINKS_YES} /> {L_YES}&nbsp;&nbsp;
			<input type="radio" name="sub_level_links" value="2" {SUB_LINKS_PIC} /> {L_SUB_LINKS_PIC}
		</td>
	</tr>
	<tr>
		<td class="row1">{L_DISPLAY_VIEWONLINE}</td>
		<td class="row2">
			<input type="radio" name="display_viewonline" value="0" {DISPLAY_VIEWONLINE_NEVER} /> {L_NEVER}&nbsp;&nbsp;
			<input type="radio" name="display_viewonline" value="1" {DISPLAY_VIEWONLINE_ROOT} /> {L_ROOT}&nbsp;&nbsp;
			<input type="radio" name="display_viewonline" value="2" {DISPLAY_VIEWONLINE_ALWAYS} /> {L_ALWAYS}
		</td>
	</tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/forum_admin_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<form method="post" action="{S_FORUM_ACTION}"><table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center">
	<tr>

<!-- mod : hirarchie des rubriques -->
<!-- v 1.0.9 : colspan= 7 -> colspan={INC_SPAN} -->
		<th class="thHead" colspan="{INC_SPAN}">{L_FORUM_TITLE}</th>
<!-- fin mod : hirarchie des rubriques -->

	</tr>
	<!-- BEGIN catrow -->

<!-- mod : hirarchie des rubriques -->
	<tr>
		<!-- BEGIN inc -->
		<td class="row2"><span class="gen">&nbsp;&nbsp;</span></td>
		<!-- END inc -->
		<td class="{catrow.CLASS_CATLEFT}"   colspan="{catrow.INC_SPAN}"><span class="cattitle"><b><a href="{catrow.U_VIEWCAT}" class="cattitle">{catrow.CAT_DESC}</a></b></span></td>
		<td class="{catrow.CLASS_CATMIDDLE}" align="center" valign="middle"><span class="gen"><a href="{catrow.U_CAT_EDIT}" class="gen">{L_EDIT}</a></span></td>
		<td class="{catrow.CLASS_CATMIDDLE}" align="center" valign="middle"><span class="gen"><a href="{catrow.U_CAT_DELETE}" class="gen">{L_DELETE}</a></span></td>
		<td class="{catrow.CLASS_CATMIDDLE}" align="center" valign="middle" nowrap="nowrap"><span class="gen"><a href="{catrow.U_CAT_MOVE_UP}" class="gen">{L_MOVE_UP}</a> <a href="{catrow.U_CAT_MOVE_DOWN}" class="gen">{L_MOVE_DOWN}</a></span></td>
		<td class="{catrow.CLASS_CATRIGHT}"  align="center" valign="middle"><span class="gen">&nbsp</span></td>
	</tr>
	<tr>
		<!-- BEGIN inc -->
		<td class="row2"></td>
		<!-- END inc -->
		<td class="row3" colspan="{catrow.INC_SPAN_ALL}"><span class="gensmall">{catrow.CAT_DESCRIPTION}</span></td>
	</tr>
<!-- fin mod : hirarchie des rubriques -->

	<!-- BEGIN forumrow -->
	<tr> 

<!-- mod : hirarchie des rubriques -->
<!-- add v1.0.9 -->
		<!-- BEGIN inc -->
		<td class="row2"><span class="gen">&nbsp;&nbsp;</span></td>
		<!-- END inc -->
	
<!-- v 1.0.9 : add colspan={catrow.forumrow.INC_SPAN} -->
		<td class="row2" colspan="{catrow.forumrow.INC_SPAN}"><span class="gen"><a href="{catrow.forumrow.U_VIEWFORUM}" target="_new">{catrow.forumrow.FORUM_NAME}</a></span><br /><span class="gensmall">{catrow.forumrow.FORUM_DESC}</span></td>
<!-- fin mod : hirarchie des rubriques -->

		<td class="row1" align="center" valign="middle"><span class="gen">{catrow.forumrow.NUM_TOPICS}</span></td>
		<td class="row2" align="center" valign="middle"><span class="gen">{catrow.forumrow.NUM_POSTS}</span></td>
		<td class="row1" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_EDIT}">{L_EDIT}</a></span></td>
		<td class="row2" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_DELETE}">{L_DELETE}</a></span></td>
		<td class="row1" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_MOVE_UP}">{L_MOVE_UP}</a> <br /> <a href="{catrow.forumrow.U_FORUM_MOVE_DOWN}">{L_MOVE_DOWN}</a></span></td>
		<td class="row2" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_RESYNC}">{L_RESYNC}</a></span></td>
	</tr>
	<!-- END forumrow -->

<!-- mod : hirarchie des rubriques -->
<!-- v 1.0.9 : add inc + colspan=7 -> colspan={catrow.INC_SPAN_ALL} -->
	<tr>
		<!-- BEGIN inc -->
		<td class="row2"><span class="gen">&nbsp;&nbsp;</span></td>
		<!-- END inc -->
		<td colspan="{catrow.INC_SPAN_ALL}" class="row2"><input class="post" type="text" name="{catrow.S_ADD_FORUM_NAME}" /> <input type="submit" class="liteoption"  name="{catrow.S_ADD_FORUM_SUBMIT}" value="{L_CREATE_FORUM}" /></td>
	</tr>
	<tr>
		<!-- BEGIN inc -->
		<td class="row2"></td>
		<!-- END inc -->
		<td colspan="{catrow.INC_SPAN_ALL}" height="1" class="spaceRow"><img src="../templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td>
	</tr>
	<!-- END catrow -->
	<tr>
		<td colspan="{INC_SPAN}" class="catBottom"><input class="post" type="text" name="categoryname" /> <input type="submit" class="liteoption"  name="addcategory" value="{L_CREATE_CATEGORY}" /></td>
	</tr>
<!-- fin mod : hirarchie des rubriques -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<form method="post" action="{S_FORUM_ACTION}">
<table width="100%" cellpadding="4" cellspacing="1" border="0">
<tr>
	<td><span class="nav"><a href="{S_FORUM_ACTION}" class="nav">{L_INDEX}</a>{NAV_CAT_DESC}</span></td>
</tr>
</table>

<table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center">
<tr>
	<th class="thLeft" colspan="{INC_SPAN}" width="75%">{L_FORUM_TITLE}</th>
	<th class="thRight" colspan="4" width="25%">{L_ACTION}</th>
</tr>
<!-- BEGIN catrow -->
<!-- BEGIN cathead -->
<tr>
	<!-- BEGIN inc -->
	<td class="row2" rowspan="{catrow.cathead.inc.ROWSPAN}" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td class="{catrow.cathead.CLASS_CATLEFT}"   colspan="{catrow.cathead.INC_SPAN}" {catrow.cathead.WIDTH}><span class="cattitle"><b><a href="{catrow.cathead.U_VIEWCAT}" class="cattitle">{catrow.cathead.CAT_TITLE}</a></b></span></td>
	<td class="{catrow.cathead.CLASS_CATMIDDLE}" align="center" valign="middle"><span class="gen"><a href="{catrow.cathead.U_CAT_EDIT}" class="gen">{L_EDIT}</a></span></td>
	<td class="{catrow.cathead.CLASS_CATMIDDLE}" align="center" valign="middle"><span class="gen"><a href="{catrow.cathead.U_CAT_DELETE}" class="gen">{L_DELETE}</a></span></td>
	<td class="{catrow.cathead.CLASS_CATMIDDLE}" align="center" valign="middle" nowrap="nowrap"><span class="gen"><a href="{catrow.cathead.U_CAT_MOVE_UP}" class="gen">{L_MOVE_UP}</a> <a href="{catrow.cathead.U_CAT_MOVE_DOWN}" class="gen">{L_MOVE_DOWN}</a></span></td>
	<td class="{catrow.cathead.CLASS_CATRIGHT}"  align="center" valign="middle"><span class="gen">&nbsp;</span></td>
</tr>
<!-- END cathead -->
<!-- BEGIN cattitle -->
<tr>
	<td class="row3" colspan="{catrow.cattitle.INC_SPAN_ALL}"><span class="gensmall">{catrow.cattitle.CAT_DESCRIPTION}</span></td>
</tr>
<!-- END cattitle -->
<!-- BEGIN forumrow -->
<tr> 
	<!-- BEGIN inc -->
	<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td class="row2" colspan="{catrow.forumrow.INC_SPAN}" {catrow.forumrow.WIDTH}><table cellpadding="0" cellspacing="0" width="100%"><tr><td>{catrow.forumrow.LINK_IMG}</td><td width="100%"><span class="gen"><a href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a></span><br /><span class="gensmall">{catrow.forumrow.FORUM_DESC}</span></td></tr></table></td>
	<td class="row1" align="center" valign="middle"><span class="gen">{catrow.forumrow.NUM_TOPICS}</span></td>
	<td class="row2" align="center" valign="middle"><span class="gen">{catrow.forumrow.NUM_POSTS}</span></td>
	<td class="row1" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_EDIT}">{L_EDIT}</a></span></td>
	<td class="row2" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_DELETE}">{L_DELETE}</a></span></td>
	<td class="row1" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_MOVE_UP}">{L_MOVE_UP}</a> <br /> <a href="{catrow.forumrow.U_FORUM_MOVE_DOWN}">{L_MOVE_DOWN}</a></span></td>
	<td class="row2" align="center" valign="middle"><span class="gen"><a href="{catrow.forumrow.U_FORUM_RESYNC}">{L_RESYNC}</a></span></td>
</tr>
<!-- END forumrow -->
<!-- BEGIN catfoot -->
<tr>
	<!-- BEGIN inc -->
	<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td colspan="{catrow.catfoot.INC_SPAN_ALL}" class="row2" nowrap="nowrap">
		<img src="{SPACER}" width="46" height="0" />
		<input class="post" type="text" name="{catrow.catfoot.S_ADD_NAME}" />&nbsp;
		<input type="submit" class="liteoption"  name="{catrow.catfoot.S_ADD_FORUM_SUBMIT}" value="{L_CREATE_FORUM}" />
		<input type="submit" class="liteoption"  name="{catrow.catfoot.S_ADD_CAT_SUBMIT}" value="{L_CREATE_CATEGORY}" />
	</td>
</tr>
<tr>
	<!-- BEGIN inc -->
	<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td colspan="{catrow.catfoot.INC_SPAN_ALL}" height="1" class="spaceRow"><img src="{SPACER}" width="46" height="0" /></td>
</tr>
<!-- END catfoot -->
<!-- END catrow -->
<tr>
	<td colspan="{INC_SPAN_ALL}" class="catBottom">
		<!-- BEGIN switch_board_footer -->
		<input class="post" type="text" name="name[0]" />&nbsp;
		<!-- BEGIN sub_forum_attach -->
		<input type="submit" class="liteoption"  name="addforum[0]" value="{L_CREATE_FORUM}" />
		<!-- END sub_forum_attach -->
		<input type="submit" class="liteoption"  name="addcategory[0]" value="{L_CREATE_CATEGORY}" />
		<!-- END switch_board_footer -->
	</td>
</tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/forum_delete_body.tpl
#
#-----[ FIND ]------------------------------------------------
# at top of the file
<h1>{L_FORUM_DELETE}</h1>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : categories hierarchy v 2 -->
#
#-----[ FIND ]------------------------------------------------
#
	  <td class="row1"><span class="row1">{NAME}</span></td>
	</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
	<tr> 
	  <td class="row1">{L_FORUM_DESC}</td>
	  <td class="row1"><span class="row1">{DESC}</span></td>
	</tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<h1>{L_FORUM_TITLE}</h1>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : categories hierarchy v 2 -->
#
#-----[ FIND ]------------------------------------------------
#
	<tr> 
	  <td class="catBottom" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="mainoption" /></td>
	</tr>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	<tr>
		<td class="row1">{L_LINK}&nbsp;</td>
		<td class="row2" align="center">
			<table cellspacing="0" cellpadding="3" border="0">
			<tr>
				<td align="right">{L_FORUM_LINK}&nbsp;</td>
				<td>
					<input type="text" name="forum_link" value="{FORUM_LINK}" size="60" class="post" /><br />
					<span class="gensmall">{L_FORUM_LINK_EXPLAIN}</span>
				</td>
			</tr>
			<tr>
				<td align="right">{L_FORUM_LINK_INTERNAL}&nbsp;</td>
				<td>
					<input type="radio" name="forum_link_internal" value="1" {FORUM_LINK_INTERNAL_YES} />&nbsp;{L_YES}&nbsp;&nbsp;<input type="radio" name="forum_link_internal" value="0" {FORUM_LINK_INTERNAL_NO} />&nbsp;{L_NO}<br />
					<span class="gensmall">{L_FORUM_LINK_INTERNAL_EXPLAIN}</span>
				</td>
			</tr>
			<tr>
				<td align="right">{L_FORUM_LINK_HIT_COUNT}&nbsp;</td>
				<td>
					<input type="radio" name="forum_link_hit_count" value="1" {FORUM_LINK_HIT_COUNT_YES} />&nbsp;{L_YES}&nbsp;&nbsp;<input type="radio" name="forum_link_hit_count" value="0" {FORUM_LINK_HIT_COUNT_NO} />&nbsp;{L_NO}<br />
					<span class="gensmall">&nbsp;{L_FORUM_LINK_HIT_COUNT_EXPLAIN}</span>
				</td>
			</tr>
			</table>
		</td>
	</tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/page_header.tpl
#
#-----[ FIND ]------------------------------------------------
#
/*-- mod : hirarchie des rubriques */
td.catRupt {
         background-color:#BCCED7;
         background-image: url(../templates/subSilver/images/cellpic4.gif);
}
/*-- fin mod : hirarchie des rubriques */

/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
/*
  Setting additional nice inner borders for the main table cells.
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM