From 0027e1a8bab69def93a8fe18d96f126974d442f9 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 24 Dec 2015 20:25:54 +0100 Subject: [PATCH 1/2] Include local constants files and fetch their values to the corresponding database constants Modules may declare their file constants in a file named as : "module name"_consts.php and located in the module root folder. They may also assign a correspondence between file constants they define and their equivalent database constants in a table named $file2bddconsts defined in their constants file. To get this two functions the module need to add its name to the list of modules in LOCAL_CONSTS_FILES. --- htdocs/core/class/conf.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 7adcd79d364..6f9363d8248 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -205,6 +205,16 @@ class Conf $db->free($resql); } + // Include local constants files and fetch their values to the corresponding database constants + if(! empty($this->global->LOCAL_CONSTS_FILES)) { + $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); + foreach ($filesList as $file) { + include_once DOL_DOCUMENT_ROOT . "/$file/{$file}_consts.php"; + foreach ($file2bddconsts as $key=>$value) { + $conf->global->$key=constant($value); + } + } + } //var_dump($this->modules); //var_dump($this->modules_parts['theme']); From ce49c0d5dc66d94adb151aef33d9eb83f7048f22 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Sun, 27 Dec 2015 18:27:18 +0100 Subject: [PATCH 2/2] Update conf.class.php I used dol_sanitizeFileName only for $file in order to not clean the two '/' characters needed in the path --- htdocs/core/class/conf.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 6f9363d8248..34fc77bbc34 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -209,6 +209,7 @@ class Conf if(! empty($this->global->LOCAL_CONSTS_FILES)) { $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); foreach ($filesList as $file) { + $file=dol_sanitizeFileName($file); include_once DOL_DOCUMENT_ROOT . "/$file/{$file}_consts.php"; foreach ($file2bddconsts as $key=>$value) { $conf->global->$key=constant($value);