conf.class.php 44 KB

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