<?
########## 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('functions.inc.php');

$items_enabled['settings']['autoresponder'] = false;
$items_enabled['settings']['spamfilter'] = false;

$loKunde = new SQLString( $kunde );

$noemail = false;
$id = safe_query2( "SELECT admin.email AS email, kunden.maxemail AS maxemail ".
									 " FROM admin, kunden WHERE kunden.kunde = ?", $loKunde );
$werte = db_fetch_array($id);
if (($werte["email"] == 0) || ($werte["maxemail"] == 0))
{
	$id = safe_query2( "SELECT COUNT(kunde) AS email FROM email WHERE kunde = ?", $loKunde );
	$werte = db_fetch_array($id);
	if ($werte["email"] == 0)
	{
		$id = safe_query2( "SELECT COUNT(kunde) AS pop3 FROM pop3 WHERE kunde = ?", $loKunde );
		$werte = db_fetch_array($id);
		if ($werte["pop3"] == 0)
		{
			$noemail = true;
		}
	}	
}

$id = safe_query2( "SELECT COUNT(ident) AS autoresponder FROM autoresponder WHERE kunde = ?", $loKunde);
$werte = db_fetch_array($id);
$autoresponder = $werte["autoresponder"];

$id = safe_query2( "SELECT maxemail, maxautoresponder, spamfilter FROM kunden WHERE kunde = ?", $loKunde);
$werte = db_fetch_array($id);
$maxautoresponder = $werte["maxautoresponder"];


if(!$noemail)
{
	if(($autoresponder > 0) || ($maxautoresponder != 0))
	{
		$items_enabled['settings']['autoresponder'] = true;
	}
	if($werte["spamfilter"] == 1)
	{
		$items_enabled['settings']['spamfilter'] = true;
	}
}

$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", "")
	),
	$gui->make_menu_item('select_language', 
		ltext('ma_selectlanguage'), 
		$gui->make_menu_target_int("allgemein_sprache.php", "alsp_title1", "alsp_descr1")
	),
);


$c_email = array(
	$gui->make_menu_item('emaillist',
		ltext("m_postfach"),
		$gui->make_menu_target_int("email_postfach.php")
	),
	$gui->make_menu_item('newemail',
		ltext("m_emailneu"),
		$gui->make_menu_target_int("email_neu.php")
	),
	$gui->make_menu_item('adbook',
		ltext("m_adbook"),
		$gui->make_menu_target_int("email_adlist.php")
	),
);

$c_settings = array(
	$gui->make_menu_item('autoresponder',
		ltext("me_autoresponder"),
		$gui->make_menu_target_int("email_autoresponder.php"),
		$items_enabled['settings']['autoresponder']
	),
	$gui->make_menu_item('spamfilter',
		ltext("m_spam"),
		$gui->make_menu_target_int("email_spam_config.php"),
		$items_enabled['settings']['spamfilter']
	),
);

$general_open = false;
$op_block = 'email';
$op_item = 'emaillist';

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

$nav_tree = $gui->make_navigation_container(array(
	$gui->make_menu_block('general',   
		ltext('m_general'),	'overview',	$c_general, $general_open),	
	$gui->make_menu_block('email',        
		ltext('m_email'),      'overview', $c_email, true), //opened
	$gui->make_menu_block('setings',        
		ltext("m_settings"),      'overview', $c_settings),
));

$page = $gui->make_left_menu(array(
	$nav_tree,
	$gui->make_action_button('logout', ltext('m_logout'), $gui->make_menu_target_top('logout.php?user=' . $PHP_AUTH_USER))
	)
);
$page->set_default($op_block, $op_item);				// active
$page->draw();
db_close();
?>
