Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.48k stars 2.8k forks source link

FROM field becomes empty upon saving email template [EASY FIX PROPOSED AND TESTED] #31997

Closed caos30 closed 3 days ago

caos30 commented 3 days ago

Bug

When modifying an email template (on Admin Tools) the "email_from" field is being saved as empty value. It worked fine on version 20.0.0 but on 20.0.1 & 20.0.2 it fails.

The problem and solutions is very easy @eldy , i think that it was a simple missing fault, just on file

/htdocs/admin/mail_templates.php (line #477) 

now appears this:

if ($field == 'topic') {
    $_POST['topic'] = GETPOST('topic-'.$rowid);
}
if ($field == 'joinfiles') {
    $_POST['joinfiles'] = GETPOST('joinfiles-'.$rowid);
}
if ($field == 'content') {
    $_POST['content'] = GETPOST('content-'.$rowid, 'restricthtml');
}
if ($field == 'content_lines') {
    $_POST['content_lines'] = GETPOST('content_lines-'.$rowid, 'restricthtml');
}

And it's missing another IF for email_from field:

if ($field == 'email_from') {
    $_POST['email_from'] = GETPOST('email_from-'.$rowid);
}

Perhaps you also would like to add somekind of "well-formed email address" check before to save the email... i don't know. But in any case, this simple patch solve the problem saving this field of the email template.

Dolibarr Version

20.0.1 & 20.0.2

Environment PHP

No response

Environment Database

No response

Steps to reproduce the behavior and expected behavior

  1. try to modify an existing email template
  2. set a "From" email address and save changes
  3. modify again the same template and you will see that "From" box is empty

Note: the saving works fine when CREATING a template, but not when MODIFYING it.

Attached files

No response

daowanatel commented 2 days ago

actually the file is /htdocs/admin/mails_templates.php