diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index a36102affab..56aea4e8355 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -6,7 +6,9 @@ * Copyright (C) 2023 Anthony Berton * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2024-2025 MDW - * + * Copyright (C) 2026 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 * the Free Software Foundation; either version 3 of the License, or @@ -102,6 +104,9 @@ if ($action == 'update' && !$cancel) { 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", GETPOSTINT("MAIN_MAIL_ENABLED_USER_DEST_SELECT"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'MAIN_MAIL_NO_WITH_TO_SELECTED', GETPOSTINT('MAIN_MAIL_NO_WITH_TO_SELECTED'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS', GETPOST('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS', 'restricthtml'), '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", GETPOSTINT("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity); @@ -670,6 +675,12 @@ if ($action == 'edit') { 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 ''; + // Global signature for all users employees + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS', getDolGlobalString('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'), '', 138, 'dolibarr_notes', 'In', true, true, !getDolGlobalString('FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, 0, '90%'); + $text = $langs->trans("MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS"); + $texthelp = $langs->trans("MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS_Help"); + print ''.$form->textwithpicto($text, $texthelp, 1, 'help').''.$doleditor->Create(1).''; print ''; print ''; @@ -999,7 +1010,12 @@ if ($action == 'edit') { print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn(getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')).''; //Disable autoselect to print ''.$langs->trans("MAIN_MAIL_NO_WITH_TO_SELECTED").''.yn(getDolGlobalString('MAIN_MAIL_NO_WITH_TO_SELECTED')).''; - + // Global signature for all users employees + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS', getDolGlobalString('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'), '', 138, 'dolibarr_notes', 'In', true, true, !getDolGlobalString('FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, 0, '90%', 1); + $text = $langs->trans("MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS"); + $texthelp = $langs->trans("MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS_Help"); + print ''.$form->textwithpicto($text, $texthelp, 1, 'help').''.$doleditor->Create(1).''; print ''; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0e328b7ce9f..e6a2096836e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -17,7 +17,7 @@ * Copyright (C) 2019-2023 Thibault Foucart * Copyright (C) 2020 Open-Dsi * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2022 Anthony Berton + * Copyright (C) 2022-2026 Anthony Berton * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2022-2026 Charlene Benke * Copyright (C) 2024-2026 MDW @@ -10226,6 +10226,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, //var_dump($onlykey); $emailsendersignature = $user->signature; // By default, we use the signature of current user. We must complete substitution with signature in c_email_senderprofile of array after calling getCommonSubstitutionArray() $usersignature = $user->signature; + if (getDolGlobalString('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS') && !empty($user->employee)) { + $emailsendersignature = getDolGlobalString('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'); + $usersignature = getDolGlobalString('MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS'); + } $substitutionarray = array_merge($substitutionarray, array( '__SENDEREMAIL_SIGNATURE__' => (string) ((!getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ? dol_trunc('SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) : ''), '__USER_SIGNATURE__' => (string) (($usersignature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($usersignature), 30) : $usersignature) : '') diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5d6658482bb..cd77df9774e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -324,6 +324,8 @@ 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=Disable the selection of a default recipient when writing an email, even if there is only 1 possible choice +MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS=Signature for all employee user +MAIN_MAIL_DEFAULT_SIGNATURE_FOR_ALL_USERS_Help=User signatures will be replaced by this one. Leave the field empty to keep the user signatures. MAIN_MAIL_SENDMODE=Sending method MAIN_MAIL_SMTPS_ID=SMTP username or ID (if sending server requires an authentication) MAIN_MAIL_SMTPS_PW=SMTP password or token (if sending server requires an authentication)