conf.class.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
  4. * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/core/class/conf.class.php
  23. * \ingroup core
  24. * \brief File of class to manage storage of current setup
  25. * Config is stored into file conf.php
  26. */
  27. /**
  28. * Class to stock current configuration
  29. */
  30. class Conf
  31. {
  32. /**
  33. * @var Object Associative array with properties found in conf file
  34. */
  35. public $file;
  36. /**
  37. * @var Object Associative array with some properties ->type, ->db, ...
  38. */
  39. public $db;
  40. //! To store properties found into database
  41. public $global;
  42. //! To store browser info
  43. public $browser;
  44. //! To store some setup of generic modules
  45. public $mycompany;
  46. public $admin;
  47. public $medias;
  48. //! To store properties of multi-company
  49. public $multicompany;
  50. //! To store module status of special module names
  51. public $expedition_bon;
  52. public $delivery_note;
  53. //! To store if javascript/ajax is enabked
  54. public $use_javascript_ajax;
  55. //! To store if javascript/ajax is enabked
  56. public $disable_compute;
  57. //! Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs->getCurrencySymbol($this->currency)
  58. public $currency;
  59. //! Used to store current css (from theme)
  60. public $theme; // Contains current theme ("eldy", "auguria", ...)
  61. public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
  62. //! Used to store current menu handler
  63. public $standard_menu;
  64. // List of activated modules
  65. public $modules;
  66. public $modules_parts;
  67. // An array to store cache results ->cache['nameofcache']=...
  68. public $cache;
  69. /**
  70. * @var int To tell header was output
  71. */
  72. public $headerdone;
  73. /**
  74. * @var string[]
  75. */
  76. public $logbuffer = array();
  77. /**
  78. * @var LogHandlerInterface[]
  79. */
  80. public $loghandlers = array();
  81. //! Used to store running instance for multi-company (default 1)
  82. public $entity = 1;
  83. //! Used to store list of entities to use for each element
  84. public $entities = array();
  85. public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url
  86. public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url
  87. public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone
  88. public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
  89. public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url. 0=default, 1=to say we use app from a webview app, 2=to say we use app from a webview app and keep ajax
  90. public $liste_limit;
  91. public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user.
  92. // TODO Remove this part.
  93. public $fournisseur;
  94. public $product;
  95. public $service;
  96. public $contrat;
  97. public $actions;
  98. public $agenda;
  99. public $commande;
  100. public $propal;
  101. public $facture;
  102. public $user;
  103. public $adherent;
  104. public $bank;
  105. public $notification;
  106. public $expensereport;
  107. public $productbatch;
  108. /**
  109. * Constructor
  110. */
  111. public function __construct()
  112. {
  113. // Properly declare multi-modules objects.
  114. $this->file = new stdClass();
  115. $this->db = new stdClass();
  116. //! Charset for HTML output and for storing data in memory
  117. $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1
  118. // Common objects that are not modules
  119. $this->mycompany = new stdClass();
  120. $this->admin = new stdClass();
  121. $this->medias = new stdClass();
  122. $this->global = new stdClass();
  123. // Common objects that are not modules and set by the main and not into the this->setValues()
  124. $this->browser = new stdClass();
  125. // Common arrays
  126. $this->cache = array();
  127. $this->modules = array();
  128. $this->modules_parts = array(
  129. 'css' => array(),
  130. 'js' => array(),
  131. 'tabs' => array(),
  132. 'triggers' => array(),
  133. 'login' => array(),
  134. 'substitutions' => array(),
  135. 'menus' => array(),
  136. 'theme' => array(),
  137. 'sms' => array(),
  138. 'tpl' => array(),
  139. 'barcode' => array(),
  140. 'models' => array(),
  141. 'societe' => array(),
  142. 'member' => array(),
  143. 'hooks' => array(),
  144. 'dir' => array(),
  145. 'syslog' => array()
  146. );
  147. // First level object that are modules.
  148. // TODO Remove this part.
  149. $this->multicompany = new stdClass();
  150. $this->fournisseur = new stdClass();
  151. $this->product = new stdClass();
  152. $this->service = new stdClass();
  153. $this->contrat = new stdClass();
  154. $this->actions = new stdClass();
  155. $this->agenda = new stdClass();
  156. $this->commande = new stdClass();
  157. $this->propal = new stdClass();
  158. $this->facture = new stdClass();
  159. $this->user = new stdClass();
  160. $this->adherent = new stdClass();
  161. $this->bank = new stdClass();
  162. $this->notification = new stdClass();
  163. $this->expensereport = new stdClass();
  164. $this->productbatch = new stdClass();
  165. }
  166. /**
  167. * Load setup values into conf object (read llx_const) for a specified entity
  168. * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setEntityValues is called.
  169. *
  170. * @param DoliDB $db Database handler
  171. * @param int $entity Entity to get
  172. * @return int < 0 if KO, >= 0 if OK
  173. */
  174. public function setEntityValues($db, $entity)
  175. {
  176. if ($this->entity != $entity) {
  177. // If we ask to reload setup for a new entity
  178. $this->entity = $entity;
  179. return $this->setValues($db);
  180. }
  181. return 0;
  182. }
  183. /**
  184. * Load setup values into conf object (read llx_const)
  185. * Note that this->db->xxx, this->file->xxx have been already set when setValues is called.
  186. *
  187. * @param DoliDB $db Database handler
  188. * @return int < 0 if KO, >= 0 if OK
  189. */
  190. public function setValues($db)
  191. {
  192. dol_syslog(get_class($this)."::setValues");
  193. // Unset all old modules values
  194. if (!empty($this->modules)) {
  195. foreach ($this->modules as $m) {
  196. if (isset($this->$m)) unset($this->$m);
  197. }
  198. }
  199. // Common objects that are not modules
  200. $this->mycompany = new stdClass();
  201. $this->admin = new stdClass();
  202. $this->medias = new stdClass();
  203. $this->global = new stdClass();
  204. // Common objects that are not modules and set by the main and not into the this->setValues()
  205. //$this->browser = new stdClass(); // This is set by main and not into this setValues(), so we keep it intact.
  206. // First level object
  207. // TODO Remove this part.
  208. $this->fournisseur = new stdClass();
  209. $this->product = new stdClass();
  210. $this->service = new stdClass();
  211. $this->contrat = new stdClass();
  212. $this->actions = new stdClass();
  213. $this->agenda = new stdClass();
  214. $this->commande = new stdClass();
  215. $this->propal = new stdClass();
  216. $this->facture = new stdClass();
  217. $this->contrat = new stdClass();
  218. $this->user = new stdClass();
  219. $this->adherent = new stdClass();
  220. $this->bank = new stdClass();
  221. $this->notification = new stdClass();
  222. $this->expensereport = new stdClass();
  223. $this->productbatch = new stdClass();
  224. // Common arrays
  225. $this->cache = array();
  226. $this->modules = array();
  227. $this->modules_parts = array(
  228. 'css' => array(),
  229. 'js' => array(),
  230. 'tabs' => array(),
  231. 'triggers' => array(),
  232. 'login' => array(),
  233. 'substitutions' => array(),
  234. 'menus' => array(),
  235. 'theme' => array(),
  236. 'sms' => array(),
  237. 'tpl' => array(),
  238. 'barcode' => array(),
  239. 'models' => array(),
  240. 'societe' => array(),
  241. 'member' => array(),
  242. 'hooks' => array(),
  243. 'dir' => array(),
  244. 'syslog' => array(),
  245. );
  246. if (!is_null($db) && is_object($db)) {
  247. include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  248. // Define all global constants into $this->global->key=value
  249. $sql = "SELECT ".$db->decrypt('name')." as name,";
  250. $sql .= " ".$db->decrypt('value')." as value, entity";
  251. $sql .= " FROM ".$db->prefix()."const";
  252. $sql .= " WHERE entity IN (0,".$this->entity.")";
  253. $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
  254. $resql = $db->query($sql);
  255. if ($resql) {
  256. $i = 0;
  257. $numr = $db->num_rows($resql);
  258. while ($i < $numr) {
  259. $objp = $db->fetch_object($resql);
  260. $key = $objp->name;
  261. $value = $objp->value;
  262. if ($key) {
  263. // Allow constants values to be overridden by environment variables
  264. if (isset($_SERVER['DOLIBARR_'.$key])) {
  265. $value = $_SERVER['DOLIBARR_'.$key];
  266. } elseif (isset($_ENV['DOLIBARR_'.$key])) {
  267. $value = $_ENV['DOLIBARR_'.$key];
  268. }
  269. $this->global->$key = dolDecrypt($value);
  270. if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
  271. $reg = array();
  272. // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
  273. if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
  274. $partname = 'tabs';
  275. $params = explode(':', $value, 2);
  276. if (!is_array($this->modules_parts[$partname])) {
  277. $this->modules_parts[$partname] = array();
  278. }
  279. $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
  280. } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
  281. // If this is constant for all generic part activated by a module. It initializes
  282. // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
  283. // modules_parts['models'], modules_parts['theme']
  284. // modules_parts['sms'],
  285. // modules_parts['css'], modules_parts['js'],...
  286. $modulename = strtolower($reg[1]);
  287. $partname = strtolower($reg[2]);
  288. if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
  289. $this->modules_parts[$partname] = array();
  290. }
  291. $arrValue = json_decode($value, true);
  292. if (is_array($arrValue)) {
  293. $newvalue = $arrValue;
  294. } elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
  295. $newvalue = '/'.$modulename.'/core/'.$partname.'/';
  296. } elseif (in_array($partname, array('models', 'theme'))) {
  297. $newvalue = '/'.$modulename.'/';
  298. } elseif (in_array($partname, array('sms'))) {
  299. $newvalue = '/'.$modulename.'/';
  300. } elseif ($value == 1) {
  301. $newvalue = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
  302. } else {
  303. $newvalue = $value;
  304. }
  305. if (!empty($newvalue)) {
  306. $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $newvalue)); // $value may be a string or an array
  307. }
  308. } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
  309. // If this is a module constant (must be at end)
  310. $modulename = strtolower($reg[1]);
  311. if ($modulename == 'propale') {
  312. $modulename = 'propal';
  313. }
  314. if ($modulename == 'supplierproposal') {
  315. $modulename = 'supplier_proposal';
  316. }
  317. $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules
  318. // deprecated in php 8.2
  319. if (!isset($this->$modulename) || !is_object($this->$modulename)) {
  320. $this->$modulename = new stdClass();
  321. }
  322. $this->$modulename->enabled = true;
  323. }
  324. }
  325. }
  326. $i++;
  327. }
  328. $db->free($resql);
  329. }
  330. // Include other local file xxx/zzz_consts.php to overwrite some variables
  331. if (!empty($this->global->LOCAL_CONSTS_FILES)) {
  332. $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
  333. foreach ($filesList as $file) {
  334. $file = dol_sanitizeFileName($file);
  335. dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
  336. }
  337. }
  338. //var_dump($this->modules);
  339. //var_dump($this->modules_parts['theme']);
  340. // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
  341. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
  342. //$this->global->MAIN_SERVER_TZ='Europe/Paris';
  343. if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
  344. try {
  345. date_default_timezone_set($this->global->MAIN_SERVER_TZ);
  346. } catch (Exception $e) {
  347. dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
  348. }
  349. }
  350. // Object $mc
  351. if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
  352. global $mc;
  353. $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
  354. if ($ret) {
  355. $mc = new ActionsMulticompany($db);
  356. $this->mc = $mc;
  357. }
  358. }
  359. // Clean some variables
  360. if (empty($this->global->MAIN_MENU_STANDARD)) {
  361. $this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
  362. }
  363. if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
  364. $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
  365. }
  366. if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
  367. $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
  368. }
  369. if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
  370. $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
  371. }
  372. if (!isset($this->global->FACTURE_TVAOPTION)) {
  373. $this->global->FACTURE_TVAOPTION = 1;
  374. }
  375. // Variable globales LDAP
  376. if (empty($this->global->LDAP_FIELD_FULLNAME)) {
  377. $this->global->LDAP_FIELD_FULLNAME = '';
  378. }
  379. if (!isset($this->global->LDAP_KEY_USERS)) {
  380. $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
  381. }
  382. if (!isset($this->global->LDAP_KEY_GROUPS)) {
  383. $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
  384. }
  385. if (!isset($this->global->LDAP_KEY_CONTACTS)) {
  386. $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
  387. }
  388. if (!isset($this->global->LDAP_KEY_MEMBERS)) {
  389. $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
  390. }
  391. if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
  392. $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
  393. }
  394. // Load translation object with current language
  395. if (empty($this->global->MAIN_LANG_DEFAULT)) {
  396. $this->global->MAIN_LANG_DEFAULT = "en_US";
  397. }
  398. $rootfordata = DOL_DATA_ROOT;
  399. $rootforuser = DOL_DATA_ROOT;
  400. // If multicompany module is enabled, we redefine the root of data
  401. if (isModEnabled('multicompany') && !empty($this->entity) && $this->entity > 1) {
  402. $rootfordata .= '/'.$this->entity;
  403. }
  404. // Set standard temporary folder name or global override
  405. $rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
  406. // Define default dir_output and dir_temp for directories of modules
  407. foreach ($this->modules as $module) {
  408. //var_dump($module);
  409. // For multicompany sharings
  410. $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
  411. $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
  412. // For backward compatibility
  413. $this->$module->dir_output = $rootfordata."/".$module;
  414. $this->$module->dir_temp = $rootfortemp."/".$module."/temp";
  415. }
  416. // External modules storage
  417. if (!empty($this->modules_parts['dir'])) {
  418. foreach ($this->modules_parts['dir'] as $module => $dirs) {
  419. if (!empty($this->$module->enabled)) {
  420. foreach ($dirs as $type => $name) { // $type is 'output' or 'temp'
  421. $multidirname = 'multidir_'.$type;
  422. $dirname = 'dir_'.$type;
  423. if ($type != 'temp') {
  424. // For multicompany sharings
  425. $this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
  426. // For backward compatibility
  427. $this->$module->$dirname = $rootfordata."/".$name;
  428. } else {
  429. // For multicompany sharings
  430. $this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
  431. // For backward compatibility
  432. $this->$module->$dirname = $rootfortemp."/".$name."/temp";
  433. }
  434. }
  435. }
  436. }
  437. }
  438. // For mycompany storage
  439. $this->mycompany->dir_output = $rootfordata."/mycompany";
  440. $this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
  441. // For admin storage
  442. $this->admin->dir_output = $rootfordata.'/admin';
  443. $this->admin->dir_temp = $rootfortemp.'/admin/temp';
  444. // For user storage
  445. $this->user->multidir_output = array($this->entity => $rootfordata."/users");
  446. $this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
  447. // For backward compatibility
  448. $this->user->dir_output = $rootforuser."/users";
  449. $this->user->dir_temp = $rootfortemp."/users/temp";
  450. // For proposal storage
  451. $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
  452. $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
  453. // For backward compatibility
  454. $this->propal->dir_output = $rootfordata."/propale";
  455. $this->propal->dir_temp = $rootfortemp."/propale/temp";
  456. // For medias storage
  457. $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
  458. $this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
  459. // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
  460. // Module fournisseur
  461. if (!empty($this->fournisseur)) {
  462. $this->fournisseur->commande = new stdClass();
  463. $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
  464. $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
  465. $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
  466. $this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
  467. $this->fournisseur->facture = new stdClass();
  468. $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
  469. $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
  470. $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
  471. $this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
  472. $this->supplierproposal = new stdClass();
  473. $this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
  474. $this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
  475. $this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
  476. $this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
  477. $this->fournisseur->payment = new stdClass();
  478. $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
  479. $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
  480. $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
  481. $this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
  482. // To prepare split of module fournisseur into module 'fournisseur' + supplier_order + supplier_invoice
  483. 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
  484. $this->supplier_order = new stdClass();
  485. $this->supplier_order->enabled = 1;
  486. $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
  487. $this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
  488. $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
  489. $this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
  490. $this->supplier_invoice = new stdClass();
  491. $this->supplier_invoice->enabled = 1;
  492. $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
  493. $this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
  494. $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
  495. $this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
  496. }
  497. }
  498. // Module product/service
  499. $this->product->multidir_output = array($this->entity => $rootfordata."/produit");
  500. $this->product->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
  501. $this->service->multidir_output = array($this->entity => $rootfordata."/produit");
  502. $this->service->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
  503. // For backward compatibility
  504. $this->product->dir_output = $rootfordata."/produit";
  505. $this->product->dir_temp = $rootfortemp."/produit/temp";
  506. $this->service->dir_output = $rootfordata."/produit";
  507. $this->service->dir_temp = $rootfortemp."/produit/temp";
  508. // Module productbatch
  509. $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
  510. $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
  511. // Module contrat
  512. $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
  513. $this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
  514. // For backward compatibility
  515. $this->contrat->dir_output = $rootfordata."/contract";
  516. $this->contrat->dir_temp = $rootfortemp."/contract/temp";
  517. // Module bank
  518. $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
  519. $this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
  520. // For backward compatibility
  521. $this->bank->dir_output = $rootfordata."/bank";
  522. $this->bank->dir_temp = $rootfortemp."/bank/temp";
  523. // Set some default values
  524. //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
  525. $this->global->MAIN_MAIL_USE_MULTI_PART = 1;
  526. // societe
  527. if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
  528. $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
  529. }
  530. if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
  531. $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
  532. }
  533. if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
  534. $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
  535. }
  536. if (empty($this->global->TICKET_ADDON)) {
  537. $this->global->TICKET_ADDON = 'mod_ticket_simple';
  538. }
  539. // Security
  540. if (empty($this->global->USER_PASSWORD_GENERATED)) {
  541. $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
  542. }
  543. if (empty($this->global->MAIN_UMASK)) {
  544. $this->global->MAIN_UMASK = '0660'; // Default mask
  545. } else {
  546. // We remove the execute bits on the file umask
  547. $tmpumask = (octdec($this->global->MAIN_UMASK) & 0666);
  548. $tmpumask = decoct($tmpumask);
  549. if (!preg_match('/^0/', $tmpumask)) {
  550. $tmpumask = '0'.$tmpumask;
  551. }
  552. if (empty($tmpumask) || $tmpumask === '0') {
  553. $tmpumask = '0664';
  554. }
  555. $this->global->MAIN_UMASK = $tmpumask;
  556. }
  557. // conf->use_javascript_ajax
  558. $this->use_javascript_ajax = 1;
  559. if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
  560. $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
  561. }
  562. // If no javascript_ajax, Ajax features are disabled.
  563. if (empty($this->use_javascript_ajax)) {
  564. unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
  565. unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
  566. unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
  567. unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
  568. }
  569. if (isModEnabled('productbatch')) {
  570. // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE
  571. $this->global->STOCK_CALCULATE_ON_BILL = 0;
  572. $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
  573. if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1;
  574. if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
  575. $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
  576. $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
  577. if (!isModEnabled('reception')) {
  578. $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
  579. } else {
  580. if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1;
  581. if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
  582. }
  583. }
  584. if (!isset($this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT)) {
  585. $this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT = 1;
  586. }
  587. // conf->currency
  588. if (empty($this->global->MAIN_MONNAIE)) {
  589. $this->global->MAIN_MONNAIE = 'EUR';
  590. }
  591. $this->currency = $this->global->MAIN_MONNAIE;
  592. if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
  593. $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
  594. }
  595. // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
  596. if (empty($this->global->ACCOUNTING_MODE)) {
  597. $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
  598. }
  599. // By default, suppliers objects can be linked to all projects
  600. if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
  601. $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
  602. }
  603. // By default we enable feature to bill time spent
  604. if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
  605. $this->global->PROJECT_BILL_TIME_SPENT = 1;
  606. }
  607. // MAIN_HTML_TITLE
  608. if (!isset($this->global->MAIN_HTML_TITLE)) {
  609. $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
  610. }
  611. // conf->liste_limit = constante de taille maximale des listes
  612. if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) {
  613. $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
  614. }
  615. $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
  616. // conf->product->limit_size = constante de taille maximale des select de produit
  617. if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
  618. $this->global->PRODUIT_LIMIT_SIZE = 1000;
  619. }
  620. $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
  621. // Set PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE, may be modified later according to browser
  622. $this->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = (isset($this->global->PRODUIT_DESC_IN_FORM) ? $this->global->PRODUIT_DESC_IN_FORM : 0);
  623. // conf->theme et $this->css
  624. if (empty($this->global->MAIN_THEME)) {
  625. $this->global->MAIN_THEME = "eldy";
  626. }
  627. if (!empty($this->global->MAIN_FORCETHEME)) {
  628. $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
  629. }
  630. $this->theme = $this->global->MAIN_THEME;
  631. $this->css = "/theme/".$this->theme."/style.css.php";
  632. // conf->email_from = email by default to send Dolibarr automatic emails
  633. $this->email_from = "robot@example.com";
  634. if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
  635. $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
  636. }
  637. // conf->notification->email_from = email by default to send Dolibarr notifications
  638. if (isModEnabled('notification')) {
  639. $this->notification->email_from = $this->email_from;
  640. if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
  641. $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
  642. }
  643. }
  644. if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
  645. $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
  646. }
  647. if (!isset($this->global->MAIN_FIX_FOR_BUGGED_MTA)) {
  648. $this->global->MAIN_FIX_FOR_BUGGED_MTA = 1;
  649. }
  650. // Format for date (used by default when not found or not searched in lang)
  651. $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
  652. $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
  653. $this->format_hour_short = "%H:%M";
  654. $this->format_hour_short_duration = "%H:%M";
  655. $this->format_date_text_short = "%d %b %Y";
  656. $this->format_date_text = "%d %B %Y";
  657. $this->format_date_hour_short = "%d/%m/%Y %H:%M";
  658. $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
  659. $this->format_date_hour_text_short = "%d %b %Y %H:%M";
  660. $this->format_date_hour_text = "%d %B %Y %H:%M";
  661. // Duration of workday
  662. if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
  663. $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
  664. }
  665. // Limites decimales si non definie (peuvent etre egale a 0)
  666. if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
  667. $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
  668. }
  669. if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
  670. $this->global->MAIN_MAX_DECIMALS_TOT = 2;
  671. }
  672. if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
  673. $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
  674. }
  675. // Default pdf option
  676. if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
  677. $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
  678. }
  679. if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
  680. $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
  681. }
  682. // Default max file size for upload (deprecated)
  683. //$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
  684. // By default, we propagate contacts
  685. if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
  686. $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
  687. }
  688. // By default, we do not use the zip town table but the table of third parties
  689. if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
  690. $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
  691. }
  692. // By default, we open card if one found
  693. if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
  694. $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
  695. }
  696. // By default, we show state code in combo list
  697. if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
  698. $this->global->MAIN_SHOW_STATE_CODE = 1;
  699. }
  700. // By default, we show state code in combo list
  701. if (!isset($this->global->MULTICURRENCY_USE_ORIGIN_TX)) {
  702. $this->global->MULTICURRENCY_USE_ORIGIN_TX = 1;
  703. }
  704. // By default, use an enclosure " for field with CRL or LF into content, + we also remove also CRL/LF chars.
  705. if (!isset($this->global->USE_STRICT_CSV_RULES)) {
  706. $this->global->USE_STRICT_CSV_RULES = 2;
  707. }
  708. // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
  709. if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
  710. $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
  711. }
  712. // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
  713. if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
  714. $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,reception,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
  715. }
  716. if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
  717. foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
  718. $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
  719. }
  720. }
  721. // Enable select2
  722. if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
  723. $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
  724. }
  725. // Timeouts
  726. if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
  727. $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
  728. }
  729. if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
  730. $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
  731. }
  732. // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
  733. if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
  734. $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
  735. }
  736. if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
  737. $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
  738. }
  739. if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
  740. $this->global->TAX_MODE_SELL_SERVICE = 'payment';
  741. }
  742. if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
  743. $this->global->TAX_MODE_BUY_SERVICE = 'payment';
  744. }
  745. // Delay before warnings
  746. // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
  747. if (isset($this->agenda)) {
  748. $this->adherent->subscription = new stdClass();
  749. $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? (int) $this->global->MAIN_DELAY_MEMBERS : 0) * 86400;
  750. }
  751. if (isset($this->agenda)) {
  752. $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? (int) $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
  753. }
  754. if (isset($this->projet)) {
  755. $this->projet->warning_delay = (getDolGlobalInt('MAIN_DELAY_PROJECT_TO_CLOSE', 7) * 86400);
  756. $this->projet->task = new StdClass();
  757. $this->projet->task->warning_delay = (getDolGlobalInt('MAIN_DELAY_TASKS_TODO', 7) * 86400);
  758. }
  759. if (isset($this->commande)) {
  760. $this->commande->client = new stdClass();
  761. $this->commande->fournisseur = new stdClass();
  762. $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? (int) $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400;
  763. $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? (int) $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400;
  764. }
  765. if (isset($this->propal)) {
  766. $this->propal->cloture = new stdClass();
  767. $this->propal->facturation = new stdClass();
  768. $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? (int) $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400;
  769. $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? (int) $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400;
  770. }
  771. if (isset($this->facture)) {
  772. $this->facture->client = new stdClass();
  773. $this->facture->fournisseur = new stdClass();
  774. $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? (int) $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400;
  775. $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? (int) $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400;
  776. }
  777. if (isset($this->contrat)) {
  778. $this->contrat->services = new stdClass();
  779. $this->contrat->services->inactifs = new stdClass();
  780. $this->contrat->services->expires = new stdClass();
  781. $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? (int) $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
  782. $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? (int) $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
  783. }
  784. if (isset($this->commande)) {
  785. $this->bank->rappro = new stdClass();
  786. $this->bank->cheque = new stdClass();
  787. $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? (int) $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
  788. $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? (int) $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
  789. }
  790. if (isset($this->expensereport)) {
  791. $this->expensereport->approve = new stdClass();
  792. $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? (int) $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400;
  793. $this->expensereport->payment = new stdClass();
  794. $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? (int) $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400;
  795. }
  796. if (isset($this->holiday)) {
  797. $this->holiday->approve = new stdClass();
  798. $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? (int) $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
  799. }
  800. if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
  801. $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
  802. }
  803. // For modules that want to disable top or left menu
  804. if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
  805. $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
  806. }
  807. if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
  808. $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
  809. }
  810. if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
  811. $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
  812. }
  813. // Save inconsistent option
  814. if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
  815. $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
  816. }
  817. if (!isset($this->global->MAIN_JS_GRAPH)) {
  818. $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
  819. }
  820. if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
  821. $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
  822. }
  823. if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
  824. $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
  825. }
  826. // Enable by default the CSRF protection by token.
  827. if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
  828. // Value 1 makes CSRF check for all POST parameters only
  829. // Value 2 makes also CSRF check for GET requests with action = a sensitive requests like action=del, action=remove...
  830. // Value 3 makes also CSRF check for all GET requests with a param action or massaction (except some sensitive values)
  831. $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 2; // TODO Switch value to 3
  832. // Note: Set MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL=1 to have a renewal of token at each page call instead of each session (not recommended)
  833. }
  834. if (!isset($this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) {
  835. $this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1;
  836. }
  837. if (!isset($this->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
  838. $this->global->MAIL_SMTP_USE_FROM_FOR_HELO = 2;
  839. }
  840. if (!defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
  841. if (defined('MAIN_ANTIVIRUS_COMMAND')) {
  842. $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
  843. }
  844. if (defined('MAIN_ANTIVIRUS_PARAM')) {
  845. $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
  846. }
  847. }
  848. // For backward compatibility
  849. if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
  850. if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
  851. $this->global->LDAP_SYNCHRO_ACTIVE = 1;
  852. } elseif ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
  853. $this->global->LDAP_SYNCHRO_ACTIVE = 2;
  854. }
  855. }
  856. // For backward compatibility
  857. if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') {
  858. $this->global->LDAP_MEMBER_ACTIVE = 2;
  859. }
  860. // For backward compatibility
  861. if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') {
  862. $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2;
  863. }
  864. if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
  865. $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
  866. }
  867. if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) {
  868. $this->global->MAIN_NO_CONCAT_DESCRIPTION = 1;
  869. } else {
  870. unset($this->global->MAIN_NO_CONCAT_DESCRIPTION);
  871. }
  872. // product is new use
  873. if (isset($this->product)) {
  874. // For backward compatibility
  875. $this->produit = $this->product;
  876. }
  877. // invoice is new use, facture is old use still initialised
  878. if (isset($this->facture)) {
  879. $this->invoice = $this->facture;
  880. }
  881. // order is new use, commande is old use still initialised
  882. if (isset($this->commande)) {
  883. $this->order = $this->commande;
  884. }
  885. // contract is new use, contrat is old use still initialised
  886. if (isset($this->contrat)) {
  887. $this->contract = $this->contrat;
  888. }
  889. // category is new use, categorie is old use still initialised
  890. if (isset($this->categorie)) {
  891. $this->category = $this->categorie;
  892. }
  893. // project is new use, projet is old use still initialised
  894. if (isset($this->projet) && !isset($this->project)) {
  895. $this->project = $this->projet;
  896. }
  897. // member is new use, adherent is old use still initialised
  898. if (isset($this->adherent) && !isset($this->member)) {
  899. $this->member = $this->adherent;
  900. }
  901. // Object $mc
  902. if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
  903. if (is_object($mc)) {
  904. $mc->setValues($this);
  905. }
  906. }
  907. if (isModEnabled('syslog')) {
  908. // We init log handlers
  909. if (!empty($this->global->SYSLOG_HANDLERS)) {
  910. $handlers = json_decode($this->global->SYSLOG_HANDLERS);
  911. } else {
  912. $handlers = array();
  913. }
  914. foreach ($handlers as $handler) {
  915. $handler_file_found = '';
  916. $dirsyslogs = array('/core/modules/syslog/');
  917. if (!empty($this->modules_parts['syslog']) && is_array($this->modules_parts['syslog'])) {
  918. $dirsyslogs = array_merge($dirsyslogs, $this->modules_parts['syslog']);
  919. }
  920. foreach ($dirsyslogs as $reldir) {
  921. $dir = dol_buildpath($reldir, 0);
  922. $newdir = dol_osencode($dir);
  923. if (is_dir($newdir)) {
  924. $file = $newdir.$handler.'.php';
  925. if (file_exists($file)) {
  926. $handler_file_found = $file;
  927. break;
  928. }
  929. }
  930. }
  931. if (empty($handler_file_found)) {
  932. // If log handler has been removed of is badly setup, we must be able to continue code.
  933. //throw new Exception('Missing log handler file '.$handler.'.php');
  934. continue;
  935. }
  936. require_once $handler_file_found;
  937. $loghandlerinstance = new $handler();
  938. if (!$loghandlerinstance instanceof LogHandlerInterface) {
  939. throw new Exception('Log handler does not extend LogHandlerInterface');
  940. }
  941. if (empty($this->loghandlers[$handler])) {
  942. $this->loghandlers[$handler] = $loghandlerinstance;
  943. }
  944. }
  945. }
  946. }
  947. // Overwrite database values from conf into the conf.php file.
  948. if (!empty($this->file->mailing_limit_sendbyweb)) {
  949. $this->global->MAILING_LIMIT_SENDBYWEB = $this->file->mailing_limit_sendbyweb;
  950. }
  951. if (empty($this->global->MAILING_LIMIT_SENDBYWEB)) { // Limit by web can't be 0
  952. $this->global->MAILING_LIMIT_SENDBYWEB = 25;
  953. }
  954. if (!empty($this->file->mailing_limit_sendbycli)) {
  955. $this->global->MAILING_LIMIT_SENDBYCLI = $this->file->mailing_limit_sendbycli;
  956. }
  957. if (!empty($this->file->mailing_limit_sendbyday)) {
  958. $this->global->MAILING_LIMIT_SENDBYDAY = $this->file->mailing_limit_sendbyday;
  959. }
  960. return 0;
  961. }
  962. }