diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 8deb8100c72..ceb878a2de9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2005-2019 Laurent Destailleur * Copyright (C) 2005-2016 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -763,7 +763,7 @@ if ($action == 'create') print '

'; print ''; - print ''; + print ''; print ''; @@ -906,6 +906,11 @@ else print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print ''; // Errors to @@ -913,6 +918,11 @@ else print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); print ''; // Nb of distinct emails diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 706153e897c..9e820a6d608 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -229,6 +229,7 @@ if ($object->fetch($id) >= 0) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); + $nbok = ($nbtry - $nbko); $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); @@ -244,10 +245,39 @@ if ($object->fetch($id) >= 0) print ''; - print ''; + print ''; // Errors to - print ''; // Nb of distinct emails diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index eb15710eb7c..aafda1197f6 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1489,6 +1489,7 @@ class CMailFile * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists * If format 5: John Doe or john@doe.com if no label exists + * @see getArrayAddress() */ public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { @@ -1560,6 +1561,7 @@ class CMailFile * * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' * @return array array of email => name + * @see getValidAddress() */ public function getArrayAddress($address) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7671c50a09c..dd0d145be96 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -285,7 +285,7 @@ class Form } $ret .= $tmpcontent; } - else $ret .= $value; + else $ret .= dol_escape_htmltag($value); if ($formatfunc && method_exists($object, $formatfunc)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 76e1105f113..ce556c0f91b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2149,7 +2149,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) * @param int $socid Id of third party if known * @param int $addlink 0=no link, 1=email has a html email link (+ link to create action if constant AGENDA_ADDACTIONFOREMAIL is on) * @param int $max Max number of characters to show - * @param int $showinvalid Show warning if syntax email is wrong + * @param int $showinvalid 1=Show warning if syntax email is wrong * @param int $withpicto Show picto * @return string HTML Link */ @@ -2191,7 +2191,7 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, } } - $rep = '
'.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'
'; + $rep = '
'.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'
'; if ($hookmanager) { $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email);
'.$langs->trans("MailTopic").'
'.$langs->trans("MailTopic").'
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($_POST['bgcolor'], 'bgcolor', '', 0); print '
'; print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); + $email = CMailFile::getValidAddress($object->email_from, 2); + if (!isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } print '
'; print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->rights->mailing->creer && $object->statut < 3, 'string'); + $email = CMailFile::getValidAddress($object->email_errorsto, 2); + if (!isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } print '
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'.$langs->trans("MailFrom").''; + $emailarray = CMailFile::getArrayAddress($object->email_from); + foreach($emailarray as $email => $name) { + if ($name && $name != $email) { + print dol_escape_htmltag($name).' <'.$email; + print '>'; + if (!isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } + } else { + print dol_print_email($object->email_from, 0, 0, 0, 0, 1); + } + } + //print dol_print_email($object->email_from, 0, 0, 0, 0, 1); + //var_dump($object->email_from); + print '
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); + print '
'.$langs->trans("MailErrorsTo").''; + $emailarray = CMailFile::getArrayAddress($object->email_errorsto); + foreach($emailarray as $email => $name) { + if ($name != $email) { + print dol_escape_htmltag($name).' <'.$email; + print '>'; + if (!isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } + } else { + print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); + } + } print '