2
0
forked from Wavyzz/dolibarr

FIX output of emails from and error on emailing pages.

This commit is contained in:
Laurent Destailleur
2019-12-13 15:52:08 +01:00
parent 95141550fa
commit d38c73c90a
5 changed files with 49 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2005-2019 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -763,7 +763,7 @@ if ($action == 'create')
print '</br><br>';
print '<table class="border centpercent">';
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet')).'"></td></tr>';
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet', 'alphanohtml')).'"></td></tr>';
print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor($_POST['bgcolor'], 'bgcolor', '', 0);
print '</td></tr>';
@@ -906,6 +906,11 @@ else
print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->rights->mailing->creer && $object->statut < 3, 'string');
print '</td><td>';
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 '</td></tr>';
// 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 '</td><td>';
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 '</td></tr>';
// Nb of distinct emails

View File

@@ -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 '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>';
print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">';
$emailarray = CMailFile::getArrayAddress($object->email_from);
foreach($emailarray as $email => $name) {
if ($name && $name != $email) {
print dol_escape_htmltag($name).' &lt;'.$email;
print '&gt;';
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 '</td></tr>';
// Errors to
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">';
$emailarray = CMailFile::getArrayAddress($object->email_errorsto);
foreach($emailarray as $email => $name) {
if ($name != $email) {
print dol_escape_htmltag($name).' &lt;'.$email;
print '&gt;';
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 '</td></tr>';
// Nb of distinct emails

View File

@@ -1489,6 +1489,7 @@ class CMailFile
* If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
* If format 4: 'John Doe' or 'john@doe.com' if no label exists
* If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> 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 <john@doe.com>, Alan Smith <alan@smith.com>' or 'john@doe.com, alan@smith.com'
* @return array array of email => name
* @see getValidAddress()
*/
public function getArrayAddress($address)
{

View File

@@ -285,7 +285,7 @@ class Form
}
$ret .= $tmpcontent;
}
else $ret .= $value;
else $ret .= dol_escape_htmltag($value);
if ($formatfunc && method_exists($object, $formatfunc))
{

View File

@@ -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 = '<div class="nospan float" style="margin-right: 10px">'.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'</div>';
$rep = '<div class="nospan" style="margin-right: 10px">'.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'</div>';
if ($hookmanager) {
$parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto);
$reshook = $hookmanager->executeHooks('printEmail', $parameters, $email);