From a7d26409c748a180257c18d12d14af82b3ae2c4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Oct 2018 20:51:35 +0200 Subject: [PATCH] FIX trackid into email sent from member module. --- htdocs/adherents/card.php | 8 ++++++-- htdocs/adherents/class/adherent.class.php | 14 ++++++++++---- htdocs/adherents/subscription.php | 4 +++- htdocs/public/members/new.php | 4 +++- htdocs/public/payment/paymentok.php | 4 +++- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 48b731c0f50..a3df6705df9 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -639,7 +639,9 @@ if (empty($reshook)) $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, 2); + $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); if ($result < 0) { $error++; @@ -710,7 +712,9 @@ if (empty($reshook)) $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1); + $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } if ($result < 0) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a10ab55ad58..a7d350e971d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -125,7 +125,7 @@ class Adherent extends CommonObject /** - * Function sending an email has the adherent with the text supplied in parameter. + * Function sending an email to the current member with the text supplied in parameter. * * @param string $text Content of message (not html entities encoded) * @param string $subject Subject of message @@ -137,9 +137,10 @@ class Adherent extends CommonObject * @param int $deliveryreceipt Ask a delivery receipt * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection * @param string $errors_to erros to + * @param string $moreinheader Add more html headers * @return int <0 if KO, >0 if OK */ - function send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='') + function send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='') { global $conf,$langs; @@ -160,9 +161,11 @@ class Adherent extends CommonObject $from=$conf->email_from; if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; + $trackid = 'mem'.$this->id; + // Send email (substitutionarray must be done just before this) include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml); + $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader); if ($mailfile->sendfile()) { return 1; @@ -2617,8 +2620,11 @@ class Adherent extends CommonObject $from = $conf->global->ADHERENT_MAIL_FROM; $to = $adherent->email; + $trackid = 'mem'.$adherent->id; + $moreinheader='X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); $result = $cmail->sendfile(); if (! $result) { diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index f7a074106b9..b0b450b10a1 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -392,7 +392,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $listofmimes=array(dol_mimetype($file)); } - $result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1); + $moreinheader='X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1, '', $moreinheader); if ($result < 0) { $errmsg=$object->error; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b92e84b8352..144ab64328f 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -296,7 +296,9 @@ if ($action == 'add') if ($subjecttosend && $texttosend) { - $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1); + $moreinheader='X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } /*if ($result < 0) { diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 91c97098f33..7f4e6e67a2c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -550,7 +550,9 @@ if ($ispaymentok) $listofmimes=array(dol_mimetype($file)); } - $result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1); + $moreinheader='X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'."\r\n"; + + $result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, "", $moreinheader); if ($result < 0) {