diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 04358a3d990..32a891b5b8c 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -365,30 +365,33 @@ class DolibarrModules { $err=0; - foreach ($this->boxes as $key => $value) + if (is_array($this->boxes)) { - $titre = $this->boxes[$key][0]; - $file = $this->boxes[$key][1]; - - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def WHERE name ='".$titre."'"; - - $result=$this->db->query($sql); - if ($result) - { - $row = $this->db->fetch_row($result); - if ($row[0] == 0) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file) VALUES ('".$titre."','".$file."')"; - if (! $this->db->query($sql)) - { - $err++; - } - } - } - else - { - $err++; - } + foreach ($this->boxes as $key => $value) + { + $titre = $this->boxes[$key][0]; + $file = $this->boxes[$key][1]; + + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def WHERE name ='".$titre."'"; + + $result=$this->db->query($sql); + if ($result) + { + $row = $this->db->fetch_row($result); + if ($row[0] == 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file) VALUES ('".$titre."','".$file."')"; + if (! $this->db->query($sql)) + { + $err++; + } + } + } + else + { + $err++; + } + } } return $err; @@ -403,18 +406,21 @@ class DolibarrModules { $err=0; - foreach ($this->boxes as $key => $value) + if (is_array($this->boxes)) { - $titre = $this->boxes[$key][0]; - $file = $this->boxes[$key][1]; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def WHERE file = '".$file."'"; - if (! $this->db->query($sql) ) - { - $err++; - } - } - + foreach ($this->boxes as $key => $value) + { + $titre = $this->boxes[$key][0]; + $file = $this->boxes[$key][1]; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def WHERE file = '".$file."'"; + if (! $this->db->query($sql) ) + { + $err++; + } + } + } + return $err; } diff --git a/htdocs/includes/modules/modBoutique.class.php b/htdocs/includes/modules/modBoutique.class.php index e760e87fc61..b2b771f0633 100644 --- a/htdocs/includes/modules/modBoutique.class.php +++ b/htdocs/includes/modules/modBoutique.class.php @@ -72,6 +72,9 @@ class modBoutique extends DolibarrModules // Constantes $this->const = array(); + // Boites + $this->boxes = array(); + // Permissions $this->rights = array(); $this->rights_class = 'boutique';