<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once('auth.php');
include_once( dirname(__FILE__) . "/../include/class.MenuBlocks.php" );

$loUser = new SQLString($PHP_AUTH_USER);

$id = safe_query2( "select frontpage, cssl, maxmysql from anbieter where anbieter=?", $loUser);
$werte = db_fetch_array($id);

$items_enabled['users']['frontpage'] = $werte['frontpage'] ? true:false;
$items_enabled['users']['ssl'] = $werte['cssl']?true:false;
$items_enabled['users']['mysql'] = $werte['maxmysql']?true:false;

$general_open = true;
$users_open = false;
$items_enabled['genereal']['changepw'] = true;
$items_enabled['genereal']['design_language'] = true;
$items_enabled['genereal']['skins_editor'] = true;
if($PHP_AUTH_USER == 'res0')
{
	$general_open = false;
	$users_open = true;
	$items_enabled['genereal']['changepw'] = false;
	$items_enabled['genereal']['design_language'] = false;
	$items_enabled['genereal']['skins_editor'] = false;
}

$c_general = array(
	$gui->make_menu_item('overview', 
		ltext('m_overview'), 
		$gui->make_menu_target_int("allgemein_start.php")
	),
	$gui->make_menu_item('changepw', 
		ltext('ma_changepw'), 
		$gui->make_menu_target_int("allgemein_pwaendern.php", "alpw_descr1", "alpw_descr2"),
		$items_enabled['genereal']['changepw']
	),
	$gui->make_menu_item('design_language', 
		ltext('ma_selectlanguage'), 
		$gui->make_menu_target_int("allgemein_sprache.php", "alsp_title1", "alsp_descr1"),
		$items_enabled['genereal']['design_language']
	),
	$gui->make_menu_item('servermessages', 
		ltext('ma_servermessages'), 
		$gui->make_menu_target_int("allgemein_servermeldungen.php")
	),
	
	$gui->make_menu_item('skins_editor',
		ltext("sk_skins_editor"),
		$gui->make_menu_target_int("skins.php?action=editskins"),
		$items_enabled['genereal']['skins_editor']
	),
);

$c_templates = array(
	$gui->make_menu_item('overview', 
		ltext('m_overview'),
		$gui->make_menu_target_int("angebote_start.php")
	),
	$gui->make_menu_item('temp_create', 
		ltext('mang_create'),
		$gui->make_menu_target_int("angebote_neu.php", 'anne_title3', 'anne_descr1')
	),
	$gui->make_menu_item('temp_change', 
		ltext('mang_change'),
		$gui->make_menu_target_int("angebote_aendern.php", 'anae_title1')
	),
	$gui->make_menu_item('temp_delete', 
		ltext('mang_delete'),
		$gui->make_menu_target_int("angebote_loeschen.php")
	),
);


$c_users = array(
	$gui->make_menu_item('overview',
		ltext("m_overview"),
		$gui->make_menu_target_int("kunden_start.php")
	),
	$gui->make_menu_item('mailsetup',
		ltext("mk_mailsetup"),
		$gui->make_menu_target_int("kunden_email.php", 'kuem_title1', 'kuem_descr1')
	),
	$gui->make_menu_item('indexsetup',
		ltext("mk_indexsetup"),
		$gui->make_menu_target_int("kunden_index.php", 'kuem_title1', 'kuem_descr1')
	),
	$gui->make_menu_item('mailing',
		ltext("mk_mailing"),
		$gui->make_menu_target_int("kunden_rundschreiben.php", 'kuru_descr1', 'kuru_descr2')
	),
	$gui->make_menu_item('helpsetup',
		ltext("mk_helpsetup"),
		$gui->make_menu_target_int("kunden_hilfeseite.php", 'kuhi_descr1', 'kuhi_descr2')
	),
	$gui->make_menu_item('createuser',
		ltext("mk_createuser"),
		$gui->make_menu_target_int("kunden_neu1.php", 'kune1_title1', 'kune1_descr1')
	),
	$gui->make_menu_item('edituser',
		ltext("mk_edituser"),
		$gui->make_menu_target_int('kunden_aendern.php', 'kuae_title1')
	),
	$gui->make_menu_item('frontpage',
		ltext("mk_frontpage"),
		$gui->make_menu_target_int("kunden_frontpage.php", 'kufr_title1', 'kufr_descr1'),
		$items_enabled['users']['frontpage']
	),
	$gui->make_menu_item('ssl',
		ltext("mk_ssl"),
		$gui->make_menu_target_int("kunden_ssl.php", 'kuss_descr1', 'kuss_descr2'),
		$items_enabled['users']['ssl']
	),
	$gui->make_menu_item('mysql',
		ltext("mk_mysql"),
		$gui->make_menu_target_int("kunden_mysql.php", 'kumy_descr1'),
		$items_enabled['users']['mysql']
	),
);

$c_stats = array(
	$gui->make_menu_item('overview',
		ltext("m_overview"),
		$gui->make_menu_target_int("statistiken_start.php")
	),
	$gui->make_menu_item('traffic',
		ltext("ms_traffic"),
		$gui->make_menu_target_int("statistiken_transfer.php")
	),
);

$additional = array();
$custom = new MenuBlocks ( 'reseller' );
for ( $custom->Start(); $items = $custom->NextElement(); )
{
	$submenus = array(
		$gui->make_menu_item ( 'overview',
		ltext("m_overview"),
		$gui->make_menu_target_int("custom_start.php?menublock_id=".$custom->GetID()) )
	);
	for ( $items->Start(); $items->NextElement(); )
	{
		$menuItem = $items->GetInFrame()?
			$gui->make_menu_target_int($items->GetHRef()):
			$gui->make_menu_target_ext($items->GetHRef());
 
		$submenus[] = $gui->make_menu_item ( 'submenu'.$items->GetID(),
																				 $items->GetLabel(), 
																				 $menuItem
																				 );
	}

	$additional[] = $gui->make_menu_block( 'custom'.$custom->GetID(), $custom->GetLabel(), 'overview',  $submenus );
}

$nav_tree = $gui->make_navigation_container( array_merge ( array(
	$gui->make_menu_block('general',   
		ltext('m_general'),	'overview',	$c_general, $general_open),	//opened
	$gui->make_menu_block('templates',     
		ltext('m_templates'),   'overview', $c_templates),
	$gui->make_menu_block('users',        
		ltext('m_users'),      'overview', $c_users, $users_open),
	$gui->make_menu_block('stats',     
		ltext('m_stats'),   'overview', $c_stats),
	),
	$additional )
);

$menu = array($nav_tree);

$users = $PHP_AUTH_USER;
$shortcuts_items = false;
if($PHP_AUTH_USER == 'res0')
{
	$id = db_query('SELECT login FROM admin');
	$res = db_fetch_array($id);
	$users .= ',' . $res['login'] . ',' . $user_prefix . '0';
	$def_user = $user_prefix . '0';
	$shortcuts_items = array( $gui->make_shortcut_item('link_services', ltext('sh_services'), $gui->make_menu_target_top('../../admin/resredirect.php?type=' . USERTYPE_USER . '&reseller=' . $def_user)),
			$gui->make_shortcut_item('link_back_to_admin', ltext('sh_back_to_admin'), $gui->make_menu_target_top('retadmin.php')));
}

$menu[] = $gui->make_action_button('logout', ltext('m_logout'), $gui->make_menu_target_top('/logout.php?user=' . $users));

if($shortcuts_items)
{
	$menu[] = $gui->make_shortcuts_block($shortcuts_items); 
}

$page = $gui->make_left_menu($menu);

$op_block = 'general';
$op_item = 'overview';

if($PHP_AUTH_USER == 'res0')
{
	$op_block = 'users';
	$op_item = 'edituser';
	$page->set_default_url("kunden_aendern_fwd.php?kunde=${user_prefix}0&aktion=domains");
}

if(array_key_exists('op_block', $_GET) && array_key_exists('op_item', $_GET))
{
	$op_block = $_GET['op_block'];
	$op_item = $_GET['op_item'];
}

if(array_key_exists('op_url', $_GET))
{
    $page->set_default_url($_GET['op_url']);
}

$page->set_height(93);// height="93%" - 7% for SWsoft-logo
$page->set_default($op_block, $op_item);

$page->draw();
?>
