<?php
/*
This file is part of Thomas Bley's moregroupware webmail2/calendar2/admin2 module. (tb-mgw)

More information:
-----------------

Simple Groupware Solutions Thomas Bley
Fichtenstr. 23
Germany, 85640 Putzbrunn

Contact:
--------

info@simple-groupware.de

http://www.simple-groupware.de


Copyright 2002-2003 Thomas Bley
tb-mgw is distributed under the terms of the GNU General Public License 

tb-mgw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

tb-mgw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with tb-mgw; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// Settings
// Moregroupware.org

$myEnv["module"] = "webmail2";
$myEnv["stdsmenu"] = false;
$myEnv["output"] = "html";

	require_once("../../config.inc.php");
    $enable_top = true;
	require_once(INCLUDEPATH . "container.inc.php");
	
	$smarty->assign("custom_font",$_SESSION["MGW"]->settings["wm2_compose_font"]);
	$smarty->assign("custom_font_size",$_SESSION["MGW"]->settings["wm2_compose_font_size"]);

	$myvars = array("account","type","action","showpwd");
	foreach ($myvars as $thevar) {
	  ${$thevar} = (isset($_GET[$thevar])) ? $_GET[$thevar] : (isset($_POST[$thevar]) ? $_POST[$thevar] : "");
	}

	error_reporting  (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

	$moduleinclude	= ROOTPATH . "/modules/" . $myEnv['module'] . "/inc/";

	$smarty->assign("mytarget","_top");
	$smarty->assign("mysendmail","index.php?rightframe=sendmail.php?test&");
	$smarty->assign("myfetchmail","index.php?rightframe=fetchmail.php");

    $smarty->assign("myimgpathmaster", "templates/default/media");

	switch ($action)
	{
		case "newaccount":
			require_once($moduleinclude . "webmail2_settings_newaccount.php");
			newaccount($conn, $smarty,false,$type);
			break;

		case "make_default":
			$_POST["option"] = "";
			require_once("../settings/inc/settings_func.inc.php");
			store_flag ("wm2_default_account","webmail2","str");
			updateSettingsInDB("wm2_default_account", (int)$account);
			require_once($moduleinclude . "webmail2_settings_listaccounts.php");
			listaccounts($conn, $smarty);
			break;

		case "newaccountsave":
			require_once($moduleinclude . "webmail2_settings_newaccount.php");
			if (newaccountsave($conn,$smarty)) {
			  redirect("settings.php?action=listaccounts&".SID);
			} else {
			  require_once($moduleinclude . "webmail2_settings_newaccount.php");
			  newaccount($conn, $smarty,true,$type);
			}
			break;

		case "listaccounts":
			require_once($moduleinclude . "webmail2_settings_listaccounts.php");
			listaccounts($conn, $smarty);
			break;

		case "editaccount":
			require_once($moduleinclude . "webmail2_settings_editaccount.php");
			editaccount($conn, $smarty,$account);
			break;

		case "deleteaccount":
			require_once($moduleinclude . "webmail2_settings_editaccount.php");
			deleteaccount($conn, $smarty,$account);
			redirect("settings.php?action=listaccounts&".SID);
			break;

		case "editaccountsave":
			require_once($moduleinclude . "webmail2_settings_editaccount.php");
			editaccountsave($conn, $smarty);
			redirect("settings.php?action=listaccounts&".SID);
			break;

		// Show the settings menu
		default:
		   $MGW = $_SESSION["MGW"];
                   $username = $MGW->username;

		   $smarty->assign("username", $username);

		   $smarty->assign("js","");
		   $smarty->display('webmail2_settings_menu.tpl');
		   
		   break;
	}
?>
