NEW Unsubscribed emails are now stored in dedicated table

This commit is contained in:
Laurent Destailleur 2018-12-11 10:24:57 +01:00
parent 5ec9a1ca7f
commit 85af3ad513

View File

@ -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;
}