##############################################################
## MOD Title:		Categories hierarchy - Part 2 (std admin forum management) - install first MOD-cache
## MOD Author:		Ptirhiik < ptirhiik@clanmckeen.com > (Pierre) http://rpgnet.clanmckeen.com
## MOD Description:
##			This mod allows to attach a categorie to a higher level categorie,
##			keeping all the forum visible on the index page (vBulletin-like view),
##			or have a sub-forum view.
##			----------------------------------------------------------------------
##			o MOD-Cache part IS required : you have to install it, even if you don't plan to use it
##				Install it FIRST
##			o Part 1 is the main installation,
##			o Part 2 is the facultative modifications of the standard phpBB admin forums prog,
##			and is not required if you want to use the new admin forums tool.
##			----------------------------------------------------------------------
##
## MOD Version:		2.0.5-RC2
##
## Installation Level:	Moderate
## Installation Time:	~30 Minutes
## Files To Edit:
##			admin/admin_forums.php
##			templates/subSilver/admin/category_edit_body.tpl
##			templates/subSilver/admin/forum_admin_body.tpl
##			templates/subSilver/admin/forum_delete_body.tpl
##			templates/subSilver/admin/forum_edit_body.tpl
##
## Included Files: (n/a)
##############################################################
## 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:
##------------------------------------------------------------
##
##	MOD-cache will settle the cache system, and is required for categories hierarchy
##		if you don't have yet installed it, install it FIRST.
##	Part 1 of this mod will include the new admin forums tool to your board
##	Part 2 of this mod will modify the old admin forums phpBB progs, and is facultative
##
##------------------------------------------------------------
##
##	o This version includes a new forum administration option that will cover the forum management
##	and the forum permissions. You can still use the standards options, but if you prefer to use the
##	new tool, you will avoid to modify the admin_forums.php, so the mod will be easier to install.
##
##------------------------------------------------------------
##
##	This mod can be installed using Nutzzy's EasyMOD v Alpha3 0.0.11a3 & greater
##	( http://area51.phpbb.com/phpBB22/viewforum.php?sid=&f=15 ),
##	on a phpBB 2.0.4 to 2.0.10
##
##############################################################
## MOD History: (see part 1)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// ------------------
// Begin function block
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- 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_key = (isset($tree['keys'][ $type . $id ])) ? $tree['keys'][ $type . $id ] : -1;

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

	// renum objects of the same level and regenerate all
	$cats = array();
	$forums = array();
	$order = 0;
	$parents = array();
	for ($i=0; $i < count($tree['data']); $i++) 
	{
		if ($tree['main'][$i] == $main)
		{
			$order = $order + 10;
			$worder = ($i == $this_key) ? $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)
		{
			$idx = count($cats);
			$cats[$idx] = $tree['data'][$i];
			$parents[POST_CAT_URL][ $tree['main'][$i] ][] = $idx;
		}
		else
		{
			$idx = count($forums);
			$forums[$idx] = $tree['data'][$i];
			$parents[POST_FORUM_URL][ $tree['main'][$i] ][] = $idx;
		}
	}

	// build the tree
	$tree = array();
	cache_tree_level('Root', $parents, $cats, $forums);

	// 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 ]------------------------------------------------
#
				$forumstatus = $row['forum_status'];
#
#-----[ AFTER, 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']);
				$icon = $row['icon'];
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			}

			$catlist = get_list('category', $cat_id, TRUE);
#
#-----[ 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;
				$icon = '';
			}
			$catlist = get_tree_option( $main_type . $cat_id, true );
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				'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'],
				'L_ICON'							=> $lang['icon'],
				'L_ICON_EXPLAIN'					=> $lang['icon_explain'],
				'ICON'								=> $icon,
				'ICON_IMG'							=> empty($icon) ? '' : '<br /><img src="' . ( isset($images[$icon]) ? $phpbb_root_path . $images[$icon] : $icon ) . '" border="0" alt="' . $icon . '" title="' . $icon . '" />',
//-- 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_key = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this_key]['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 ]------------------------------------------------
#
				$field_sql .= ", $field";
				$value_sql .= ", $value";

			}

			// There is no problem having duplicate forum names so we won't check for it.
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- 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";
			$icon = isset($HTTP_POST_VARS['icon']) ? trim(stripslashes($HTTP_POST_VARS['icon'])) : '';
			$field_sql .= ", icon";
			$value_sql .= ", '$icon'";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
			$sql = "INSERT INTO " . FORUMS_TABLE . "
				VALUES ('" . $next_id . "',
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
// here we replaced
//	" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
// with
//	$cat_id
//-- modify
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
$cat_id
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql);
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			admin_check_cat();
			get_user_tree($userdata);
			move_tree('Root', 0, 0);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
					message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- 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_key = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this_key]['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'";
			}
			$icon = isset($HTTP_POST_VARS['icon']) ? trim(stripslashes($HTTP_POST_VARS['icon'])) : '';
			$field_value_sql .= ", icon = '$icon'";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full lines are longer
#
			$sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname'])
				WHERE forum_id =
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
// here we replaced
//	" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
// with
//	$cat_id
//
// and added
//	. $field_value_sql
//--- modify
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
" . intval($HTTP_POST_VARS[POST_CAT_URL]) . "
#
#-----[ IN-LINE REPLACE WITH ]--------------------------------
#
$cat_id
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
 . intval($HTTP_POST_VARS['prune_enable'])
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
#
 . $field_value_sql
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				else
				{
					$sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
						VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
				}

				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- 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
			$icon = isset($HTTP_POST_VARS['icon']) ? trim($HTTP_POST_VARS['icon']) : '';
			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_key = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this_key]['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)";
#
#-----[ 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, icon, cat_order)
				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', '" . $cat_main_type . "', " . $cat_main . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "', '" . str_replace("\'", "''", $icon) . "', $next_order)";
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't insert row in categories table", "", __LINE__, __FILE__, $sql);
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			admin_check_cat();
			get_user_tree($userdata);
			move_tree('Root', 0, 0);
			cache_tree(true);
			board_stats();
//-- 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 ]------------------------------------------------
#
			$cat_title = $row['cat_title'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				$cat_desc	= $row['cat_desc'];
				$icon = $row['icon'];
				$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  = '';
				$icon = '';
				$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 ]------------------------------------------------
#
				'L_EDIT_CATEGORY' => $lang['Edit_Category'],
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- 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,
				'L_ICON'					=> $lang['icon'],
				'L_ICON_EXPLAIN'			=> $lang['icon_explain'],
				'ICON'						=> $icon,
				'ICON_IMG'					=> empty($icon) ? '' : '<br /><img src="' . ( isset($images[$icon]) ? $phpbb_root_path . $images[$icon] : $icon ) . '" border="0" alt="' . $icon . '" title="' . $icon . '" />',
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		case 'modcat':
			// Modify a category in the DB
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$icon = isset($HTTP_POST_VARS['icon']) ? trim($HTTP_POST_VARS['icon']) : '';
			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_key = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this_key]['forum_link']))
				{
					message_die(GENERAL_ERROR, $lang['Forum_attached_to_link_denied']);
				}
			}

			// update db
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full lines are longer
#
			$sql = "UPDATE " . CATEGORIES_TABLE . "
				SET cat_title =
				WHERE cat_id =
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- 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']) . "', icon = '" . str_replace("\'", "''", $icon) . "'
//-- modify
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "'
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
#
, cat_main_type='" . $cat_main_type . "', cat_main = " . $cat_main . ", cat_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "', icon = '" . str_replace("\'", "''", $icon) . "'
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			message_die(GENERAL_MESSAGE, $message);

			break;
			
		case 'deleteforum':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
			$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_key = $tree['keys'][POST_FORUM_URL . $forum_id];
			$name = $tree['data'][$this_key]['forum_name'];
			$desc = $tree['data'][$this_key]['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 ]------------------------------------------------
#
			$to_id = intval($HTTP_POST_VARS['to_id']);
			$delete_old = intval($HTTP_POST_VARS['delete_old']);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- 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 ----------------------------------------------------------------
			$delete_old = intval($HTTP_POST_VARS['delete_old']);
#
#-----[ FIND ]------------------------------------------------
#
			$sql = "DELETE FROM " . PRUNE_TABLE . "
				WHERE forum_id = $from_id";
			if( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't delete forum prune information!", "", __LINE__, __FILE__, $sql);
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- 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">';
				$select_to .= get_list('category', $cat_id, 0);
				$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_key = $tree['keys'][POST_CAT_URL . $cat_id];
			$name = $tree['data'][$this_key]['cat_title'];
			$desc = $tree['data'][$this_key]['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_key] == 'Root')
			{
				// check if other main categories
				$found = false;
				for ($i=0; (($i < count($tree['data'])) && !$found); $i++)
				{
					$found = (($i != $this_key) && ($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 ]------------------------------------------------
#
				'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)
			);

			$template->pparse("body");
			break;

		case 'movedelcat':
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- 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 ----------------------------------------------------------------
			$template->pparse("body");
			break;

		case 'movedelcat':
#
#-----[ FIND ]------------------------------------------------
#
			$to_id = intval($HTTP_POST_VARS['to_id']);

			if (!empty($to_id))
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- 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 ----------------------------------------------------------------

			if (!empty($to_id))
#
#-----[ FIND ]------------------------------------------------
#
					message_die(GENERAL_ERROR, "Ambiguous category ID's", "", __LINE__, __FILE__);
				}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- 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 ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$sql = "UPDATE " . FORUMS_TABLE . "
					SET cat_id = $to_id
					WHERE cat_id = $from_id";
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
// here we added
//	" . $sql_feed . "
// and
//	 . $sql_where
//-- modify
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
$to_id
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
#
" . $sql_feed . "
#
#-----[ IN-LINE FIND ]---------------------------------------- 
#
$from_id"
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------- 
#
 . $sql_where
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql);
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			else if ( $to_fid == 'Root' )
			{
				$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']);
				}
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				message_die(GENERAL_ERROR, "Couldn't delete category", "", __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>");
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
			$err = admin_check_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$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 ]---------------------------------------- 
#
//-- 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);
			cache_tree(true);
			board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$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');
#
#-----[ 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] ];
			cache_tree(true);
			board_stats();
//-- 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 ]------------------------------------------------
#
	'L_RESYNC' => $lang['Resync'])
);
#
#-----[ AFTER, ADD ]------------------------------------------
#
#************************************************************************************
#					NOTE :
#					------
# /!\ Important : I strongly recommand to mute all the lines between the nexts 
#     ---------  			/* and */ 
#		by adding // in front of each lines or by deleting all.
#
# ie: //	for($i = 0; $i < $total_categories; $i++)
#
#************************************************************************************
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
/*
#
#-----[ FIND ]------------------------------------------------
#
}// if ... total_categories
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- add
*/
function display_admin_index($cur='Root', $level=0, $max_level=-1)
{
	global $template, $phpbb_root_path, $phpEx, $lang, $images;
	global $tree;

	// display the level
	$this_key = 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_key >= -1)
	{
		// cat header row
		if ($tree['type'][$this_key] == POST_CAT_URL)
		{
			// display a cat row
			$cat = $tree['data'][$this_key];
			$cat_id = $tree['id'][$this_key];

			// 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;

			// title and icon
			$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;
			}
			$cat_icon = empty($cat['icon']) ? '' : '<img src="' . ( isset($images[ $cat['icon'] ]) ? $phpbb_root_path . $images[ $cat['icon'] ] : $cat['icon'] ) . '" border="0" alt="' . $cat['icon'] . '" title="' . $cat['icon'] . '" />';

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

				'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
			for ($k=1; $k <= $level; $k++)
			{
				$template->assign_block_vars('catrow.cathead.inc', array());
			}
		}

		// forum header row
		if ($tree['type'][$this_key] == POST_FORUM_URL)
		{
			$forum = $tree['data'][$this_key];
			$forum_id = $tree['id'][$this_key];
			$forum_link_img = '';
			if (!empty($tree['data'][$this_key]['forum_link']))
			{
				$forum_link_img = '<img src="' . $phpbb_root_path . $images['link'] . '" border="0" />';
			}
			else
			{
				$sub = (isset($tree['sub'][POST_FORUM_URL . $forum_id]));
				$forum_link_img = '<img src="' . $phpbb_root_path . (($sub) ? $images['category'] : $images['forum']) . '" border="0" />';
				if ($tree['data'][$this_key]['forum_status'] == FORUM_LOCKED)
				{
					$forum_link_img = '<img src="' . $phpbb_root_path . (($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,
				'ICON_IMG'			=> empty($forum['icon']) ? '' : '<img src="' . ( isset($images[ $forum['icon'] ]) ? $phpbb_root_path . $images[ $forum['icon'] ] : $forum['icon'] ) . '" border="0" alt="' . $forum['icon'] . '" title="' . $forum['icon'] . '" />',
				'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_key] == 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'			=> $phpbb_root_path . $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 ]------------------------------------------------
#
templates/subSilver/admin/category_edit_body.tpl
#
#-----[ FIND ]------------------------------------------------
# at top of the file
<h1>{L_EDIT_CATEGORY}</h1>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : categories hierarchy v 2 -->
#
#-----[ FIND ]------------------------------------------------
#
	  <td class="row2"><input class="post" type="text" size="25" name="cat_title" value="{CAT_TITLE}" /></td>
	</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
	<tr>
	  <td class="row1">{L_CAT_DESCRIPTION}</td>
	  <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="cat_desc" class="post">{CAT_DESCRIPTION}</textarea></td>
	</tr>
	<tr>
		<td class="row1"><span class="gen">{L_ICON}</span><span class="gensmall"><br />{L_ICON_EXPLAIN}</span></td>
		<td class="row2"><span class="gen"><input name="icon" value="{ICON}" type="text" class="post" size="60" />{ICON_IMG}</span></td>
	</tr>
	<tr>
	  <td class="row1">{L_CATEGORY_ATTACHMENT}</td>
	  <td class="row2"><select name="cat_main">{S_CAT_LIST}</select></td>
	</tr>
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/forum_admin_body.tpl
#
#-----[ FIND ]------------------------------------------------
# at top of the file
<h1>{L_FORUM_TITLE}</h1>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
<!-- mod : categories hierarchy v 2 -->
#
#-----[ FIND ]------------------------------------------------
#
<p>{L_FORUM_EXPLAIN}</p>

<form method="post" action="{S_FORUM_ACTION}"><table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center">
#
#-----[ REPLACE WITH ]----------------------------------------
#
<p>{L_FORUM_EXPLAIN}</p>
<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">
#
#-----[ FIND ]------------------------------------------------
#
	<tr>
		<th class="thHead" colspan="7">{L_FORUM_TITLE}</th>
	</tr>
	<!-- BEGIN catrow -->
	<tr>
		<td class="catLeft" colspan="3"><span class="cattitle"><b><a href="{catrow.U_VIEWCAT}">{catrow.CAT_DESC}</a></b></span></td>
		<td class="cat" align="center" valign="middle"><span class="gen"><a href="{catrow.U_CAT_EDIT}">{L_EDIT}</a></span></td>
		<td class="cat" align="center" valign="middle"><span class="gen"><a href="{catrow.U_CAT_DELETE}">{L_DELETE}</a></span></td>
		<td class="cat" align="center" valign="middle" nowrap="nowrap"><span class="gen"><a href="{catrow.U_CAT_MOVE_UP}">{L_MOVE_UP}</a> <a href="{catrow.U_CAT_MOVE_DOWN}">{L_MOVE_DOWN}</a></span></td>
		<td class="catRight" align="center" valign="middle"><span class="gen">&nbsp</span></td>
	</tr>
	<!-- BEGIN forumrow -->
	<tr> 
		<td class="row2"><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>
		<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 -->
	<tr>
		<td colspan="7" 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>
		<td colspan="7" height="1" class="spaceRow"><img src="../templates/subSilver/images/spacer.gif" alt="" width="1" height="1" /></td>
	</tr>
	<!-- END catrow -->
	<tr>
		<td colspan="7" class="catBottom"><input class="post" type="text" name="categoryname" /> <input type="submit" class="liteoption"  name="addcategory" value="{L_CREATE_CATEGORY}" /></td>
	</tr>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<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" 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>
<tr>
	<!-- BEGIN inc -->
	<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td class="row3" colspan="{catrow.cathead.INC_SPAN}"><table cellpadding="2" cellspacing="0" border="0" width="100%"><tr><td>{catrow.cathead.ICON_IMG}</td><td width="100%"><span class="gensmall">{catrow.cathead.CAT_DESCRIPTION}</span></td></tr></table></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
</tr>
<!-- END cathead -->
<!-- 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>{catrow.forumrow.ICON_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 ]------------------------------------------------
#
	  <td class="row2"><textarea rows="5" cols="45" wrap="virtual" name="forumdesc" class="post">{DESCRIPTION}</textarea></td>
#
#-----[ AFTER, ADD ]------------------------------------------
#
	</tr>
	<tr>
		<td class="row1"><span class="gen">{L_ICON}</span><span class="gensmall"><br />{L_ICON_EXPLAIN}</span></td>
		<td class="row2"><span class="gen"><input name="icon" value="{ICON}" type="text" class="post" size="60" />{ICON_IMG}</span></td>
#
#-----[ 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>
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM