diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index e4ad9c71bb6..a9c0071078d 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -1,8 +1,9 @@ - * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2016 Jonathan TISSEAU +/* Copyright (C) 2007-2020 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016 Jonathan TISSEAU + * Copyright (C) 2023 Anthony Berton * * 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 @@ -87,6 +88,7 @@ if ($action == 'update' && !$cancel) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'MAIN_MAIL_NO_WITH_TO_SELECTED', GETPOST('MAIN_MAIL_NO_WITH_TO_SELECTED', 'int'), 'chaine', 0, '', $conf->entity); // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity); @@ -115,6 +117,7 @@ if ($action == 'update' && !$cancel) { dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; } @@ -629,6 +632,10 @@ if ($action == 'edit') { print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT'), 1); print ''; + //Disable autoselect to + print ''.$langs->trans("MAIN_MAIL_NO_WITH_TO_SELECTED").''; + print $form->selectyesno('MAIN_MAIL_NO_WITH_TO_SELECTED', getDolGlobalString('MAIN_MAIL_NO_WITH_TO_SELECTED'), 1); + print ''; print ''; @@ -905,6 +912,8 @@ if ($action == 'edit') { //Add user to select destinaries list print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn(!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)).''; + //Disable autoselect to + print ''.$langs->trans("MAIN_MAIL_NO_WITH_TO_SELECTED").''.yn(!empty($conf->global->MAIN_MAIL_NO_WITH_TO_SELECTED)).''; print ''; print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b0be14cbb51..a4fe5628056 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1,11 +1,13 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2015-2017 Marcos García - * Copyright (C) 2015-2017 Nicolas ZABOURI - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2022 Charlene Benke +/* Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2015-2017 Marcos García + * Copyright (C) 2015-2017 Nicolas ZABOURI + * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Anthony Berton + * * * 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 @@ -1081,9 +1083,10 @@ class FormMail extends Form } $withtoselected = GETPOST("receiver", 'array'); // Array of selected value - - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { - $withtoselected = array_keys($tmparray); + if (!getDolGlobalInt('MAIN_MAIL_NO_WITH_TO_SELECTED')) { + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { + $withtoselected = array_keys($tmparray); + } } $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9c5d62fc38b..d2fdc06de93 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -301,6 +301,7 @@ MAIN_MAIL_AUTOCOPY_TO= Copy (Bcc) all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) MAIN_MAIL_ENABLED_USER_DEST_SELECT=Suggest emails of employees (if defined) into the list of predefined recipient when writing a new email +MAIN_MAIL_NO_WITH_TO_SELECTED=Do not select a default recipient even if single choice MAIN_MAIL_SENDMODE=Email sending method MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication) MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication)