FIX #12198
This commit is contained in:
parent
8242281ef8
commit
f9c86256dc
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||||
@ -191,6 +191,7 @@ if (empty($reshook))
|
|||||||
$object->facebook = GETPOST("facebook", 'alpha');
|
$object->facebook = GETPOST("facebook", 'alpha');
|
||||||
$object->linkedin = GETPOST("linkedin", 'alpha');
|
$object->linkedin = GETPOST("linkedin", 'alpha');
|
||||||
$object->email = GETPOST("email", 'alpha');
|
$object->email = GETPOST("email", 'alpha');
|
||||||
|
$object->no_email = GETPOST("no_email", "int");
|
||||||
$object->phone_pro = GETPOST("phone_pro", 'alpha');
|
$object->phone_pro = GETPOST("phone_pro", 'alpha');
|
||||||
$object->phone_perso = GETPOST("phone_perso", 'alpha');
|
$object->phone_perso = GETPOST("phone_perso", 'alpha');
|
||||||
$object->phone_mobile = GETPOST("phone_mobile", 'alpha');
|
$object->phone_mobile = GETPOST("phone_mobile", 'alpha');
|
||||||
@ -230,6 +231,22 @@ if (empty($reshook))
|
|||||||
// Categories association
|
// Categories association
|
||||||
$contcats = GETPOST('contcats', 'array');
|
$contcats = GETPOST('contcats', 'array');
|
||||||
$object->setCategories($contcats);
|
$object->setCategories($contcats);
|
||||||
|
|
||||||
|
// Add mass emailing flag into table mailing_unsubscribe
|
||||||
|
if (GETPOST('no_email', 'int') && $object->email)
|
||||||
|
{
|
||||||
|
$sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
if (empty($obj->nb))
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,6 +377,7 @@ if (empty($reshook))
|
|||||||
$object->country_id = GETPOST("country_id", 'int');
|
$object->country_id = GETPOST("country_id", 'int');
|
||||||
|
|
||||||
$object->email = GETPOST("email", 'alpha');
|
$object->email = GETPOST("email", 'alpha');
|
||||||
|
$object->no_email = GETPOST("no_email", "int");
|
||||||
$object->skype = GETPOST("skype", 'alpha');
|
$object->skype = GETPOST("skype", 'alpha');
|
||||||
$object->twitter = GETPOST("twitter", 'alpha');
|
$object->twitter = GETPOST("twitter", 'alpha');
|
||||||
$object->facebook = GETPOST("facebook", 'alpha');
|
$object->facebook = GETPOST("facebook", 'alpha');
|
||||||
@ -387,6 +405,35 @@ if (empty($reshook))
|
|||||||
$categories = GETPOST('contcats', 'array');
|
$categories = GETPOST('contcats', 'array');
|
||||||
$object->setCategories($categories);
|
$object->setCategories($categories);
|
||||||
|
|
||||||
|
$no_email = GETPOST('no_email', 'int');
|
||||||
|
|
||||||
|
// Update mass emailing flag into table mailing_unsubscribe
|
||||||
|
if (GETPOSTISSET('no_email') && $object->email)
|
||||||
|
{
|
||||||
|
if ($no_email)
|
||||||
|
{
|
||||||
|
$sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
$noemail = $obj->nb;
|
||||||
|
if (empty($noemail))
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')";
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0));
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->no_email = $no_email;
|
||||||
|
}
|
||||||
|
|
||||||
$object->old_lastname='';
|
$object->old_lastname='';
|
||||||
$object->old_firstname='';
|
$object->old_firstname='';
|
||||||
$action = 'view';
|
$action = 'view';
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class Contact extends CommonObject
|
|||||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
|
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
|
||||||
);
|
);
|
||||||
|
|
||||||
public $civility_id; // In fact we store civility_code
|
public $civility_id; // In fact we store civility_code
|
||||||
public $civility_code;
|
public $civility_code;
|
||||||
public $civility;
|
public $civility;
|
||||||
public $address;
|
public $address;
|
||||||
@ -88,16 +88,17 @@ class Contact extends CommonObject
|
|||||||
public $town;
|
public $town;
|
||||||
|
|
||||||
public $state_id; // Id of department
|
public $state_id; // Id of department
|
||||||
public $state_code; // Code of department
|
public $state_code; // Code of department
|
||||||
public $state; // Label of department
|
public $state; // Label of department
|
||||||
|
|
||||||
public $poste; // Position
|
public $poste; // Position
|
||||||
|
|
||||||
public $socid; // fk_soc
|
public $socid; // fk_soc
|
||||||
public $statut; // 0=inactif, 1=actif
|
public $statut; // 0=inactif, 1=actif
|
||||||
|
|
||||||
public $code;
|
public $code;
|
||||||
public $email;
|
public $email;
|
||||||
|
public $no_email; // 1 = contact has globaly unsubscribe of all mass emailings
|
||||||
public $skype;
|
public $skype;
|
||||||
public $photo;
|
public $photo;
|
||||||
public $jabberid;
|
public $jabberid;
|
||||||
@ -394,6 +395,7 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
if (! $error && $this->user_id > 0)
|
if (! $error && $this->user_id > 0)
|
||||||
{
|
{
|
||||||
|
// If contact is linked to a user
|
||||||
$tmpobj = new User($this->db);
|
$tmpobj = new User($this->db);
|
||||||
$tmpobj->fetch($this->user_id);
|
$tmpobj->fetch($this->user_id);
|
||||||
$usermustbemodified = 0;
|
$usermustbemodified = 0;
|
||||||
|
|||||||
@ -115,7 +115,7 @@ if (! empty($tag) && ($unsuscrib=='1'))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Update status communication of email (new usage)
|
// 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."')";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
//if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed
|
//if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user