diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index efb6e394834..9b5d6319e27 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,27 +32,37 @@ $langs->load("mails"); if (!$user->admin) accessforbidden(); +$action = GETPOST("action"); /* * Actions */ -if ($_POST["action"] == 'setvalue' && $user->admin) +if ($action == 'setvalue' && $user->admin) { - $result1=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$_POST["MAILING_EMAIL_FROM"],'chaine',0,'',$conf->entity); - $result2=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$_POST["MAILING_EMAIL_ERRORSTO"],'chaine',0,'',$conf->entity); - if (($result1 + $result2) == 2) - { - $mesg='
'.$langs->trans("Success").'
'; - } - else - { - dol_print_error($db); + $db->begin(); + + $mailfrom = GETPOST("MAILING_EMAIL_FROM"); + $mailerror = GETPOST("MAILING_EMAIL_ERRORSTO"); + + $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + + if (! $error) + { + $db->commit(); + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $db->rollback(); + $mesg = "".$langs->trans("Error").""; } } - /* * View */ @@ -93,10 +104,8 @@ print ''; print ''; print ''; - $db->close(); - llxFooter(); ?>