NEW Add option MAIN_MAIL_EMAIL_FROM_PASSWORDRESET

This commit is contained in:
Laurent Destailleur (aka Eldy) 2025-02-12 19:10:36 +01:00
parent 863248b618
commit fe3669621a
3 changed files with 68 additions and 11 deletions

View File

@ -382,6 +382,7 @@ if ($action == 'edit') {
clearstatcache();
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
@ -613,11 +614,11 @@ if ($action == 'edit') {
print '</td></tr>';
print '</table>';
print '</div>';
print '<br>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
@ -664,6 +665,7 @@ if ($action == 'edit') {
print '</td></tr>';
print '</table>';
print '</div>';
print dol_get_fiche_end();
@ -868,7 +870,7 @@ if ($action == 'edit') {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
print img_warning($langs->trans("ErrorBadEMail"));
print img_warning($langs->trans("ErrorBadEMail", getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')));
} else {
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
}
@ -892,7 +894,7 @@ if ($action == 'edit') {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) {
if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
print img_warning($langs->trans("ErrorBadEMail"));
print img_warning($langs->trans("ErrorBadEMail", getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')));
} else {
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
}
@ -910,7 +912,7 @@ if ($action == 'edit') {
if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM')) {
print img_warning($langs->trans("Mandatory"));
} elseif (!isValidEmail(getDolGlobalString('MAIN_MAIL_EMAIL_FROM'))) {
print img_warning($langs->trans("ErrorBadEMail"));
print img_warning($langs->trans("ErrorBadEMail", getDolGlobalString('MAIN_MAIL_EMAIL_FROM')));
}
print '</td></tr>';
@ -958,7 +960,7 @@ if ($action == 'edit') {
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
print '<td>'.(getDolGlobalString('MAIN_MAIL_ERRORS_TO'));
if (getDolGlobalString('MAIN_MAIL_ERRORS_TO') && !isValidEmail(getDolGlobalString('MAIN_MAIL_ERRORS_TO'))) {
print img_warning($langs->trans("ErrorBadEMail"));
print img_warning($langs->trans("ErrorBadEMail", getDolGlobalString('MAIN_MAIL_ERRORS_TO')));
}
print '</td></tr>';

View File

@ -104,6 +104,10 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_PASSWORDRESET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_PASSWORDRESET"), 'chaine', 0, '', $conf->entity);
if (GETPOSTISSET("MAIN_MAIL_EMAIL_FROM_PASSWORDRESET")) {
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM_PASSWORDRESET", GETPOST("MAIN_MAIL_EMAIL_FROM_PASSWORDRESET", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
}
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
}
@ -349,6 +353,7 @@ if ($action == 'edit') {
clearstatcache();
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td></td></tr>';
@ -553,6 +558,26 @@ if ($action == 'edit') {
print '</td></tr>';
print '</table>';
print '</div>';
print '<br>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
// From
$help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
print '<tr class="oddeven"><td class="">';
print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
print ' '.$help;
print '</td>';
print '<td><input class="flat minwidth300" name="MAIN_MAIL_EMAIL_FROM_PASSWORDRESET" value="'.getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET');
print '"></td></tr>';
print '</table>';
print '</div>';
print dol_get_fiche_end();
@ -685,6 +710,36 @@ if ($action == 'edit') {
print '</table>';
print '</div>';
print '<br>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("OtherOptions").'</td><td></td></tr>';
// From
$help = $form->textwithpicto('', $langs->trans("EMailHelpMsgSPFDKIM"));
print '<tr class="oddeven"><td>';
print $langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ? ini_get('sendmail_from') : $langs->transnoentities("Undefined"));
print ' '.$help;
print '</td>';
print '<td>';
if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET')) {
print '<span class="opacitymedium">'.getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'</span>';
} else {
print getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET');
}
if (!getDolGlobalString('MAIN_MAIL_EMAIL_FROM') && !getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET')) {
print img_warning($langs->trans("Mandatory"));
} elseif (getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET') && !isValidEmail(getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET'))) {
print img_warning($langs->trans("ErrorBadEMail", getDolGlobalString('MAIN_MAIL_EMAIL_FROM_PASSWORDRESET')));
}
print '</td></tr>';
print '</table>';
print '</div>';
print dol_get_fiche_end();

View File

@ -2663,12 +2663,12 @@ class User extends CommonObject
$outputlangs = new Translate("", $conf);
if (isset($this->conf->MAIN_LANG_DEFAULT)
&& $this->conf->MAIN_LANG_DEFAULT != 'auto') { // If user has defined its own language (rare because in most cases, auto is used)
$outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
&& getDolGlobalString('MAIN_LANG_DEFAULT') != 'auto') { // If user has defined its own language (rare because in most cases, auto is used)
$outputlangs->getDefaultLang(getDolGlobalString('MAIN_LANG_DEFAULT'));
}
if ($this->conf->MAIN_LANG_DEFAULT) {
$outputlangs->setDefaultLang($this->conf->MAIN_LANG_DEFAULT);
if (getDolGlobalString('MAIN_LANG_DEFAULT')) {
$outputlangs->setDefaultLang(getDolGlobalString('MAIN_LANG_DEFAULT'));
} else { // If user has not defined its own language, we used current language
$outputlangs = $langs;
}
@ -2729,7 +2729,7 @@ class User extends CommonObject
$mailfile = new CMailFile(
$subject,
$this->email,
$conf->global->MAIN_MAIL_EMAIL_FROM,
getDolGlobalString("MAIN_MAIL_EMAIL_FROM_PASSWORDRESET", getDolGlobalString("MAIN_MAIL_EMAIL_FROM")),
$mesg,
array(),
array(),