From a9a03df8cf8cf575bf746e452696d1121944651f Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Wed, 25 Jan 2023 23:56:57 +0100 Subject: [PATCH] NEW - Do not select a default recipient --- htdocs/admin/mails.php | 8 ++++++++ htdocs/core/class/html.formmail.class.php | 10 +++++++--- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index e9a8132188c..e71bcca1e16 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -86,6 +86,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); @@ -114,6 +115,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; } @@ -628,6 +630,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 ''; @@ -904,6 +910,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 c81ccb769ab..cdc8231514e 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1076,10 +1076,14 @@ class FormMail extends Form $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtoselected = GETPOST("receiver", 'array'); // Array of selected value + if (getDolGlobalInt('MAIN_MAIL_NO_WITH_TO_SELECTED')) { + $withtoselected = ''; + } else { + $withtoselected = GETPOST("receiver", 'array'); // Array of selected value - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { - $withtoselected = array_keys($tmparray); + 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 8e0acd832d5..74453822955 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -298,6 +298,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)