conf.class.php 43 KB

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