<?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
*/

  if (!defined('ROOTPATH')) die;

  $sql = "SELECT mboxname FROM mgw_webmail2_mailboxes WHERE mboxname=".$conn->Quote('public');
  if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
  $row = $res->FetchRow();

  if (!isset($row["mboxname"])) {
    $sql = "INSERT INTO mgw_webmail2_mailboxes (createdby,created,mbox_id, user_id, mboxname, mboxparent, mbox_protect,isintrash,isdraft) VALUES (1,0,1, 0,'public', 0,1,0,0)";
    if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  }
	
  $sql = "SELECT mboxname FROM mgw_webmail2_mailboxes WHERE mboxname=".$conn->Quote('publictrash');
  if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
  $row = $res->FetchRow();

  if (!isset($row["mboxname"])) {
    $sql = "INSERT INTO mgw_webmail2_mailboxes (createdby,created,mbox_id, user_id, mboxname, mboxparent, mbox_protect,isintrash,isdraft) VALUES (1,0,2, 0,'publictrash', 0,1,1,0)";
    if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  }
  
  $sql = "SELECT mailboxname FROM mgw_webmail2_accounts WHERE mailboxname=".$conn->Quote('default');
  if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
  $row = $res->FetchRow();

  if (!isset($row["mailboxname"])) {
    $sql = "INSERT INTO mgw_webmail2_accounts (imap_show_numbers,enable_smtp,folderid,copyfolderid,usermaychange,mailboxname, servertype, pophost, smtphost, smtpauth, smtpusepopuser, usemailfunction, smtpusername, smtppassword, username, password, leavemessages, popbeforesmtp, enable_ssl, enable_ssl_smtp, activated, fullname, replyto, user_id, leaveoldmails, id) VALUES ('checked','checked',-1,-1,'checked','default', 'wm2_servertype_pop3', 'pop3host', 'smtphost', '', '', '', '', '', '\$username', '', '', '', '', '', 'checked', '\$fullusername', '\$email', 1, NULL, 0)";
    if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,__FILE__));
  }
?>
