diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php
index baf48447bad..83833304d44 100644
--- a/htdocs/comm/mailing/class/advtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/advtargetemailing.class.php
@@ -745,7 +745,16 @@ class AdvanceTargetingMailing extends CommonObject
$sqlwhere[]= " (t.civility IN ('".$this->db->escape(implode("','",$arrayquery['contact_civility']))."'))";
}
if ($arrayquery['contact_no_email']!='') {
- $sqlwhere[]= " (t.no_email='".$this->db->escape($arrayquery['contact_no_email'])."')";
+ $tmpwhere = '';
+ if (! empty($arrayquery['contact_no_email']))
+ {
+ $tmpwhere.= "(t.email IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
+ }
+ else
+ {
+ $tmpwhere.= "(t.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE t.entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($arrayquery['contact_no_email'])."'))";
+ }
+ $sqlwhere[]= $tmpwhere;
}
if ($arrayquery['contact_update_st_dt']!='') {
$sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')";
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 15cbe110a6a..3ca9c4ae6bc 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -194,7 +194,6 @@ if (empty($reshook))
$object->phone_mobile = GETPOST("phone_mobile",'alpha');
$object->fax = GETPOST("fax",'alpha');
$object->jabberid = GETPOST("jabberid",'alpha');
- $object->no_email = GETPOST("no_email",'int');
$object->priv = GETPOST("priv",'int');
$object->note_public = GETPOST("note_public",'none');
$object->note_private = GETPOST("note_private",'none');
@@ -367,7 +366,6 @@ if (empty($reshook))
$object->phone_mobile = GETPOST("phone_mobile",'alpha');
$object->fax = GETPOST("fax",'alpha');
$object->jabberid = GETPOST("jabberid",'alpha');
- $object->no_email = GETPOST("no_email",'int');
$object->priv = GETPOST("priv",'int');
$object->note_public = GETPOST("note_public",'none');
$object->note_private = GETPOST("note_private",'none');
@@ -651,8 +649,21 @@ else
print '
| '.$langs->trans("ContactVisibility").' | ';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 3cafedaeceb..a5297750386 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -123,7 +123,6 @@ class Contact extends CommonObject
public $birthday;
public $default_lang;
- public $no_email; // 1=Don't send e-mail to this contact, 0=do
public $ref_facturation; // Reference number of invoice for which it is contact
public $ref_contrat; // Nb de reference contrat pour lequel il est contact
@@ -372,7 +371,6 @@ class Contact extends CommonObject
$sql .= ", statut = ".$this->db->escape($this->statut);
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL");
$sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL");
- $sql .= ", no_email=".($this->no_email?"'".$this->db->escape($this->no_email)."'":"0");
$sql .= ", entity = " . $this->db->escape($this->entity);
$sql .= " WHERE rowid=".$this->db->escape($id);
@@ -709,7 +707,7 @@ class Contact extends CommonObject
$sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook,";
$sql.= " c.photo,";
- $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,";
+ $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
$sql.= " c.import_key,";
$sql.= " c.datec as date_creation, c.tms as date_modification,";
$sql.= " co.label as country, co.code as country_code,";
@@ -790,7 +788,6 @@ class Contact extends CommonObject
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->default_lang = $obj->default_lang;
- $this->no_email = $obj->no_email;
$this->user_id = $obj->user_id;
$this->user_login = $obj->user_login;
$this->canvas = $obj->canvas;
diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql
index 94cf869543d..00456e3ece6 100644
--- a/htdocs/install/mysql/tables/llx_socpeople.sql
+++ b/htdocs/install/mysql/tables/llx_socpeople.sql
@@ -53,7 +53,7 @@ create table llx_socpeople
whatsapp varchar(255), --
photo varchar(255),
- no_email smallint NOT NULL DEFAULT 0,
+ no_email smallint NOT NULL DEFAULT 0, -- deprecated. Use table llx_mailing_unsubscribe instead
priv smallint NOT NULL DEFAULT 0,
fk_user_creat integer DEFAULT 0, -- user qui a creel'enregistrement
fk_user_modif integer,
diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php
index 67672f19e7c..d04d6eb8020 100644
--- a/htdocs/public/emailing/mailing-unsubscribe.php
+++ b/htdocs/public/emailing/mailing-unsubscribe.php
@@ -100,19 +100,21 @@ if (! empty($tag) && ($unsuscrib=='1'))
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
- // Update status communication of thirdparty prospect (old data)
+ /*
+ // Update status communication of thirdparty prospect (old usage)
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)";
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
- // Update status communication of contact prospect (old data)
+ // Update status communication of contact prospect (old usage)
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='contact' AND source_id is not null)";
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
+ */
- // Update status communication of contact prospect (old data)
+ // Update status communication of email (new usage)
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')";
$resql=$db->query($sql);
diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php
index 9ffde3cdf80..edb429af0d3 100644
--- a/htdocs/webservices/server_contact.php
+++ b/htdocs/webservices/server_contact.php
@@ -105,7 +105,6 @@ $contact_fields = array(
'birthday' => array('name'=>'birthday','type'=>'xsd:string'),
'default_lang' => array('name'=>'default_lang','type'=>'xsd:string'),
'note' => array('name'=>'note','type'=>'xsd:string'),
- 'no_email' => array('name'=>'no_email','type'=>'xsd:string'),
'ref_facturation' => array('name'=>'ref_facturation','type'=>'xsd:string'),
'ref_contrat' => array('name'=>'ref_contrat','type'=>'xsd:string'),
'ref_commande' => array('name'=>'ref_commande','type'=>'xsd:string'),
@@ -295,7 +294,6 @@ function getContact($authentication,$id,$ref_ext)
'birthday' => $contact->birthday,
'default_lang' => $contact->default_lang,
'note' => $contact->note,
- 'no_email' => $contact->no_email,
'ref_facturation' => $contact->ref_facturation,
'ref_contrat' => $contact->ref_contrat,
'ref_commande' => $contact->ref_commande,
@@ -406,7 +404,6 @@ function createContact($authentication,$contact)
$newobject->birthday=$contact['birthday'];
$newobject->default_lang=$contact['default_lang'];
$newobject->note=$contact['note'];
- $newobject->no_email=$contact['no_email'];
$newobject->ref_facturation=$contact['ref_facturation'];
$newobject->ref_contrat=$contact['ref_contrat'];
$newobject->ref_commande=$contact['ref_commande'];
@@ -496,7 +493,7 @@ function getContactsForThirdParty($authentication,$idthirdparty)
$sql.= " c.fk_departement,";
$sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
- //$sql.= " c.priv, c.note, c.default_lang, c.no_email, c.canvas,";
+ //$sql.= " c.priv, c.note, c.default_lang, c.canvas,";
$sql.= " co.label as country, co.code as country_code,";
$sql.= " d.nom as state, d.code_departement as state_code,";
$sql.= " u.rowid as user_id, u.login as user_login,";
@@ -557,7 +554,6 @@ function getContactsForThirdParty($authentication,$idthirdparty)
'birthday' => $contact->birthday?$contact->birthday:'',
'default_lang' => $contact->default_lang?$contact->default_lang:'',
'note' => $contact->note?$contact->note:'',
- 'no_email' => $contact->no_email?$contact->no_email:'',
'ref_facturation' => $contact->ref_facturation?$contact->ref_facturation:'',
'ref_contrat' => $contact->ref_contrat?$contact->ref_contrat:'',
'ref_commande' => $contact->ref_commande?$contact->ref_commande:'',
|