diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ca15812b1fa..6fb47d6100f 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -160,7 +160,7 @@ class Conf $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); $varname = $partname.'_modules'; - $this->$varname = array(); + if (! is_array($this->$varname)) { $this->$varname = array(); } $arrValue = unserialize($value); if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; else $value = ($value == 1 ? '/'.$modulename.'/core/'.$partname.'/' : $value); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 2b7344eaf1c..016d1c15d3a 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2011 Regis Houssin +/* Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -43,9 +43,9 @@ class HookManager * * @param DoliDB $DB Handler acces base de donnees */ - function HookManager($DB) + function __construct($db) { - $this->db = $DB; + $this->db = $db; } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 8eaecc5bbf1..dbd18d486c1 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1261,13 +1261,28 @@ abstract class DolibarrModules global $conf; $err=0; + $entity=$conf->entity; if (is_array($this->module_parts) && ! empty($this->module_parts)) { foreach($this->module_parts as $key => $value) { + $newvalue = $value; + // Serialize array parameters - if (is_array($value)) $value = serialize($value); + if (is_array($value)) + { + // Can defined other parameters + if (is_array($value['data']) && ! empty($value['data'])) + { + $newvalue = serialize($value['data']); + if (isset($value['entity'])) $entity = $value['entity']; + } + else + { + $newvalue = serialize($value); + } + } $sql = "INSERT INTO ".MAIN_DB_PREFIX."const ("; $sql.= "name"; @@ -1278,12 +1293,12 @@ abstract class DolibarrModules $sql.= ", entity"; $sql.= ")"; $sql.= " VALUES ("; - $sql.= $this->db->encrypt($this->const_name."_".strtoupper($key),1); + $sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1); $sql.= ", 'chaine'"; - $sql.= ", ".$this->db->encrypt($value,1); + $sql.= ", ".$this->db->encrypt($newvalue, 1); $sql.= ", null"; $sql.= ", '0'"; - $sql.= ", ".$conf->entity; + $sql.= ", ".$entity; $sql.= ")"; dol_syslog(get_class($this)."::insert_".$key." sql=".$sql);