Fix error when email list contains ', ,'

Fix output dir of notification
This commit is contained in:
Laurent Destailleur 2018-01-29 20:36:40 +01:00
parent 1834be79a0
commit 8102883356

View File

@ -397,13 +397,13 @@ class Notify
break; break;
case 'FICHINTER_ADD_CONTACT': case 'FICHINTER_ADD_CONTACT':
$link='/fichinter/card.php?id='.$object->id; $link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output; $dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter'; $object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$object->ref);
break; break;
case 'FICHINTER_VALIDATE': case 'FICHINTER_VALIDATE':
$link='/fichinter/card.php?id='.$object->id; $link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output; $dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter'; $object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break; break;
@ -651,8 +651,9 @@ class Notify
} }
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
$sendto = preg_replace('/^[\s,]+/','',$sendto); // Clean start of string $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid
$sendto = preg_replace('/[\s,]+$/','',$sendto); // Clean end of string $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
} }
if ($sendto) if ($sendto)