From a9a03df8cf8cf575bf746e452696d1121944651f Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Wed, 25 Jan 2023 23:56:57 +0100 Subject: [PATCH 1/3] 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) From 3db523b4c6f0eec755d32e520e73dc1bb5dacddb Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Thu, 26 Jan 2023 10:46:59 +0100 Subject: [PATCH 2/3] Cop --- htdocs/admin/mails.php | 9 +++++---- htdocs/core/class/html.formmail.class.php | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index e71bcca1e16..d93f5e865fb 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 diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index cdc8231514e..439a52d95a5 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 From 27866f6811226f2f03260a8571ed66dcac6f95c7 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Wed, 1 Feb 2023 01:04:29 +0100 Subject: [PATCH 3/3] error only 1 receiver in select --- htdocs/core/class/html.formmail.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 439a52d95a5..7871b8e82cb 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1078,11 +1078,8 @@ class FormMail extends Form $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - if (getDolGlobalInt('MAIN_MAIL_NO_WITH_TO_SELECTED')) { - $withtoselected = ''; - } else { - $withtoselected = GETPOST("receiver", 'array'); // Array of selected value - + $withtoselected = GETPOST("receiver", 'array'); // Array of selected value + if (!getDolGlobalInt('MAIN_MAIL_NO_WITH_TO_SELECTED')) { if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); }