mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 15:42:29 +01:00
Fix #18961 : no_email field has been replaced by mailing_unsubscribe table
This commit is contained in:
@@ -80,7 +80,7 @@ class mailing_contacts1 extends MailingTargets
|
||||
$statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$statssql[0] .= " WHERE c.entity IN (".getEntity('socpeople').")";
|
||||
$statssql[0] .= " AND c.email != ''"; // Note that null != '' is false
|
||||
$statssql[0] .= " AND c.no_email = 0";
|
||||
$statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0";
|
||||
$statssql[0] .= " AND c.statut = 1";
|
||||
|
||||
return $statssql;
|
||||
@@ -104,7 +104,6 @@ class mailing_contacts1 extends MailingTargets
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc";
|
||||
$sql .= " WHERE c.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " AND c.email != ''"; // Note that null != '' is false
|
||||
$sql .= " AND c.no_email = 0";
|
||||
$sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0";
|
||||
// exclude unsubscribed users
|
||||
$sql .= " AND c.statut = 1";
|
||||
@@ -132,9 +131,8 @@ class mailing_contacts1 extends MailingTargets
|
||||
$sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
/*$sql.= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql.= " AND sp.no_email = 0";
|
||||
$sql.= " AND sp.statut = 1";*/
|
||||
$sql .= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql .= " AND sp.statut = 1";
|
||||
$sql .= " AND (sp.poste IS NOT NULL AND sp.poste != '')";
|
||||
$sql .= " GROUP BY sp.poste";
|
||||
$sql .= " ORDER BY sp.poste";
|
||||
@@ -166,10 +164,9 @@ class mailing_contacts1 extends MailingTargets
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as sp,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie as c,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie_contact as cs";
|
||||
$sql .= " WHERE sp.statut = 1"; // Note that null != '' is false
|
||||
//$sql.= " AND sp.no_email = 0";
|
||||
//$sql.= " AND sp.email != ''";
|
||||
//$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql .= " AND sp.statut = 1";
|
||||
$sql .= " AND cs.fk_categorie = c.rowid";
|
||||
$sql .= " AND cs.fk_socpeople = sp.rowid";
|
||||
$sql .= " GROUP BY c.label";
|
||||
@@ -241,10 +238,9 @@ class mailing_contacts1 extends MailingTargets
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as sp,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie as c,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$sql .= " WHERE sp.statut = 1"; // Note that null != '' is false
|
||||
//$sql.= " AND sp.no_email = 0";
|
||||
//$sql.= " AND sp.email != ''";
|
||||
//$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql .= " AND sp.statut = 1";
|
||||
$sql .= " AND cs.fk_categorie = c.rowid";
|
||||
$sql .= " AND cs.fk_soc = sp.fk_soc";
|
||||
$sql .= " GROUP BY c.label";
|
||||
@@ -283,10 +279,9 @@ class mailing_contacts1 extends MailingTargets
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as sp,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie as c,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs";
|
||||
$sql .= " WHERE sp.statut = 1"; // Note that null != '' is false
|
||||
//$sql.= " AND sp.no_email = 0";
|
||||
//$sql.= " AND sp.email != ''";
|
||||
//$sql.= " AND sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql .= " AND sp.statut = 1";
|
||||
$sql .= " AND cs.fk_categorie = c.rowid";
|
||||
$sql .= " AND cs.fk_soc = sp.fk_soc";
|
||||
$sql .= " GROUP BY c.label";
|
||||
@@ -385,7 +380,6 @@ class mailing_contacts1 extends MailingTargets
|
||||
if ($filter_category_supplier <> 'all') $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " AND sp.email <> ''";
|
||||
$sql .= " AND sp.no_email = 0";
|
||||
$sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = sp.email) = 0";
|
||||
// Exclude unsubscribed email adresses
|
||||
$sql .= " AND sp.statut = 1";
|
||||
|
||||
@@ -209,24 +209,6 @@ class MailingTargets // This can't be abstract as it is used for some method
|
||||
|
||||
dol_syslog(__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";
|
||||
$sql .= " WHERE fk_mailing=".$mailing_id." AND email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)";
|
||||
$sql .= " AND source_type='thirdparty'";
|
||||
dol_syslog(__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";
|
||||
$sql .= " WHERE fk_mailing=".$mailing_id." AND source_type='contact' AND (email in (SELECT sc.email FROM ".MAIN_DB_PREFIX."socpeople AS sc ";
|
||||
$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(__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')."'))";
|
||||
|
||||
Reference in New Issue
Block a user