Laurent Destailleur před 4 roky
rodič
revize
82ee5c2825
2 změnil soubory, kde provedl 677 přidání a 677 odebrání
  1. 674 661
      htdocs/core/class/conf.class.php
  2. 3 16
      htdocs/master.inc.php

+ 674 - 661
htdocs/core/class/conf.class.php

@@ -110,7 +110,6 @@ class Conf
 		// Common objects that are not modules
 		$this->mycompany = new stdClass();
 		$this->admin = new stdClass();
-		$this->user	= new stdClass();
 		$this->browser = new stdClass();
 		$this->medias = new stdClass();
 		$this->global = new stdClass();
@@ -136,7 +135,7 @@ class Conf
 			'syslog' => array()
 		);
 
-		// First level object
+		// First level object that are modules.
 		// TODO Remove this part.
 		$this->syslog = new stdClass();
 		$this->multicompany = new stdClass();
@@ -152,6 +151,7 @@ class Conf
 		$this->propal = new stdClass();
 		$this->facture			= new stdClass();
 		$this->contrat			= new stdClass();
+		$this->user	= new stdClass();
 		$this->usergroup		= new stdClass();
 		$this->adherent			= new stdClass();
 		$this->bank = new stdClass();
@@ -173,751 +173,764 @@ class Conf
 	{
 		dol_syslog(get_class($this)."::setValues");
 
-		//Define all global constants into $this->global->key=value
-		$sql = "SELECT ".$db->decrypt('name')." as name,";
-		$sql .= " ".$db->decrypt('value')." as value, entity";
-		$sql .= " FROM ".MAIN_DB_PREFIX."const";
-		$sql .= " WHERE entity IN (0,".$this->entity.")";
-		$sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
-
-		$resql = $db->query($sql);
-		if ($resql) {
-			$i = 0;
-			$numr = $db->num_rows($resql);
-			while ($i < $numr) {
-				$objp = $db->fetch_object($resql);
-				$key = $objp->name;
-				$value = $objp->value;
-				if ($key) {
-					// Allow constants values to be overridden by environment variables
-					if (isset($_SERVER['DOLIBARR_'.$key])) {
-						$value = $_SERVER['DOLIBARR_'.$key];
-					} elseif (isset($_ENV['DOLIBARR_'.$key])) {
-						$value = $_ENV['DOLIBARR_'.$key];
-					}
+		if (!defined('NOREQUIREDB')) {
+			// Define all global constants into $this->global->key=value
+			$sql = "SELECT ".$db->decrypt('name')." as name,";
+			$sql .= " ".$db->decrypt('value')." as value, entity";
+			$sql .= " FROM ".MAIN_DB_PREFIX."const";
+			$sql .= " WHERE entity IN (0,".$this->entity.")";
+			$sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
+
+			$resql = $db->query($sql);
+			if ($resql) {
+				$i = 0;
+				$numr = $db->num_rows($resql);
+				while ($i < $numr) {
+					$objp = $db->fetch_object($resql);
+					$key = $objp->name;
+					$value = $objp->value;
+					if ($key) {
+						// Allow constants values to be overridden by environment variables
+						if (isset($_SERVER['DOLIBARR_'.$key])) {
+							$value = $_SERVER['DOLIBARR_'.$key];
+						} elseif (isset($_ENV['DOLIBARR_'.$key])) {
+							$value = $_ENV['DOLIBARR_'.$key];
+						}
 
-					//if (! defined("$key")) define("$key", $value);	// In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
-					$this->global->$key = $value;
-
-					if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
-						$reg = array();
-						// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
-						if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
-							$partname = 'tabs';
-							$params = explode(':', $value, 2);
-							if (!is_array($this->modules_parts[$partname])) {
-								$this->modules_parts[$partname] = array();
-							}
-							$this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
-						} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
-							// If this is constant for all generic part activated by a module. It initializes
-							// modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
-							// modules_parts['models'], modules_parts['theme']
-							// modules_parts['sms'],
-							// modules_parts['css'], ...
-
-							$modulename = strtolower($reg[1]);
-							$partname = strtolower($reg[2]);
-							if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
-								$this->modules_parts[$partname] = array();
-							}
-							$arrValue = json_decode($value, true);
-							if (is_array($arrValue) && !empty($arrValue)) {
-								$value = $arrValue;
-							} elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
-								$value = '/'.$modulename.'/core/'.$partname.'/';
-							} elseif (in_array($partname, array('models', 'theme'))) {
-								$value = '/'.$modulename.'/';
-							} elseif (in_array($partname, array('sms'))) {
-								$value = '/'.$modulename.'/';
-							} elseif ($value == 1) {
-								$value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
-							}
-							$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
-						} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
-							// If this is a module constant (must be at end)
-							$modulename = strtolower($reg[1]);
-							if ($modulename == 'propale') {
-								$modulename = 'propal';
-							}
-							if ($modulename == 'supplierproposal') {
-								$modulename = 'supplier_proposal';
+						//if (! defined("$key")) define("$key", $value);	// In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
+						$this->global->$key = $value;
+
+						if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
+							$reg = array();
+							// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
+							if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
+								$partname = 'tabs';
+								$params = explode(':', $value, 2);
+								if (!is_array($this->modules_parts[$partname])) {
+									$this->modules_parts[$partname] = array();
+								}
+								$this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
+							} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
+								// If this is constant for all generic part activated by a module. It initializes
+								// modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
+								// modules_parts['models'], modules_parts['theme']
+								// modules_parts['sms'],
+								// modules_parts['css'], ...
+
+								$modulename = strtolower($reg[1]);
+								$partname = strtolower($reg[2]);
+								if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
+									$this->modules_parts[$partname] = array();
+								}
+								$arrValue = json_decode($value, true);
+								if (is_array($arrValue) && !empty($arrValue)) {
+									$value = $arrValue;
+								} elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
+									$value = '/'.$modulename.'/core/'.$partname.'/';
+								} elseif (in_array($partname, array('models', 'theme'))) {
+									$value = '/'.$modulename.'/';
+								} elseif (in_array($partname, array('sms'))) {
+									$value = '/'.$modulename.'/';
+								} elseif ($value == 1) {
+									$value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
+								}
+								$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
+							} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
+								// If this is a module constant (must be at end)
+								$modulename = strtolower($reg[1]);
+								if ($modulename == 'propale') {
+									$modulename = 'propal';
+								}
+								if ($modulename == 'supplierproposal') {
+									$modulename = 'supplier_proposal';
+								}
+								if (!isset($this->$modulename) || !is_object($this->$modulename)) {
+									$this->$modulename = new stdClass();
+								}
+								$this->$modulename->enabled = true;
+								$this->modules[] = $modulename; // Add this module in list of enabled modules
 							}
-							if (!isset($this->$modulename) || !is_object($this->$modulename)) {
-								$this->$modulename = new stdClass();
-							}
-							$this->$modulename->enabled = true;
-							$this->modules[] = $modulename; // Add this module in list of enabled modules
 						}
 					}
+					$i++;
 				}
-				$i++;
-			}
-
-			$db->free($resql);
-		}
 
-		// Include other local consts.php 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) {
-				$file = dol_sanitizeFileName($file);
-				dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
+				$db->free($resql);
 			}
-		}
 
-		//var_dump($this->modules);
-		//var_dump($this->modules_parts['theme']);
+			// Include other local consts.php 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) {
+					$file = dol_sanitizeFileName($file);
+					dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
+				}
+			}
 
-		// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
-		// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
-		//$this->global->MAIN_SERVER_TZ='Europe/Paris';
-		if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
-			try {
-				date_default_timezone_set($this->global->MAIN_SERVER_TZ);
-			} catch (Exception $e) {
-				dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
+			//var_dump($this->modules);
+			//var_dump($this->modules_parts['theme']);
+
+			// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
+			// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
+			//$this->global->MAIN_SERVER_TZ='Europe/Paris';
+			if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
+				try {
+					date_default_timezone_set($this->global->MAIN_SERVER_TZ);
+				} catch (Exception $e) {
+					dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
+				}
 			}
-		}
 
-		// Object $mc
-		if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
-			global $mc;
-			$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
-			if ($ret) {
-				$mc = new ActionsMulticompany($db);
-				$this->mc = $mc;
+			// Object $mc
+			if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
+				global $mc;
+				$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
+				if ($ret) {
+					$mc = new ActionsMulticompany($db);
+					$this->mc = $mc;
+				}
 			}
-		}
 
-		// Clean some variables
-		if (empty($this->global->MAIN_MENU_STANDARD)) {
-			$this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
-		}
-		if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
-			$this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
-		}
-		if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
-			$this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
-		}
-		if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
-			$this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
-		}
-		if (!isset($this->global->FACTURE_TVAOPTION)) {
-			$this->global->FACTURE_TVAOPTION = 1;
-		}
+			// Clean some variables
+			if (empty($this->global->MAIN_MENU_STANDARD)) {
+				$this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
+			}
+			if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
+				$this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
+			}
+			if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
+				$this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
+			}
+			if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
+				$this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
+			}
+			if (!isset($this->global->FACTURE_TVAOPTION)) {
+				$this->global->FACTURE_TVAOPTION = 1;
+			}
 
-		// Variable globales LDAP
-		if (empty($this->global->LDAP_FIELD_FULLNAME)) {
-			$this->global->LDAP_FIELD_FULLNAME = '';
-		}
-		if (!isset($this->global->LDAP_KEY_USERS)) {
-			$this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
-		}
-		if (!isset($this->global->LDAP_KEY_GROUPS)) {
-			$this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
-		}
-		if (!isset($this->global->LDAP_KEY_CONTACTS)) {
-			$this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
-		}
-		if (!isset($this->global->LDAP_KEY_MEMBERS)) {
-			$this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
-		}
-		if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
-			$this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
-		}
+			// Variable globales LDAP
+			if (empty($this->global->LDAP_FIELD_FULLNAME)) {
+				$this->global->LDAP_FIELD_FULLNAME = '';
+			}
+			if (!isset($this->global->LDAP_KEY_USERS)) {
+				$this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
+			}
+			if (!isset($this->global->LDAP_KEY_GROUPS)) {
+				$this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
+			}
+			if (!isset($this->global->LDAP_KEY_CONTACTS)) {
+				$this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
+			}
+			if (!isset($this->global->LDAP_KEY_MEMBERS)) {
+				$this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
+			}
+			if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
+				$this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
+			}
 
-		// Load translation object with current language
-		if (empty($this->global->MAIN_LANG_DEFAULT)) {
-			$this->global->MAIN_LANG_DEFAULT = "en_US";
-		}
+			// Load translation object with current language
+			if (empty($this->global->MAIN_LANG_DEFAULT)) {
+				$this->global->MAIN_LANG_DEFAULT = "en_US";
+			}
 
-		$rootfordata = DOL_DATA_ROOT;
-		$rootforuser = DOL_DATA_ROOT;
-		// If multicompany module is enabled, we redefine the root of data
-		if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) {
-			$rootfordata .= '/'.$this->entity;
-		}
-		// Set standard temporary folder name or global override
-		$rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
-
-		// Define default dir_output and dir_temp for directories of modules
-		foreach ($this->modules as $module) {
-			//var_dump($module);
-			// For multicompany sharings
-			$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
-			$this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
-			// For backward compatibility
-			$this->$module->dir_output = $rootfordata."/".$module;
-			$this->$module->dir_temp = $rootfortemp."/".$module."/temp";
-		}
+			$rootfordata = DOL_DATA_ROOT;
+			$rootforuser = DOL_DATA_ROOT;
+			// If multicompany module is enabled, we redefine the root of data
+			if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) {
+				$rootfordata .= '/'.$this->entity;
+			}
+			// Set standard temporary folder name or global override
+			$rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
+
+			// Define default dir_output and dir_temp for directories of modules
+			foreach ($this->modules as $module) {
+				//var_dump($module);
+				// For multicompany sharings
+				$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
+				$this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
+				// For backward compatibility
+				$this->$module->dir_output = $rootfordata."/".$module;
+				$this->$module->dir_temp = $rootfortemp."/".$module."/temp";
+			}
 
-		// External modules storage
-		if (!empty($this->modules_parts['dir'])) {
-			foreach ($this->modules_parts['dir'] as $module => $dirs) {
-				if (!empty($this->$module->enabled)) {
-					foreach ($dirs as $type => $name) {  // $type is 'output' or 'temp'
-						$multidirname = 'multidir_'.$type;
-						$dirname = 'dir_'.$type;
-
-						if ($type != 'temp') {
-							// For multicompany sharings
-							$this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
-
-							// For backward compatibility
-							$this->$module->$dirname = $rootfordata."/".$name;
-						} else {
-							// For multicompany sharings
-							$this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
-
-							// For backward compatibility
-							$this->$module->$dirname = $rootfortemp."/".$name."/temp";
+			// External modules storage
+			if (!empty($this->modules_parts['dir'])) {
+				foreach ($this->modules_parts['dir'] as $module => $dirs) {
+					if (!empty($this->$module->enabled)) {
+						foreach ($dirs as $type => $name) {  // $type is 'output' or 'temp'
+							$multidirname = 'multidir_'.$type;
+							$dirname = 'dir_'.$type;
+
+							if ($type != 'temp') {
+								// For multicompany sharings
+								$this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
+
+								// For backward compatibility
+								$this->$module->$dirname = $rootfordata."/".$name;
+							} else {
+								// For multicompany sharings
+								$this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
+
+								// For backward compatibility
+								$this->$module->$dirname = $rootfortemp."/".$name."/temp";
+							}
 						}
 					}
 				}
 			}
-		}
 
-		// For mycompany storage
-		$this->mycompany->dir_output = $rootfordata."/mycompany";
-		$this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
-
-		// For admin storage
-		$this->admin->dir_output = $rootfordata.'/admin';
-		$this->admin->dir_temp = $rootfortemp.'/admin/temp';
-
-		// For user storage
-		$this->user->multidir_output = array($this->entity => $rootfordata."/users");
-		$this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
-		// For backward compatibility
-		$this->user->dir_output = $rootforuser."/users";
-		$this->user->dir_temp = $rootfortemp."/users/temp";
-
-		// For usergroup storage
-		$this->usergroup->dir_output = $rootforuser."/usergroups";
-		$this->usergroup->dir_temp = $rootfortemp."/usergroups/temp";
-
-		// For proposal storage
-		$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
-		$this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
-		// For backward compatibility
-		$this->propal->dir_output = $rootfordata."/propale";
-		$this->propal->dir_temp = $rootfortemp."/propale/temp";
-
-		// For medias storage
-		$this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
-		$this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
-
-		// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
-
-		// Sous module bons d'expedition
-		$this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
-		// Sub module delivery note  Sous module bons de livraison
-		$this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0);
-
-		// Module fournisseur
-		if (!empty($this->fournisseur)) {
-			$this->fournisseur->commande = new stdClass();
-			$this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
-			$this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
-			$this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
-			$this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
-
-			$this->fournisseur->facture = new stdClass();
-			$this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
-			$this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
-			$this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
-			$this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
-
-			$this->supplierproposal = new stdClass();
-			$this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
-			$this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
-			$this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
-			$this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
-
-			$this->fournisseur->payment = new stdClass();
-			$this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
-			$this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
-			$this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
-			$this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
-
-			// To prepare split of module fournisseur into module 'fournisseur' + supplier_order + supplier_invoice
-			if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) {  // By default, if module supplier is on, and we don't use yet the new modules, we set artificially the module properties
-				$this->supplier_order = new stdClass();
-				$this->supplier_order->enabled = 1;
-				$this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
-				$this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
-				$this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
-				$this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
-
-				$this->supplier_invoice = new stdClass();
-				$this->supplier_invoice->enabled = 1;
-				$this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
-				$this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
-				$this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
-				$this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
+			// For mycompany storage
+			$this->mycompany->dir_output = $rootfordata."/mycompany";
+			$this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
+
+			// For admin storage
+			$this->admin->dir_output = $rootfordata.'/admin';
+			$this->admin->dir_temp = $rootfortemp.'/admin/temp';
+
+			// For user storage
+			$this->user->multidir_output = array($this->entity => $rootfordata."/users");
+			$this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
+			// For backward compatibility
+			$this->user->dir_output = $rootforuser."/users";
+			$this->user->dir_temp = $rootfortemp."/users/temp";
+
+			// For usergroup storage
+			$this->usergroup->dir_output = $rootforuser."/usergroups";
+			$this->usergroup->dir_temp = $rootfortemp."/usergroups/temp";
+
+			// For proposal storage
+			$this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
+			$this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
+			// For backward compatibility
+			$this->propal->dir_output = $rootfordata."/propale";
+			$this->propal->dir_temp = $rootfortemp."/propale/temp";
+
+			// For medias storage
+			$this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
+			$this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
+
+			// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
+
+			// Sous module bons d'expedition
+			$this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
+			// Sub module delivery note  Sous module bons de livraison
+			$this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0);
+
+			// Module fournisseur
+			if (!empty($this->fournisseur)) {
+				$this->fournisseur->commande = new stdClass();
+				$this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
+				$this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
+				$this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
+				$this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
+
+				$this->fournisseur->facture = new stdClass();
+				$this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
+				$this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
+				$this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
+				$this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
+
+				$this->supplierproposal = new stdClass();
+				$this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
+				$this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
+				$this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
+				$this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
+
+				$this->fournisseur->payment = new stdClass();
+				$this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
+				$this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
+				$this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
+				$this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
+
+				// To prepare split of module fournisseur into module 'fournisseur' + supplier_order + supplier_invoice
+				if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) {  // By default, if module supplier is on, and we don't use yet the new modules, we set artificially the module properties
+					$this->supplier_order = new stdClass();
+					$this->supplier_order->enabled = 1;
+					$this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
+					$this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
+					$this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
+					$this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
+
+					$this->supplier_invoice = new stdClass();
+					$this->supplier_invoice->enabled = 1;
+					$this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
+					$this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
+					$this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
+					$this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
+				}
 			}
-		}
 
-		// Module product/service
-		$this->product->multidir_output 		= array($this->entity => $rootfordata."/produit");
-		$this->product->multidir_temp			= array($this->entity => $rootfortemp."/produit/temp");
-		$this->service->multidir_output			= array($this->entity => $rootfordata."/produit");
-		$this->service->multidir_temp			= array($this->entity => $rootfortemp."/produit/temp");
-		// For backward compatibility
-		$this->product->dir_output				= $rootfordata."/produit";
-		$this->product->dir_temp				= $rootfortemp."/produit/temp";
-		$this->service->dir_output				= $rootfordata."/produit";
-		$this->service->dir_temp				= $rootfortemp."/produit/temp";
-
-		// Module productbatch
-		$this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
-		$this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
-
-		// Module contrat
-		$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
-		$this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
-		// For backward compatibility
-		$this->contrat->dir_output = $rootfordata."/contract";
-		$this->contrat->dir_temp = $rootfortemp."/contract/temp";
-
-		// Module bank
-		$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
-		$this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
-		// For backward compatibility
-		$this->bank->dir_output = $rootfordata."/bank";
-		$this->bank->dir_temp = $rootfortemp."/bank/temp";
-
-		// Set some default values
-		//$this->global->MAIN_LIST_FILTER_ON_DAY=1;		// On filter that show date, we must show input field for day before or after month
-		$this->global->MAIN_MAIL_USE_MULTI_PART = 1;
-
-		// societe
-		if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
-			$this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
-		}
-		if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
-			$this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
-		}
+			// Module product/service
+			$this->product->multidir_output 		= array($this->entity => $rootfordata."/produit");
+			$this->product->multidir_temp			= array($this->entity => $rootfortemp."/produit/temp");
+			$this->service->multidir_output			= array($this->entity => $rootfordata."/produit");
+			$this->service->multidir_temp			= array($this->entity => $rootfortemp."/produit/temp");
+			// For backward compatibility
+			$this->product->dir_output				= $rootfordata."/produit";
+			$this->product->dir_temp				= $rootfortemp."/produit/temp";
+			$this->service->dir_output				= $rootfordata."/produit";
+			$this->service->dir_temp				= $rootfortemp."/produit/temp";
+
+			// Module productbatch
+			$this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
+			$this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
+
+			// Module contrat
+			$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
+			$this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
+			// For backward compatibility
+			$this->contrat->dir_output = $rootfordata."/contract";
+			$this->contrat->dir_temp = $rootfortemp."/contract/temp";
 
-		if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
-			$this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
-		}
-		if (empty($this->global->TICKET_ADDON)) {
-			$this->global->TICKET_ADDON = 'mod_ticket_simple';
-		}
+			// Module bank
+			$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
+			$this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
+			// For backward compatibility
+			$this->bank->dir_output = $rootfordata."/bank";
+			$this->bank->dir_temp = $rootfortemp."/bank/temp";
 
-		// Security
-		if (empty($this->global->USER_PASSWORD_GENERATED)) {
-			$this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
-		}
-		if (empty($this->global->MAIN_UMASK)) {
-			$this->global->MAIN_UMASK = '0664'; // Default mask
-		}
+			// Set some default values
+			//$this->global->MAIN_LIST_FILTER_ON_DAY=1;		// On filter that show date, we must show input field for day before or after month
+			$this->global->MAIN_MAIL_USE_MULTI_PART = 1;
 
-		// conf->use_javascript_ajax
-		$this->use_javascript_ajax = 1;
-		if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
-			$this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
-		}
-		// If no javascript_ajax, Ajax features are disabled.
-		if (empty($this->use_javascript_ajax)) {
-			unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
-			unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
-			unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
-			unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
-		}
+			// societe
+			if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
+				$this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
+			}
+			if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
+				$this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
+			}
 
-		if (!empty($this->productbatch->enabled)) {
-			$this->global->STOCK_CALCULATE_ON_BILL = 0;
-			$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
-			$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
-			$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
-			$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
-			$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
-			if (empty($this->reception->enabled)) {
-				$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
-			} else {
-				$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
-				$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
+			if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
+				$this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
+			}
+			if (empty($this->global->TICKET_ADDON)) {
+				$this->global->TICKET_ADDON = 'mod_ticket_simple';
 			}
-		}
 
-		if (!isset($this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT)) {
-			$this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT = 1;
-		}
+			// Security
+			if (empty($this->global->USER_PASSWORD_GENERATED)) {
+				$this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
+			}
+			if (empty($this->global->MAIN_UMASK)) {
+				$this->global->MAIN_UMASK = '0664'; // Default mask
+			}
 
-		// conf->currency
-		if (empty($this->global->MAIN_MONNAIE)) {
-			$this->global->MAIN_MONNAIE = 'EUR';
-		}
-		$this->currency = $this->global->MAIN_MONNAIE;
+			// conf->use_javascript_ajax
+			$this->use_javascript_ajax = 1;
+			if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
+				$this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
+			}
+			// If no javascript_ajax, Ajax features are disabled.
+			if (empty($this->use_javascript_ajax)) {
+				unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
+				unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
+				unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
+				unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
+			}
 
-		if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
-			$this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
-		}
+			if (!empty($this->productbatch->enabled)) {
+				$this->global->STOCK_CALCULATE_ON_BILL = 0;
+				$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
+				$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
+				$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
+				$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
+				$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
+				if (empty($this->reception->enabled)) {
+					$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
+				} else {
+					$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
+					$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
+				}
+			}
 
-		// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
-		if (empty($this->global->ACCOUNTING_MODE)) {
-			$this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
-		}
+			if (!isset($this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT)) {
+				$this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT = 1;
+			}
 
-		// By default, suppliers objects can be linked to all projects
-		if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
-			$this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
-		}
+			// conf->currency
+			if (empty($this->global->MAIN_MONNAIE)) {
+				$this->global->MAIN_MONNAIE = 'EUR';
+			}
+			$this->currency = $this->global->MAIN_MONNAIE;
 
-		// By default we enable feature to bill time spent
-		if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
-			$this->global->PROJECT_BILL_TIME_SPENT = 1;
-		}
+			if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
+				$this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
+			}
 
-		// MAIN_HTML_TITLE
-		if (!isset($this->global->MAIN_HTML_TITLE)) {
-			$this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
-		}
+			// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
+			if (empty($this->global->ACCOUNTING_MODE)) {
+				$this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
+			}
 
-		// conf->liste_limit = constante de taille maximale des listes
-		if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) {
-			$this->global->MAIN_SIZE_LISTE_LIMIT = 25;
-		}
-		$this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
+			// By default, suppliers objects can be linked to all projects
+			if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
+				$this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
+			}
 
-		// conf->product->limit_size = constante de taille maximale des select de produit
-		if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
-			$this->global->PRODUIT_LIMIT_SIZE = 1000;
-		}
-		$this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
+			// By default we enable feature to bill time spent
+			if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
+				$this->global->PROJECT_BILL_TIME_SPENT = 1;
+			}
 
-		// conf->theme et $this->css
-		if (empty($this->global->MAIN_THEME)) {
-			$this->global->MAIN_THEME = "eldy";
-		}
-		if (!empty($this->global->MAIN_FORCETHEME)) {
-			$this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
-		}
-		$this->theme = $this->global->MAIN_THEME;
-		$this->css = "/theme/".$this->theme."/style.css.php";
+			// MAIN_HTML_TITLE
+			if (!isset($this->global->MAIN_HTML_TITLE)) {
+				$this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
+			}
 
-		// conf->email_from = email pour envoi par dolibarr des mails automatiques
-		$this->email_from = "robot@example.com";
-		if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
-			$this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
-		}
+			// conf->liste_limit = constante de taille maximale des listes
+			if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) {
+				$this->global->MAIN_SIZE_LISTE_LIMIT = 25;
+			}
+			$this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
 
-		// conf->notification->email_from = email pour envoi par Dolibarr des notifications
-		$this->notification->email_from = $this->email_from;
-		if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
-			$this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
-		}
+			// conf->product->limit_size = constante de taille maximale des select de produit
+			if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
+				$this->global->PRODUIT_LIMIT_SIZE = 1000;
+			}
+			$this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
 
-		// conf->mailing->email_from = email pour envoi par Dolibarr des mailings
-		$this->mailing->email_from = $this->email_from;
-		if (!empty($this->global->MAILING_EMAIL_FROM)) {
-			$this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
-		}
-		if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) {
-			$this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
-		}
+			// conf->theme et $this->css
+			if (empty($this->global->MAIN_THEME)) {
+				$this->global->MAIN_THEME = "eldy";
+			}
+			if (!empty($this->global->MAIN_FORCETHEME)) {
+				$this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
+			}
+			$this->theme = $this->global->MAIN_THEME;
+			$this->css = "/theme/".$this->theme."/style.css.php";
 
-		if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
-			$this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
-		}
+			// conf->email_from = email pour envoi par dolibarr des mails automatiques
+			$this->email_from = "robot@example.com";
+			if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
+				$this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
+			}
 
-		// Format for date (used by default when not found or not searched in lang)
-		$this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
-		$this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
-		$this->format_hour_short = "%H:%M";
-		$this->format_hour_short_duration = "%H:%M";
-		$this->format_date_text_short = "%d %b %Y";
-		$this->format_date_text = "%d %B %Y";
-		$this->format_date_hour_short = "%d/%m/%Y %H:%M";
-		$this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
-		$this->format_date_hour_text_short = "%d %b %Y %H:%M";
-		$this->format_date_hour_text = "%d %B %Y %H:%M";
-
-		// Duration of workday
-		if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
-			$this->global->MAIN_DURATION_OF_WORKDAY = 86400;
-		}
+			// conf->notification->email_from = email pour envoi par Dolibarr des notifications
+			$this->notification->email_from = $this->email_from;
+			if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
+				$this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
+			}
 
-		// Limites decimales si non definie (peuvent etre egale a 0)
-		if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
-			$this->global->MAIN_MAX_DECIMALS_UNIT = 5;
-		}
-		if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
-			$this->global->MAIN_MAX_DECIMALS_TOT = 2;
-		}
-		if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
-			$this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
-		}
+			// conf->mailing->email_from = email pour envoi par Dolibarr des mailings
+			$this->mailing->email_from = $this->email_from;
+			if (!empty($this->global->MAILING_EMAIL_FROM)) {
+				$this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
+			}
+			if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) {
+				$this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
+			}
 
-		// Default pdf option
-		if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
-			$this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
-		}
-		if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
-			$this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
-		}
+			if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
+				$this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
+			}
 
-		// Default max file size for upload
-		$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
+			// Format for date (used by default when not found or not searched in lang)
+			$this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
+			$this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
+			$this->format_hour_short = "%H:%M";
+			$this->format_hour_short_duration = "%H:%M";
+			$this->format_date_text_short = "%d %b %Y";
+			$this->format_date_text = "%d %B %Y";
+			$this->format_date_hour_short = "%d/%m/%Y %H:%M";
+			$this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
+			$this->format_date_hour_text_short = "%d %b %Y %H:%M";
+			$this->format_date_hour_text = "%d %B %Y %H:%M";
+
+			// Duration of workday
+			if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
+				$this->global->MAIN_DURATION_OF_WORKDAY = 86400;
+			}
 
-		// By default, we propagate contacts
-		if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
-			$this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
-		}
+			// Limites decimales si non definie (peuvent etre egale a 0)
+			if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
+				$this->global->MAIN_MAX_DECIMALS_UNIT = 5;
+			}
+			if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
+				$this->global->MAIN_MAX_DECIMALS_TOT = 2;
+			}
+			if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
+				$this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
+			}
 
-		// By default, we do not use the zip town table but the table of third parties
-		if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
-			$this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
-		}
+			// Default pdf option
+			if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
+				$this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
+			}
+			if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
+				$this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
+			}
 
-		// By default, we open card if one found
-		if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
-			$this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
-		}
+			// Default max file size for upload
+			$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
 
-		// By default, we show state code in combo list
-		if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
-			$this->global->MAIN_SHOW_STATE_CODE = 1;
-		}
+			// By default, we propagate contacts
+			if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
+				$this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
+			}
 
-		// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
-		if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
-			$this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
-		}
+			// By default, we do not use the zip town table but the table of third parties
+			if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
+				$this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
+			}
 
-		// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
-		if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
-			$this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
-		}
-		if (!empty($this->modules_parts['moduleforexternal'])) {		// Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
-			foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
-				$this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
+			// By default, we open card if one found
+			if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
+				$this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
 			}
-		}
 
-		// Enable select2
-		if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
-			$this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
-		}
+			// By default, we show state code in combo list
+			if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
+				$this->global->MAIN_SHOW_STATE_CODE = 1;
+			}
 
-		// Timeouts
-		if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
-			$this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
-		}
-		if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
-			$this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
-		}
+			// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
+			if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
+				$this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
+			}
 
-		// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
-		if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
-			$this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
-		}
-		if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
-			$this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
-		}
-		if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
-			$this->global->TAX_MODE_SELL_SERVICE = 'payment';
-		}
-		if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
-			$this->global->TAX_MODE_BUY_SERVICE = 'payment';
-		}
+			// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
+			if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
+				$this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
+			}
+			if (!empty($this->modules_parts['moduleforexternal'])) {		// Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
+				foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
+					$this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
+				}
+			}
 
-		// Delay before warnings
-		// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
-		if (isset($this->agenda)) {
-			$this->adherent->subscription = new stdClass();
-			$this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400;
-		}
-		if (isset($this->agenda)) {
-			$this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
-		}
-		if (isset($this->projet)) {
-			$this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400;
-			$this->projet->task = new StdClass();
-			$this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400;
-		}
+			// Enable select2
+			if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
+				$this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
+			}
 
-		if (isset($this->commande)) {
-			$this->commande->client = new stdClass();
-			$this->commande->fournisseur = new stdClass();
-			$this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400;
-			$this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400;
-		}
-		if (isset($this->propal)) {
-			$this->propal->cloture = new stdClass();
-			$this->propal->facturation = new stdClass();
-			$this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400;
-			$this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400;
-		}
-		if (isset($this->facture)) {
-			$this->facture->client = new stdClass();
-			$this->facture->fournisseur = new stdClass();
-			$this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400;
-			$this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400;
-		}
-		if (isset($this->contrat)) {
-			$this->contrat->services = new stdClass();
-			$this->contrat->services->inactifs = new stdClass();
-			$this->contrat->services->expires = new stdClass();
-			$this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
-			$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
-		}
-		if (isset($this->commande)) {
-			$this->bank->rappro					= new stdClass();
-			$this->bank->cheque					= new stdClass();
-			$this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
-			$this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
-		}
-		if (isset($this->expensereport)) {
-			$this->expensereport->approve = new stdClass();
-			$this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400;
-			$this->expensereport->payment = new stdClass();
-			$this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400;
-		}
-		if (isset($this->holiday)) {
-			$this->holiday->approve = new stdClass();
-			$this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
-		}
+			// Timeouts
+			if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
+				$this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
+			}
+			if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
+				$this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
+			}
 
-		if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
-			$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
-		}
+			// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
+			if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
+				$this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
+			}
+			if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
+				$this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
+			}
+			if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
+				$this->global->TAX_MODE_SELL_SERVICE = 'payment';
+			}
+			if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
+				$this->global->TAX_MODE_BUY_SERVICE = 'payment';
+			}
 
-		// For modules that want to disable top or left menu
-		if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
-			$this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
-		}
-		if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
-			$this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
-		}
+			// Delay before warnings
+			// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
+			if (isset($this->agenda)) {
+				$this->adherent->subscription = new stdClass();
+				$this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400;
+			}
+			if (isset($this->agenda)) {
+				$this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
+			}
+			if (isset($this->projet)) {
+				$this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400;
+				$this->projet->task = new StdClass();
+				$this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400;
+			}
 
-		if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
-			$this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
-		}
+			if (isset($this->commande)) {
+				$this->commande->client = new stdClass();
+				$this->commande->fournisseur = new stdClass();
+				$this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400;
+				$this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400;
+			}
+			if (isset($this->propal)) {
+				$this->propal->cloture = new stdClass();
+				$this->propal->facturation = new stdClass();
+				$this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400;
+				$this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400;
+			}
+			if (isset($this->facture)) {
+				$this->facture->client = new stdClass();
+				$this->facture->fournisseur = new stdClass();
+				$this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400;
+				$this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400;
+			}
+			if (isset($this->contrat)) {
+				$this->contrat->services = new stdClass();
+				$this->contrat->services->inactifs = new stdClass();
+				$this->contrat->services->expires = new stdClass();
+				$this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
+				$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
+			}
+			if (isset($this->commande)) {
+				$this->bank->rappro					= new stdClass();
+				$this->bank->cheque					= new stdClass();
+				$this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
+				$this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
+			}
+			if (isset($this->expensereport)) {
+				$this->expensereport->approve = new stdClass();
+				$this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400;
+				$this->expensereport->payment = new stdClass();
+				$this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400;
+			}
+			if (isset($this->holiday)) {
+				$this->holiday->approve = new stdClass();
+				$this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
+			}
 
-		if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) {
-			$this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
-		}
+			if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
+				$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
+			}
 
-		// Save inconsistent option
-		if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
-			$this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
-		}
+			// For modules that want to disable top or left menu
+			if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
+				$this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
+			}
+			if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
+				$this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
+			}
 
-		if (!isset($this->global->MAIN_JS_GRAPH)) {
-			$this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
-		}
+			if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
+				$this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
+			}
 
-		if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
-			$this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
-		}
-		if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
-			$this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
-		}
+			if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) {
+				$this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
+			}
 
-		// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
-		if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) {
-			$this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
-		}
+			// Save inconsistent option
+			if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
+				$this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
+			}
 
-		if (defined('MAIN_ANTIVIRUS_COMMAND')) {
-			$this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
-		}
-		if (defined('MAIN_ANTIVIRUS_PARAM')) {
-			$this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
-		}
+			if (!isset($this->global->MAIN_JS_GRAPH)) {
+				$this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
+			}
 
-		if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
-			$this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY;	// 'tzserver' or 'tzuserrel'
-		}
+			if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
+				$this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
+			}
+			if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
+				$this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
+			}
 
-		if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) {
-			$this->global->MAIN_NO_CONCAT_DESCRIPTION = 1;
-		} else {
-			unset($this->global->MAIN_NO_CONCAT_DESCRIPTION);
-		}
+			// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
+			if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) {
+				$this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
+			}
 
-		// product is new use
-		if (isset($this->product)) {
-			// For backward compatibility
-			$this->produit = $this->product;
-		}
-		// invoice is new use, facture is old use still initialised
-		if (isset($this->facture)) {
-			$this->invoice = $this->facture;
-		}
-		// order is new use, commande is old use still initialised
-		if (isset($this->commande)) {
-			$this->order = $this->commande;
-		}
-		// contract is new use, contrat is old use still initialised
-		if (isset($this->contrat)) {
-			$this->contract = $this->contrat;
-		}
-		// category is new use, categorie is old use still initialised
-		if (isset($this->categorie)) {
-			$this->category = $this->categorie;
-		}
-		// project is new use, projet is old use still initialised
-		if (isset($this->projet) && !isset($this->project)) {
-			$this->project = $this->projet;
-		}
-		// member is new use, adherent is old use still initialised
-		if (isset($this->adherent) && !isset($this->member)) {
-			$this->member = $this->adherent;
-		}
+			if (defined('MAIN_ANTIVIRUS_COMMAND')) {
+				$this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
+			}
+			if (defined('MAIN_ANTIVIRUS_PARAM')) {
+				$this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
+			}
 
-		// Object $mc
-		if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
-			if (is_object($mc)) {
-				$mc->setValues($this);
+			if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
+				$this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY;	// 'tzserver' or 'tzuserrel'
 			}
-		}
 
-		if (!empty($this->syslog->enabled)) {
-			// We init log handlers
-			if (!empty($this->global->SYSLOG_HANDLERS)) {
-				$handlers = json_decode($this->global->SYSLOG_HANDLERS);
+			if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) {
+				$this->global->MAIN_NO_CONCAT_DESCRIPTION = 1;
 			} else {
-				$handlers = array();
+				unset($this->global->MAIN_NO_CONCAT_DESCRIPTION);
+			}
+
+			// product is new use
+			if (isset($this->product)) {
+				// For backward compatibility
+				$this->produit = $this->product;
+			}
+			// invoice is new use, facture is old use still initialised
+			if (isset($this->facture)) {
+				$this->invoice = $this->facture;
+			}
+			// order is new use, commande is old use still initialised
+			if (isset($this->commande)) {
+				$this->order = $this->commande;
+			}
+			// contract is new use, contrat is old use still initialised
+			if (isset($this->contrat)) {
+				$this->contract = $this->contrat;
+			}
+			// category is new use, categorie is old use still initialised
+			if (isset($this->categorie)) {
+				$this->category = $this->categorie;
+			}
+			// project is new use, projet is old use still initialised
+			if (isset($this->projet) && !isset($this->project)) {
+				$this->project = $this->projet;
+			}
+			// member is new use, adherent is old use still initialised
+			if (isset($this->adherent) && !isset($this->member)) {
+				$this->member = $this->adherent;
+			}
+
+			// Object $mc
+			if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
+				if (is_object($mc)) {
+					$mc->setValues($this);
+				}
 			}
-			foreach ($handlers as $handler) {
-				$handler_file_found = '';
-				$dirsyslogs = array('/core/modules/syslog/');
-				if (!empty($this->modules_parts['syslog']) && is_array($this->modules_parts['syslog'])) {
-					$dirsyslogs = array_merge($dirsyslogs, $this->modules_parts['syslog']);
+
+			if (!empty($this->syslog->enabled)) {
+				// We init log handlers
+				if (!empty($this->global->SYSLOG_HANDLERS)) {
+					$handlers = json_decode($this->global->SYSLOG_HANDLERS);
+				} else {
+					$handlers = array();
 				}
-				foreach ($dirsyslogs as $reldir) {
-					$dir = dol_buildpath($reldir, 0);
-					$newdir = dol_osencode($dir);
-					if (is_dir($newdir)) {
-						$file = $newdir.$handler.'.php';
-						if (file_exists($file)) {
-							$handler_file_found = $file;
-							break;
+				foreach ($handlers as $handler) {
+					$handler_file_found = '';
+					$dirsyslogs = array('/core/modules/syslog/');
+					if (!empty($this->modules_parts['syslog']) && is_array($this->modules_parts['syslog'])) {
+						$dirsyslogs = array_merge($dirsyslogs, $this->modules_parts['syslog']);
+					}
+					foreach ($dirsyslogs as $reldir) {
+						$dir = dol_buildpath($reldir, 0);
+						$newdir = dol_osencode($dir);
+						if (is_dir($newdir)) {
+							$file = $newdir.$handler.'.php';
+							if (file_exists($file)) {
+								$handler_file_found = $file;
+								break;
+							}
 						}
 					}
-				}
 
-				if (empty($handler_file_found)) {
-					throw new Exception('Missing log handler file '.$handler.'.php');
-				}
+					if (empty($handler_file_found)) {
+						throw new Exception('Missing log handler file '.$handler.'.php');
+					}
 
-				require_once $handler_file_found;
-				$loghandlerinstance = new $handler();
-				if (!$loghandlerinstance instanceof LogHandlerInterface) {
-					throw new Exception('Log handler does not extend LogHandlerInterface');
-				}
+					require_once $handler_file_found;
+					$loghandlerinstance = new $handler();
+					if (!$loghandlerinstance instanceof LogHandlerInterface) {
+						throw new Exception('Log handler does not extend LogHandlerInterface');
+					}
 
-				if (empty($this->loghandlers[$handler])) {
-					$this->loghandlers[$handler] = $loghandlerinstance;
+					if (empty($this->loghandlers[$handler])) {
+						$this->loghandlers[$handler] = $loghandlerinstance;
+					}
 				}
 			}
 		}
 
+		// Overwrite database values from conf into the conf.php file.
+		if (!empty($this->file->mailing_limit_sendbyweb)) {
+			$this->global->MAILING_LIMIT_SENDBYWEB = $this->file->mailing_limit_sendbyweb;
+		}
+		if (empty($this->global->MAILING_LIMIT_SENDBYWEB)) {
+			$this->global->MAILING_LIMIT_SENDBYWEB = 25;
+		}
+		if (!empty($this->file->mailing_limit_sendbycli)) {
+			$this->global->MAILING_LIMIT_SENDBYCLI = $this->file->mailing_limit_sendbycli;
+		}
+
 		return 0;
 	}
 }

+ 3 - 16
htdocs/master.inc.php

@@ -195,23 +195,10 @@ if (!is_numeric($conf->entity)) {
 	$conf->entity = 1;
 }
 
-if (!defined('NOREQUIREDB')) {
-	//print "Will work with data into entity instance number '".$conf->entity."'";
-
-	// Here we read database (llx_const table) and define $conf->global->XXX var.
-	$conf->setValues($db);
-}
+//print "We work with data into entity instance number '".$conf->entity."'";
 
-// Overwrite database value
-if (!empty($conf->file->mailing_limit_sendbyweb)) {
-	$conf->global->MAILING_LIMIT_SENDBYWEB = $conf->file->mailing_limit_sendbyweb;
-}
-if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) {
-	$conf->global->MAILING_LIMIT_SENDBYWEB = 25;
-}
-if (!empty($conf->file->mailing_limit_sendbycli)) {
-	$conf->global->MAILING_LIMIT_SENDBYCLI = $conf->file->mailing_limit_sendbycli;
-}
+// Here we read database (llx_const table) and define $conf->global->XXX var.
+$conf->setValues($db);
 
 // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
 if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) {