From 157e118cbaf99f32c4044214dd8e72a6164d2cfe Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Jan 2018 10:47:40 +0100 Subject: [PATCH 1/4] Fix: broken feature --- htdocs/contact/class/contact.class.php | 3 ++- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ca4880d68b8..31a95f8cd78 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -176,6 +176,7 @@ class Contact extends CommonObject if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request + $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql.= " datec"; @@ -199,7 +200,7 @@ class Contact extends CommonObject $sql.= " ".$this->priv.","; $sql.= " ".$this->statut.","; $sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").","; - $sql.= " ".$this->entity.","; + $sql.= " ".$entity.","; $sql.= "'".$this->db->escape($this->ref_ext)."',"; $sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); $sql.= ")"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index af15ce7c700..865924c7274 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -471,7 +471,7 @@ class Societe extends CommonObject if ($result >= 0) { - $entity = isset($this->entity)?$this->entity:$conf->entity; + $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$entity.", '".$this->db->idate($now)."'"; From 20ad3b0e80c785ec5e894308ab4a2c079736ca8a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Jan 2018 10:39:15 +0100 Subject: [PATCH 2/4] Fix: if $entity is empty '' the isset return true !! --- htdocs/contact/class/contact.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index db2152a00ae..1bfc9ee8c19 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -176,9 +176,8 @@ class Contact extends CommonObject if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request - $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); - $entity = isset($this->entity)?$this->entity:$conf->entity; + $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql.= " datec"; From b8688a46d349915362091f54b21034bb2cd195e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 15 Jan 2018 11:30:11 +0100 Subject: [PATCH 3/4] Update contact.class.php --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 1bfc9ee8c19..1f307b00c69 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -177,7 +177,7 @@ class Contact extends CommonObject if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request - $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); + $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql.= " datec"; From 68f0808d16be648c924f3f954dcf529edb8ef681 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 15 Jan 2018 11:30:32 +0100 Subject: [PATCH 4/4] Update societe.class.php --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 865924c7274..cd4b66a23a1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -471,7 +471,7 @@ class Societe extends CommonObject if ($result >= 0) { - $entity = (isset($this->entity) && is_numeric($this->entity)?$this->entity:$conf->entity); + $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$entity.", '".$this->db->idate($now)."'";