($fUsername -> $fUsername)";
}
/*
# TODO: The following code segment is from admin/create-mailbox.php. To be compared/merged with the code from /create-mailbox.php.
Lines starting with /* were inserted to keep this section in commented mode.
$result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir',$quota,'$fDomain',NOW(),NOW(),'$sqlActive')");
if ($result['rows'] != 1)
{
$tDomain = $fDomain;
$tMessage .= $PALANG['pCreate_mailbox_result_error'] . "
($fUsername)
";
}
else
{
$error=TRUE; // Being pessimistic
if (mailbox_postcreation($fUsername,$fDomain,$maildir))
{
if ('pgsql'==$CONF['database_type'])
{
$result=db_query("COMMIT");
/* should really not be possible: */
/*
if (!$result) die('COMMIT-query failed.');
}
$error=FALSE;
} else {
$tMessage .= $PALANG['pCreate_mailbox_result_error'] . "
($fUsername)
";
if ('pgsql'==$CONF['database_type'])
{
$result=db_query("ROLLBACK");
/* should really not be possible: */
/*
if (!$result) die('ROLLBACK-query failed.');
} else {
/*
When we cannot count on transactions, we need to move forward, despite
the problems.
*/
/*
$error=FALSE;
}
}
if (!$error)
{
db_log ($CONF['admin_email'], $fDomain, 'create_mailbox', $fUsername);
*/
/*
TODO: this is the start of /create-mailbox code segment that was originally used in /create-mailbox.php instead
of the above from admin/create-mailbox.php.
To be compared / merged.
*/
$result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$sqlActive')");
if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir))
{
$tDomain = $fDomain;
$tMessage .= $PALANG['pCreate_mailbox_result_error'] . "
($fUsername)
";
db_query('ROLLBACK');
}
else
{
db_query('COMMIT');
db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");
/*
TODO: this is the end of /create-mailbox.php code segment
*/
$tDomain = $fDomain;
if (create_mailbox_subfolders($fUsername,$fPassword))
{
$tMessage = $PALANG['pCreate_mailbox_result_success'] . "
($fUsername";
} else {
$tMessage = $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "
($fUsername";
}
if ($CONF['generate_password'] == "YES")
{
$tMessage .= " / $fPassword)";
}
else
{
if ($CONF['show_password'] == "YES")
{
$tMessage .= " / $fPassword)";
}
else
{
$tMessage .= ")";
}
}
$tQuota = $CONF['maxquota'];
if ($fMail == "on")
{
$fTo = $fUsername;
$fFrom = $SESSID_USERNAME;
$fHeaders = "To: " . $fTo . "\n";
$fHeaders .= "From: " . $fFrom . "\n";
if (!empty ($PALANG['charset']))
{
$fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text'], $PALANG['charset']) . "\n";
$fHeaders .= "MIME-Version: 1.0\n";
$fHeaders .= "Content-Type: text/plain; charset=" . $PALANG['charset'] . "\n";
$fHeaders .= "Content-Transfer-Encoding: 8bit\n";
}
else
{
$fHeaders .= "Subject: " . $PALANG['pSendmail_subject_text'] . "\n\n";
}
$fHeaders .= $CONF['welcome_text'];
if (!smtp_mail ($fTo, $fFrom, $fHeaders))
{
$tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
";
}
else
{
$tMessage .= "
" . $PALANG['pSendmail_result_success'] . "
";
}
}
}
}
}
include ("$incpath/templates/header.tpl");
if (authentication_has_role('global-admin')) {
include ("$incpath/templates/admin_menu.tpl");
} else {
include ("$incpath/templates/menu.tpl");
}
include ("$incpath/templates/create-mailbox.tpl");
include ("$incpath/templates/footer.tpl");
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
?>