From 85af3ad513121d0158e4a9b5983dda227cc4f0df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Dec 2018 10:24:57 +0100 Subject: [PATCH] NEW Unsubscribed emails are now stored in dedicated table --- .../core/modules/mailings/modules_mailings.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index f7136d4aa63..d3158ba9775 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -166,7 +166,7 @@ class MailingTargets // This can't be abstract as it is used for some method $this->db->begin(); - // Insert emailing targest from array into database + // Insert emailing targets from array into database $j = 0; $num = count($cibles); foreach ($cibles as $targetarray) @@ -211,6 +211,7 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(get_class($this)."::".__METHOD__.": mailing ".$j." targets added"); + /* //Update the status to show thirdparty mail that don't want to be contacted anymore' $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; @@ -219,8 +220,6 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(get_class($this)."::".__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted"); $result=$this->db->query($sql); - - //Update the status to show contact mail that don't want to be contacted anymore' $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; @@ -228,11 +227,23 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))"; dol_syslog(get_class($this)."::".__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG); $result=$this->db->query($sql); + */ + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " SET statut=3"; + $sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; + + dol_syslog(get_class($this)."::".__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG); + $result=$this->db->query($sql); + if (! $result) + { + dol_print_error($this->db); + } $this->update_nb($mailing_id); $this->db->commit(); + return $j; }