($fUsername -> $fUsername)");
}
// apparently uppercase usernames really confuse some IMAP clients.
$fUsername = strtolower($fUsername);
$local_part = '';
if(preg_match('/^(.*)@/', $fUsername, $matches)) {
$local_part = $matches[1];
}
$result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')");
if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota))
{
$tDomain = $fDomain;
flash_error($PALANG['pCreate_mailbox_result_error'] . "
($fUsername)");
db_query('ROLLBACK');
}
else
{
db_query('COMMIT');
db_log ($fDomain, 'create_mailbox', "$fUsername");
$tDomain = $fDomain;
$tQuota = $CONF['maxquota'];
if ($fMail == "on")
{
$fTo = $fUsername;
$fFrom = $SESSID_USERNAME;
$fSubject = $PALANG['pSendmail_subject_text'];
$fBody = $CONF['welcome_text'];
if (!smtp_mail ($fTo, $fFrom, $fSubject, $fBody))
{
flash_error($PALANG['pSendmail_result_error']);
}
else
{
flash_info($PALANG['pSendmail_result_success']);
}
}
$tShowpass = "";
if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword";
if (create_mailbox_subfolders($fUsername,$fPassword))
{
flash_info($PALANG['pCreate_mailbox_result_success'] . "
($fUsername$tShowpass)");
} else {
flash_info($PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "
($fUsername$tShowpass)");
}
}
}
}
$smarty->assign ('mode', 'create');
$smarty->assign ('tUsername', $tUsername);
$smarty->assign ('tActive', ' checked="checked" '); # TODO: use form value if POST
$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain)), false);
$smarty->assign ('pCreate_mailbox_username_text_error', $pCreate_mailbox_username_text_error, false);
$smarty->assign ('mailbox_password_text_error', $pCreate_mailbox_password_text_error, false);
$smarty->assign ('tName', $tName, false);
$smarty->assign ('tQuota', $tQuota);
$smarty->assign ('mailbox_quota_text_error', $pCreate_mailbox_quota_text_error, false);
$smarty->assign ('smarty_template', 'edit-mailbox');
$smarty->display ('index.tpl');
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
?>