Merge pull request #12811 from simicar29/develop

Avoid adding unsubscribed contacts in mailing list
This commit is contained in:
Laurent Destailleur 2020-01-10 00:18:12 +01:00 committed by GitHub
commit e36bf0261c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,6 +105,8 @@ class mailing_contacts1 extends MailingTargets
$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";
// The request must return a field called "nb" to be understandable by parent::getNbOfRecipients
@ -384,6 +386,8 @@ class mailing_contacts1 extends MailingTargets
$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";
$sql.= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
// Filter on category