Merge pull request #11384 from ATM-Consulting/7.0_fix_mass_send_mail

FIX mass send mail
This commit is contained in:
Laurent Destailleur 2019-06-24 15:34:06 +02:00 committed by GitHub
commit 04606ec6a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 114 additions and 50 deletions

View File

@ -216,22 +216,22 @@ class Adherent extends CommonObject
'__ID__'=>$this->id, '__ID__'=>$this->id,
'__MEMBER_ID__'=>$this->id, '__MEMBER_ID__'=>$this->id,
'__CIVILITY__'=>$this->getCivilityLabel(), '__CIVILITY__'=>$this->getCivilityLabel(),
'__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname, '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):($this->firstname?$this->firstname:''),
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname, '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):($this->lastname?$this->lastname:''),
'__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs), '__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe, '__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):($this->societe?$this->societe:''),
'__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address, '__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):($this->address?$this->address:''),
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip, '__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):($this->zip?$this->zip:''),
'__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town, '__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):($this->town?$this->town:''),
'__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country, '__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):($this->country?$this->country:''),
'__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email, '__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):($this->email?$this->email:''),
'__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday, '__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):($birthday?$birthday:''),
'__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo, '__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):($this->photo?$this->photo:''),
'__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login, '__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):($this->login?$this->login:''),
'__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass, '__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):($this->pass?$this->pass:''),
'__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone, '__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):($this->phone?$this->phone:''),
'__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso, '__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):($this->phone_perso?$this->phone_perso:''),
'__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile, '__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):($this->phone_mobile?$this->phone_mobile:'')
); );
complete_substitutions_array($substitutionarray, $langs, $this); complete_substitutions_array($substitutionarray, $langs, $this);

View File

@ -69,6 +69,8 @@ if (! $error && $massaction == 'confirm_presend')
$listofobjectid=array(); $listofobjectid=array();
$listofobjectthirdparties=array(); $listofobjectthirdparties=array();
$listofobjectref=array(); $listofobjectref=array();
$attachedfilesThirdpartyObj=array();
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
if (! $error) if (! $error)
{ {
@ -93,7 +95,7 @@ if (! $error && $massaction == 'confirm_presend')
} }
// Check mandatory parameters // Check mandatory parameters
if (empty($user->email)) if (GETPOST('fromtype','alpha') === 'user' && empty($user->email))
{ {
$error++; $error++;
setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
@ -193,7 +195,6 @@ if (! $error && $massaction == 'confirm_presend')
$sendtocc=implode(',',$tmparray); $sendtocc=implode(',',$tmparray);
//var_dump($listofobjectref);exit; //var_dump($listofobjectref);exit;
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
$listofqualifiedobj=array(); $listofqualifiedobj=array();
$listofqualifiedref=array(); $listofqualifiedref=array();
$thirdpartywithoutemail=array(); $thirdpartywithoutemail=array();
@ -208,7 +209,7 @@ if (! $error && $massaction == 'confirm_presend')
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>'; $resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>';
continue; // Payment done or started or canceled continue; // Payment done or started or canceled
} }
if ($objectclass == 'Commande' && $objectoj->statut == Commande::STATUS_DRAFT) if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT)
{ {
$langs->load("errors"); $langs->load("errors");
$nbignored++; $nbignored++;
@ -263,12 +264,12 @@ if (! $error && $massaction == 'confirm_presend')
if (dol_is_file($file)) if (dol_is_file($file))
{ {
// Create form object // Create form object
$attachedfiles=array( $attachedfilesThirdpartyObj[$thirdpartyid][$objectid]=array(
'paths'=>array_merge($attachedfiles['paths'],array($file)), 'paths'=>array($file),
'names'=>array_merge($attachedfiles['names'],array($filename)), 'names'=>array($filename),
'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) 'mimes'=>array($mime)
); );
} }
else else
{ {
@ -333,12 +334,16 @@ if (! $error && $massaction == 'confirm_presend')
if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
// $listofqualifiedobj is array with key = object id of qualified objects for the current thirdparty // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
$looparray=array(); $looparray=array();
if (! $oneemailperrecipient) if (! $oneemailperrecipient)
{ {
$looparray = $listofqualifiedobj; $looparray = $listofqualifiedobj;
foreach ($looparray as $key => $objecttmp)
{
$looparray[$key]->thirdparty = $thirdparty;
}
} }
else else
{ {
@ -347,8 +352,9 @@ if (! $error && $massaction == 'confirm_presend')
$looparray[0]=$objectforloop; $looparray[0]=$objectforloop;
} }
//var_dump($looparray);exit; //var_dump($looparray);exit;
dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient);
foreach ($looparray as $objecttmp) // $objecttmp is a real object or an empty if we choose to send one email per thirdparty instead of per record //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref);
foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object
{ {
// Make substitution in email content // Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
@ -358,20 +364,54 @@ if (! $error && $massaction == 'confirm_presend')
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$parameters=array('mode'=>'formemail'); $parameters=array('mode'=>'formemail');
if ( ! empty( $listofobjectthirdparties ) ) {
$parameters['listofobjectthirdparties'] = $listofobjectthirdparties;
}
if ( ! empty( $listofobjectref ) ) {
$parameters['listofobjectref'] = $listofobjectref;
}
complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
$subject=make_substitutions($subject, $substitutionarray); $subjectreplaced=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray); $messagereplaced=make_substitutions($message, $substitutionarray);
$attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
if($oneemailperrecipient)
{
// if "one email per recipient" isn't check we must collate $attachedfiles by thirdparty
if(is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id]))
{
foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){
// Create form object
$attachedfiles=array(
'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']),
'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']),
'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes'])
);
}
}
}
elseif(!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){
// Create form object
// if "one email per recipient" isn't check we must separate $attachedfiles by object
$attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
}
$filepath = $attachedfiles['paths']; $filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names']; $filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes']; $mimetype = $attachedfiles['mimes'];
//var_dump($filepath); //var_dump($filepath);
// Send mail (substitutionarray must be done just before this) // Send mail (substitutionarray must be done just before this)
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
if ($mailfile->error) if ($mailfile->error)
{ {
$resaction.='<div class="error">'.$mailfile->error.'</div>'; $resaction.='<div class="error">'.$mailfile->error.'</div>';
@ -386,8 +426,12 @@ if (! $error && $massaction == 'confirm_presend')
$error=0; $error=0;
// Insert logs into agenda // Insert logs into agenda
foreach($listofqualifiedobj as $objid => $objectobj) foreach($listofqualifiedobj as $objid2 => $objectobj2)
{ {
if ((! $oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level
dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2));
/*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
if ($objectclass == 'Commande') $actiontypecode='AC_COM'; if ($objectclass == 'Commande') $actiontypecode='AC_COM';
if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
@ -399,18 +443,18 @@ if (! $error && $massaction == 'confirm_presend')
if ($message) if ($message)
{ {
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subjectreplaced);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message); $actionmsg = dol_concatdesc($actionmsg, $messagereplaced);
} }
$actionmsg2=''; $actionmsg2='';
// Initialisation donnees // Initialisation donnees
$objectobj->sendtoid = 0; $objectobj2->sendtoid = 0;
$objectobj->actionmsg = $actionmsg; // Long text $objectobj2->actionmsg = $actionmsg; // Long text
$objectobj->actionmsg2 = $actionmsg2; // Short text $objectobj2->actionmsg2 = $actionmsg2; // Short text
$objectobj->fk_element = $objid; $objectobj2->fk_element = $objid2;
$objectobj->elementtype = $objectobj->element; $objectobj2->elementtype = $objectobj2->element;
$triggername = strtoupper(get_class($objectobj)) .'_SENTBYMAIL'; $triggername = strtoupper(get_class($objectobj)) .'_SENTBYMAIL';
if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL';
@ -425,9 +469,9 @@ if (! $error && $massaction == 'confirm_presend')
if (! empty($triggername)) if (! empty($triggername))
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers($triggername, $objectobj, $user, $langs, $conf); $result=$interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf);
if ($result < 0) { $error++; $errors=$interface->errors; } if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
@ -437,9 +481,9 @@ if (! $error && $massaction == 'confirm_presend')
dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR); dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR);
} }
} }
$nbsent++;
} }
$nbsent++; // Nb of email sent (may be lower than number of record selected if we group thirdparties)
} }
else else
{ {
@ -504,6 +548,8 @@ if ($massaction == 'confirm_createbills')
$objecttmp = new Facture($db); $objecttmp = new Facture($db);
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
else { else {
// Load extrafields of order
$cmd->fetch_optionals();
$objecttmp->socid = $cmd->socid; $objecttmp->socid = $cmd->socid;
$objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->type = Facture::TYPE_STANDARD;
@ -521,6 +567,8 @@ if ($massaction == 'confirm_createbills')
$objecttmp->origin = 'commande'; $objecttmp->origin = 'commande';
$objecttmp->origin_id = $id_order; $objecttmp->origin_id = $id_order;
$objecttmp->array_options = $cmd->array_options; // Copy extrafields
$res = $objecttmp->create($user); $res = $objecttmp->create($user);
if($res > 0) $nb_bills_created++; if($res > 0) $nb_bills_created++;
@ -560,6 +608,12 @@ if ($massaction == 'confirm_createbills')
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
// If we build one invoice for several order, we must put the invoice of order on the line
if (! empty($createbills_onebythird))
{
$desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs));
}
if ($lines[$i]->subprice < 0) if ($lines[$i]->subprice < 0)
{ {
// Negative line, we create a discount line // Negative line, we create a discount line
@ -670,6 +724,7 @@ if ($massaction == 'confirm_createbills')
if (! $error && $validate_invoices) if (! $error && $validate_invoices)
{ {
$massaction = $action = 'builddoc'; $massaction = $action = 'builddoc';
foreach($TAllFact as &$objecttmp) foreach($TAllFact as &$objecttmp)
{ {
$result = $objecttmp->validate($user); $result = $objecttmp->validate($user);
@ -687,7 +742,12 @@ if ($massaction == 'confirm_createbills')
$donotredirect = 1; $donotredirect = 1;
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer; $permissioncreate=$user->rights->facture->creer;
// Call action to build doc
$savobject = $object;
$object = $objecttmp;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
$object = $savobject;
} }
$massaction = $action = 'confirm_createbills'; $massaction = $action = 'confirm_createbills';
@ -696,7 +756,7 @@ if ($massaction == 'confirm_createbills')
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
setEventMessage($langs->trans('BillCreated', $nb_bills_created)); setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
// Make a redirect to avoid to bill twice if we make a refresh or back // Make a redirect to avoid to bill twice if we make a refresh or back
$param=''; $param='';

View File

@ -908,7 +908,6 @@ class FormMail extends Form
$defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage); $defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage);
$defaultmessage=preg_replace("/^\n+/","",$defaultmessage); $defaultmessage=preg_replace("/^\n+/","",$defaultmessage);
} }
$out.= '<tr>'; $out.= '<tr>';
$out.= '<td valign="top">'.$langs->trans("MailText").'</td>'; $out.= '<td valign="top">'.$langs->trans("MailText").'</td>';
$out.= '<td>'; $out.= '<td>';

View File

@ -5733,6 +5733,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitition for array $substitutionarray // Make substitition for array $substitutionarray
foreach ($substitutionarray as $key => $value) foreach ($substitutionarray as $key => $value)
{ {
if (! isset($value)) continue; // If value is null, it same than not having substitution key at all into array, we do not replace.
if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection
if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection

View File

@ -36,11 +36,12 @@ if ($massaction == 'presend')
{ {
$langs->load("mails"); $langs->load("mails");
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
if (! GETPOST('cancel', 'alpha')) if (! GETPOST('cancel', 'alpha'))
{ {
$listofselectedid = array();
$listofselectedthirdparties = array();
$listofselectedref = array();
foreach ($arrayofselected as $toselectid) foreach ($arrayofselected as $toselectid)
{ {
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
@ -106,7 +107,8 @@ if ($massaction == 'presend')
$formmail->withtoreadonly = 1; $formmail->withtoreadonly = 1;
} }
$formmail->withoptiononeemailperrecipient = empty($liste)?0:((GETPOST('oneemailperrecipient')=='on')?1:-1); $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1);
$formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste; $formmail->withto = empty($liste)?(GETPOST('sendto','alpha')?GETPOST('sendto','alpha'):array()):$liste;
$formmail->withtofree = empty($liste)?1:0; $formmail->withtofree = empty($liste)?1:0;
$formmail->withtocc = 1; $formmail->withtocc = 1;
@ -125,6 +127,7 @@ if ($massaction == 'presend')
// Make substitution in email content // Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $object->thirdparty->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
$substitutionarray['__PERSONALIZED__'] = ''; // deprecated $substitutionarray['__PERSONALIZED__'] = ''; // deprecated