dolibarr  20.0.0-alpha
conf.class.php
Go to the documentation of this file.
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 
33 class Conf extends stdClass
34 {
38  public $file;
39 
43  public $db;
44 
48  public $global;
49 
53  public $browser;
54 
56  public $mycompany;
57  public $admin;
58  public $medias;
60  public $multicompany;
61 
64  public $delivery_note;
65 
66 
72  public $currency;
73 
77  public $theme; // Contains current theme ("eldy", "auguria", ...)
79 
82  public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
83 
84  public $email_from;
85 
88 
92  public $modules;
96  public $modules_parts;
97 
101  public $cache;
102 
106  public $headerdone;
107 
111  public $logbuffer = array();
112 
116  public $loghandlers = array();
117 
121  public $entity = 1;
125  public $entities = array();
126 
127  public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url
128  public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url
129  public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone
130  public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
131  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
132 
133  public $format_date_short; // Format of day with PHP/C tags (strftime functions)
134  public $format_date_short_java; // Format of day with Java tags
135  public $format_hour_short;
136  public $format_hour_short_duration;
137  public $format_date_text_short;
138  public $format_date_text;
139  public $format_date_hour_short;
140  public $format_date_hour_sec_short;
141  public $format_date_hour_text_short;
142  public $format_date_hour_text;
143 
144  public $liste_limit;
145 
146  public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user.
147 
148 
149  // TODO Remove this part.
150 
154  public $fournisseur;
155 
159  public $product;
160 
164  public $produit;
165  public $service;
169  public $contrat;
170  public $contract;
171  public $actions;
172  public $agenda;
173  public $propal;
177  public $commande;
178  public $order;
182  public $facture;
183  public $invoice;
184  public $user;
188  public $adherent;
189  public $member;
190  public $bank;
191  public $notification;
192  public $expensereport;
193  public $productbatch;
197  public $projet;
198  public $project;
199  public $supplier_proposal;
200  public $supplier_order;
201  public $supplier_invoice;
202  public $category;
203 
204 
208  public function __construct()
209  {
210  // Properly declare multi-modules objects.
211  $this->file = new stdClass();
212  $this->db = new stdClass();
214  $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1
215 
216  // Common objects that are not modules
217  $this->mycompany = new stdClass();
218  $this->admin = new stdClass();
219  $this->medias = new stdClass();
220  $this->global = new stdClass();
221 
222  // Common objects that are not modules and set by the main and not into the this->setValues()
223  $this->browser = new stdClass();
224 
225  // Common arrays
226  $this->cache = array();
227  $this->modules = array();
228  $this->modules_parts = array(
229  'css' => array(),
230  'js' => array(),
231  'tabs' => array(),
232  'triggers' => array(),
233  'login' => array(),
234  'substitutions' => array(),
235  'menus' => array(),
236  'theme' => array(),
237  'sms' => array(),
238  'tpl' => array(),
239  'barcode' => array(),
240  'models' => array(),
241  'societe' => array(),
242  'member' => array(),
243  'hooks' => array(),
244  'dir' => array(),
245  'syslog' => array(),
246  'websitetemplates' => array()
247  );
248 
249  // First level object that are modules.
250  // TODO Remove this part.
251  $this->multicompany = new stdClass();
252  $this->fournisseur = new stdClass();
253  $this->product = new stdClass();
254  $this->service = new stdClass();
255  $this->contrat = new stdClass();
256  $this->actions = new stdClass();
257  $this->agenda = new stdClass();
258  $this->commande = new stdClass();
259  $this->propal = new stdClass();
260  $this->facture = new stdClass();
261  $this->user = new stdClass();
262  $this->adherent = new stdClass();
263  $this->bank = new stdClass();
264  $this->notification = new stdClass();
265  $this->expensereport = new stdClass();
266  $this->productbatch = new stdClass();
267  }
268 
269 
278  public function setEntityValues($db, $entity)
279  {
280  if ($this->entity != $entity) {
281  // If we ask to reload setup for a new entity
282  $this->entity = $entity;
283  return $this->setValues($db);
284  }
285 
286  return 0;
287  }
288 
296  public function setValues($db)
297  {
298  dol_syslog(get_class($this)."::setValues");
299 
300  // Unset all old modules values
301  if (!empty($this->modules)) {
302  foreach ($this->modules as $m) {
303  if (isset($this->$m)) {
304  unset($this->$m);
305  }
306  }
307  }
308 
309  // Common objects that are not modules
310  $this->mycompany = new stdClass();
311  $this->admin = new stdClass();
312  $this->medias = new stdClass();
313  $this->global = new stdClass();
314 
315  // Common objects that are not modules and set by the main and not into the this->setValues()
316  //$this->browser = new stdClass(); // This is set by main and not into this setValues(), so we keep it intact.
317 
318  // First level object
319  // TODO Remove this part.
320  $this->fournisseur = new stdClass();
321  $this->product = new stdClass();
322  $this->service = new stdClass();
323  $this->contrat = new stdClass();
324  $this->actions = new stdClass();
325  $this->agenda = new stdClass();
326  $this->commande = new stdClass();
327  $this->propal = new stdClass();
328  $this->facture = new stdClass();
329  $this->user = new stdClass();
330  $this->adherent = new stdClass();
331  $this->bank = new stdClass();
332  $this->notification = new stdClass();
333  $this->expensereport = new stdClass();
334  $this->productbatch = new stdClass();
335 
336  // Common arrays
337  $this->cache = array();
338  $this->modules = array();
339  $this->modules_parts = array(
340  'css' => array(),
341  'js' => array(),
342  'tabs' => array(),
343  'triggers' => array(),
344  'login' => array(),
345  'substitutions' => array(),
346  'menus' => array(),
347  'theme' => array(),
348  'sms' => array(),
349  'tpl' => array(),
350  'barcode' => array(),
351  'models' => array(),
352  'societe' => array(),
353  'member' => array(),
354  'hooks' => array(),
355  'dir' => array(),
356  'syslog' => array(),
357  'websitetemplates' => array(),
358  );
359 
360  if (!is_null($db) && is_object($db)) {
361  include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
362 
363  // Define all global constants into $this->global->key=value
364  $sql = "SELECT ".$db->decrypt('name')." as name,";
365  $sql .= " ".$db->decrypt('value')." as value, entity";
366  $sql .= " FROM ".$db->prefix()."const";
367  $sql .= " WHERE entity IN (0,".$this->entity.")";
368  $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
369 
370  $resql = $db->query($sql);
371  if ($resql) {
372  $i = 0;
373  $numr = $db->num_rows($resql);
374  while ($i < $numr) {
375  $objp = $db->fetch_object($resql);
376  $key = $objp->name;
377  $value = $objp->value;
378  if ($key) {
379  // Allow constants values to be overridden by environment variables
380  if (isset($_SERVER['DOLIBARR_'.$key])) {
381  $value = $_SERVER['DOLIBARR_'.$key];
382  } elseif (isset($_ENV['DOLIBARR_'.$key])) {
383  $value = $_ENV['DOLIBARR_'.$key];
384  }
385 
386  $this->global->$key = dolDecrypt($value); // decrypt data excrypted with dolibarr_set_const($db, $name, $value)
387 
388  if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
389  $reg = array();
390  // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
391  if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
392  $partname = 'tabs';
393  $params = explode(':', $value, 2);
394  if (!is_array($this->modules_parts[$partname])) {
395  $this->modules_parts[$partname] = array();
396  }
397  $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
398  } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
399  // If this is constant for all generic part activated by a module. It initializes
400  // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
401  // modules_parts['models'], modules_parts['theme']
402  // modules_parts['sms'],
403  // modules_parts['css'], modules_parts['js'],...
404 
405  $modulename = strtolower($reg[1]);
406  $partname = strtolower($reg[2]);
407  if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
408  $this->modules_parts[$partname] = array();
409  }
410 
411  $arrValue = json_decode($value, true);
412 
413  if (is_array($arrValue)) {
414  $newvalue = $arrValue;
415  } elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
416  $newvalue = '/'.$modulename.'/core/'.$partname.'/';
417  } elseif (in_array($partname, array('models', 'theme', 'websitetemplates'))) {
418  $newvalue = '/'.$modulename.'/';
419  } elseif ($value == 1) {
420  $newvalue = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
421  } else { // $partname can be any other value like 'sms', ...
422  $newvalue = $value;
423  }
424 
425  if (!empty($newvalue)) {
426  $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $newvalue)); // $value may be a string or an array
427  }
428  } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
429  // If this is a module constant (must be at end)
430  $modulename = strtolower($reg[1]);
431  if ($modulename == 'propale') {
432  $modulename = 'propal';
433  }
434  if ($modulename == 'supplierproposal') {
435  $modulename = 'supplier_proposal';
436  }
437  $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules
438 
439  // deprecated in php 8.2
440  //if (version_compare(phpversion(), '8.2') < 0) {
441  if (!isset($this->$modulename) || !is_object($this->$modulename)) {
442  $this->$modulename = new stdClass(); // We need this to use the ->enabled and the ->multidir, ->dir...
443  }
444  $this->$modulename->enabled = true; // TODO Remove this
445 
446  // Duplicate entry with the new name
447  /*
448  $mapping = $this->deprecatedProperties();
449  if (array_key_exists($modulename, $mapping)) {
450  $newmodulename = $mapping[$modulename];
451  $this->modules[$newmodulename] = $newmodulename;
452 
453  if (!isset($this->$newmodulename) || !is_object($this->$newmodulename)) {
454  $this->$newmodulename = new stdClass(); // We need this to use the ->enabled and the ->multidir, ->dir...
455  }
456  $this->$newmodulename->enabled = true; // TODO Remove this
457  }
458  */
459  }
460  }
461  }
462  $i++;
463  }
464 
465  $db->free($resql);
466  }
467 
468  // Include other local file xxx/zzz_consts.php to overwrite some variables
469  if (!empty($this->global->LOCAL_CONSTS_FILES)) {
470  $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
471  foreach ($filesList as $file) {
472  $file = dol_sanitizeFileName($file);
473  dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
474  }
475  }
476 
477  //var_dump($this->modules);
478  //var_dump($this->modules_parts['theme']);
479 
480  // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
481  // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
482  //$this->global->MAIN_SERVER_TZ='Europe/Paris';
483  if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
484  try {
485  date_default_timezone_set($this->global->MAIN_SERVER_TZ);
486  } catch (Exception $e) {
487  dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
488  }
489  }
490 
491  // Object $mc
492  if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
493  global $mc;
494  $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
495  if ($ret && class_exists('ActionsMulticompany')) {
496  $mc = new ActionsMulticompany($db);
497  }
498  }
499 
500  // Clean some variables
501  if (empty($this->global->MAIN_MENU_STANDARD)) {
502  $this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
503  }
504  if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
505  $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
506  }
507  if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
508  $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
509  }
510  if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
511  $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
512  }
513  if (!isset($this->global->FACTURE_TVAOPTION)) {
514  $this->global->FACTURE_TVAOPTION = 1;
515  }
516 
517  // Variable globales LDAP
518  if (empty($this->global->LDAP_FIELD_FULLNAME)) {
519  $this->global->LDAP_FIELD_FULLNAME = '';
520  }
521  if (!isset($this->global->LDAP_KEY_USERS)) {
522  $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
523  }
524  if (!isset($this->global->LDAP_KEY_GROUPS)) {
525  $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
526  }
527  if (!isset($this->global->LDAP_KEY_CONTACTS)) {
528  $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
529  }
530  if (!isset($this->global->LDAP_KEY_MEMBERS)) {
531  $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
532  }
533  if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
534  $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
535  }
536 
537  // Load translation object with current language
538  if (empty($this->global->MAIN_LANG_DEFAULT)) {
539  $this->global->MAIN_LANG_DEFAULT = "en_US";
540  }
541 
542  $rootfordata = DOL_DATA_ROOT;
543  $rootforuser = DOL_DATA_ROOT;
544  // If multicompany module is enabled, we redefine the root of data
545  if (isModEnabled('multicompany') && !empty($this->entity) && $this->entity > 1) {
546  $rootfordata .= '/'.$this->entity;
547  }
548  // Set standard temporary folder name or global override
549  $rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
550 
551  // Define default dir_output and dir_temp for directories of modules
552  foreach ($this->modules as $module) {
553  //var_dump($module);
554  // For multicompany sharings
555  $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
556  $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
557  // For backward compatibility
558  $this->$module->dir_output = $rootfordata."/".$module;
559  $this->$module->dir_temp = $rootfortemp."/".$module."/temp";
560  }
561 
562  // External modules storage
563  if (!empty($this->modules_parts['dir'])) {
564  foreach ($this->modules_parts['dir'] as $module => $dirs) {
565  if (!empty($this->$module->enabled)) {
566  foreach ($dirs as $type => $name) { // $type is 'output' or 'temp'
567  $multidirname = 'multidir_'.$type;
568  $dirname = 'dir_'.$type;
569 
570  if ($type != 'temp') {
571  // For multicompany sharings
572  $this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
573 
574  // For backward compatibility
575  $this->$module->$dirname = $rootfordata."/".$name;
576  } else {
577  // For multicompany sharings
578  $this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
579 
580  // For backward compatibility
581  $this->$module->$dirname = $rootfortemp."/".$name."/temp";
582  }
583  }
584  }
585  }
586  }
587 
588  // For mycompany storage
589  $this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
590  $this->mycompany->multidir_temp = array($this->entity => $rootfortemp."/mycompany/temp");
591  // For backward compatibility
592  $this->mycompany->dir_output = $rootfordata."/mycompany";
593  $this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
594 
595  // For admin storage
596  $this->admin->dir_output = $rootfordata.'/admin';
597  $this->admin->dir_temp = $rootfortemp.'/admin/temp';
598 
599  // For user storage
600  $this->user->multidir_output = array($this->entity => $rootfordata."/users");
601  $this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
602  // For backward compatibility
603  $this->user->dir_output = $rootforuser."/users";
604  $this->user->dir_temp = $rootfortemp."/users/temp";
605 
606  // For proposal storage
607  $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
608  $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
609  // For backward compatibility
610  $this->propal->dir_output = $rootfordata."/propale";
611  $this->propal->dir_temp = $rootfortemp."/propale/temp";
612 
613  // For medias storage
614  $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
615  $this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
616 
617  // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
618 
619  // Module supplier is on
620  if (isModEnabled('fournisseur')) {
621  $this->fournisseur->commande = new stdClass();
622  $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
623  $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
624  $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
625  $this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
626 
627  $this->fournisseur->facture = new stdClass();
628  $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
629  $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
630  $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
631  $this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
632 
633  $this->supplier_proposal = new stdClass();
634  $this->supplier_proposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
635  $this->supplier_proposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
636  $this->supplier_proposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
637  $this->supplier_proposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
638 
639  $this->fournisseur->payment = new stdClass();
640  $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
641  $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
642  $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
643  $this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
644 
645  // To prepare split of module supplier into module 'supplier' + 'supplier_order' + 'supplier_invoice'
646  if (!getDolGlobalString('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
647  $this->supplier_order = new stdClass();
648  $this->supplier_order->enabled = 1;
649  $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
650  $this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
651  $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
652  $this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
653 
654  $this->supplier_invoice = new stdClass();
655  $this->supplier_invoice->enabled = 1;
656  $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
657  $this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
658  $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
659  $this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
660  }
661  }
662 
663  // Module product/service
664  $this->product->multidir_output = array($this->entity => $rootfordata."/produit");
665  $this->product->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
666  $this->service->multidir_output = array($this->entity => $rootfordata."/produit");
667  $this->service->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
668  // For backward compatibility
669  $this->product->dir_output = $rootfordata."/produit";
670  $this->product->dir_temp = $rootfortemp."/produit/temp";
671  $this->service->dir_output = $rootfordata."/produit";
672  $this->service->dir_temp = $rootfortemp."/produit/temp";
673 
674  // Module productbatch
675  $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
676  $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
677 
678  // Module contrat
679  $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
680  $this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
681  // For backward compatibility
682  $this->contrat->dir_output = $rootfordata."/contract";
683  $this->contrat->dir_temp = $rootfortemp."/contract/temp";
684 
685  // Module bank
686  $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
687  $this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
688  // For backward compatibility
689  $this->bank->dir_output = $rootfordata."/bank";
690  $this->bank->dir_temp = $rootfortemp."/bank/temp";
691 
692  // Set some default values
693  //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
694  $this->global->MAIN_MAIL_USE_MULTI_PART = 1;
695 
696  // societe
697  if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
698  $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
699  }
700  if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
701  $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
702  }
703 
704  if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
705  $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
706  }
707  if (empty($this->global->TICKET_ADDON)) {
708  $this->global->TICKET_ADDON = 'mod_ticket_simple';
709  }
710 
711  // Security
712  if (empty($this->global->USER_PASSWORD_GENERATED)) {
713  $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
714  }
715  if (empty($this->global->MAIN_UMASK)) {
716  $this->global->MAIN_UMASK = '0660'; // Default mask
717  } else {
718  // We remove the execute bits on the file umask
719  $tmpumask = (octdec($this->global->MAIN_UMASK) & 0666);
720  $tmpumask = decoct($tmpumask);
721  if (!preg_match('/^0/', $tmpumask)) {
722  $tmpumask = '0'.$tmpumask;
723  }
724  if (empty($tmpumask) || $tmpumask === '0') {
725  $tmpumask = '0664';
726  }
727  $this->global->MAIN_UMASK = $tmpumask;
728  }
729 
730  // conf->use_javascript_ajax
731  $this->use_javascript_ajax = 1;
732  if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
733  $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
734  }
735  // If no javascript_ajax, Ajax features are disabled.
736  if (empty($this->use_javascript_ajax)) {
737  unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
738  unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
739  unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
740  unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
741  }
742 
743  if (isModEnabled('productbatch')) {
744  // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE
745  $this->global->STOCK_CALCULATE_ON_BILL = 0;
746  $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
747  if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) {
748  $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1;
749  }
750  if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
751  $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
752  }
753  $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
754  $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
755  if (!isModEnabled('reception')) {
756  $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
757  } else {
758  if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) {
759  $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1;
760  }
761  if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
762  $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
763  }
764  }
765  }
766 
767  if (!isset($this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT)) {
768  $this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT = 1;
769  }
770 
771  // conf->currency
772  if (empty($this->global->MAIN_MONNAIE)) {
773  $this->global->MAIN_MONNAIE = 'EUR';
774  }
775  $this->currency = $this->global->MAIN_MONNAIE;
776 
777  if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
778  $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
779  }
780 
781  // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
782  if (empty($this->global->ACCOUNTING_MODE)) {
783  $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
784  }
785 
786  if (!isset($this->global->MAIN_ENABLE_AJAX_TOOLTIP)) {
787  $this->global->MAIN_ENABLE_AJAX_TOOLTIP = 0; // Not enabled by default (still trouble of persistent tooltip)
788  }
789 
790  // By default, suppliers objects can be linked to all projects
791  if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
792  $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
793  }
794 
795  // By default we enable feature to bill time spent
796  if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
797  $this->global->PROJECT_BILL_TIME_SPENT = 1;
798  }
799 
800  // MAIN_HTML_TITLE
801  if (!isset($this->global->MAIN_HTML_TITLE)) {
802  $this->global->MAIN_HTML_TITLE = 'thirdpartynameonly,contactnameonly,projectnameonly';
803  }
804 
805  // conf->liste_limit = constante de taille maximale des listes
806  if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) {
807  $this->global->MAIN_SIZE_LISTE_LIMIT = 15;
808  }
809  $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
810 
811  // conf->product->limit_size = constante de taille maximale des select de produit
812  if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
813  $this->global->PRODUIT_LIMIT_SIZE = 1000;
814  }
815  $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
816 
817  // Set PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE, may be modified later according to browser
818  $this->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = (isset($this->global->PRODUIT_DESC_IN_FORM) ? $this->global->PRODUIT_DESC_IN_FORM : 0);
819 
820  // conf->theme et $this->css
821  if (empty($this->global->MAIN_THEME)) {
822  $this->global->MAIN_THEME = "eldy";
823  }
824  if (!empty($this->global->MAIN_FORCETHEME)) {
825  $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
826  }
827  $this->theme = $this->global->MAIN_THEME;
828  $this->css = "/theme/".$this->theme."/style.css.php";
829 
830  // conf->email_from = email by default to send Dolibarr automatic emails
831  $this->email_from = "robot@example.com";
832  if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
833  $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
834  }
835 
836  // conf->notification->email_from = email by default to send Dolibarr notifications
837  if (isModEnabled('notification')) {
838  $this->notification->email_from = $this->email_from;
839  if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
840  $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
841  }
842  }
843 
844  if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
845  $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
846  }
847 
848  if (!isset($this->global->MAIN_FIX_FOR_BUGGED_MTA)) {
849  $this->global->MAIN_FIX_FOR_BUGGED_MTA = 1;
850  }
851 
852  // Format for date (used by default when not found or not searched in lang)
853  $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
854  $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
855  $this->format_hour_short = "%H:%M";
856  $this->format_hour_short_duration = "%H:%M";
857  $this->format_date_text_short = "%d %b %Y";
858  $this->format_date_text = "%d %B %Y";
859  $this->format_date_hour_short = "%d/%m/%Y %H:%M";
860  $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
861  $this->format_date_hour_text_short = "%d %b %Y %H:%M";
862  $this->format_date_hour_text = "%d %B %Y %H:%M";
863 
864  // Duration of workday
865  if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
866  $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
867  }
868 
869  // Limites decimales si non definie (peuvent etre egale a 0)
870  if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
871  $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
872  }
873  if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
874  $this->global->MAIN_MAX_DECIMALS_TOT = 2;
875  }
876  if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
877  $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
878  }
879 
880  // Default pdf option
881  if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
882  $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
883  }
884  if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
885  $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
886  }
887  if (!isset($this->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
888  $this->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING = 1;
889  }
890 
891  // Default max file size for upload (deprecated)
892  //$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
893 
894  // By default, we propagate contacts
895  if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
896  $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
897  }
898 
899  // By default, we do not use the zip town table but the table of third parties
900  if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
901  $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
902  }
903 
904  // By default, we open card if one found
905  if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
906  $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
907  }
908 
909  // By default, we show state code in combo list
910  if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
911  $this->global->MAIN_SHOW_STATE_CODE = 1;
912  }
913 
914  // By default, we show state code in combo list
915  if (!isset($this->global->MULTICURRENCY_USE_ORIGIN_TX)) {
916  $this->global->MULTICURRENCY_USE_ORIGIN_TX = 1;
917  }
918 
919  // By default, use an enclosure " for field with CRL or LF into content, + we also remove also CRL/LF chars.
920  if (!isset($this->global->USE_STRICT_CSV_RULES)) {
921  $this->global->USE_STRICT_CSV_RULES = 2;
922  }
923 
924  // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
925  if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
926  $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
927  }
928 
929  // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
930  if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
931  $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,reception,agenda,resource,adherent,blockedlog,ticket'; // '' means 'all'. Note that contact is added here as it should be a module later.
932  }
933  if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
934  foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
935  $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
936  }
937  }
938 
939  // Enable select2
940  if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
941  $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
942  }
943 
944  // Timeouts
945  if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
946  $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
947  }
948  if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
949  $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
950  }
951 
952  // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
953  if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
954  $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
955  }
956  if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
957  $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
958  }
959  if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
960  $this->global->TAX_MODE_SELL_SERVICE = 'payment';
961  }
962  if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
963  $this->global->TAX_MODE_BUY_SERVICE = 'payment';
964  }
965 
966  // Delay before warnings
967  // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
968  if (isset($this->agenda)) {
969  $this->adherent->subscription = new stdClass();
970  $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? (int) $this->global->MAIN_DELAY_MEMBERS : 0) * 86400;
971  }
972  if (isset($this->agenda)) {
973  $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? (int) $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
974  }
975  if (isset($this->projet)) {
976  $this->projet->warning_delay = (getDolGlobalInt('MAIN_DELAY_PROJECT_TO_CLOSE', 7) * 86400);
977  $this->projet->task = new StdClass();
978  $this->projet->task->warning_delay = (getDolGlobalInt('MAIN_DELAY_TASKS_TODO', 7) * 86400);
979  }
980 
981  if (isset($this->commande)) {
982  $this->commande->client = new stdClass();
983  $this->commande->fournisseur = new stdClass();
984  $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? (int) $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400;
985  $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;
986  }
987  if (isset($this->propal)) {
988  $this->propal->cloture = new stdClass();
989  $this->propal->facturation = new stdClass();
990  $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? (int) $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400;
991  $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? (int) $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400;
992  }
993  if (isset($this->facture)) {
994  $this->facture->client = new stdClass();
995  $this->facture->fournisseur = new stdClass();
996  $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? (int) $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400;
997  $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;
998  }
999  if (isset($this->contrat)) {
1000  $this->contrat->services = new stdClass();
1001  $this->contrat->services->inactifs = new stdClass();
1002  $this->contrat->services->expires = new stdClass();
1003  $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? (int) $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
1004  $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? (int) $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
1005  }
1006  if (isset($this->commande)) {
1007  $this->bank->rappro = new stdClass();
1008  $this->bank->cheque = new stdClass();
1009  $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? (int) $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
1010  $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? (int) $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
1011  }
1012  if (isset($this->expensereport)) {
1013  $this->expensereport->approve = new stdClass();
1014  $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? (int) $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400;
1015  $this->expensereport->payment = new stdClass();
1016  $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? (int) $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400;
1017  }
1018  if (isset($this->holiday)) {
1019  $this->holiday->approve = new stdClass();
1020  $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? (int) $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
1021  }
1022 
1023  if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
1024  $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
1025  }
1026 
1027  // For modules that want to disable top or left menu
1028  if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
1029  $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
1030  }
1031  if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
1032  $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
1033  }
1034 
1035  if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
1036  $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
1037  }
1038 
1039  // Save inconsistent option
1040  if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
1041  $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
1042  }
1043 
1044  if (!isset($this->global->MAIN_JS_GRAPH)) {
1045  $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
1046  }
1047 
1048  if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
1049  $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
1050  }
1051  if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
1052  $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
1053  }
1054 
1055  // Enable by default the CSRF protection by token.
1056  if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
1057  // Value 1 makes CSRF check for all POST parameters only
1058  // Value 2 makes also CSRF check for GET requests with action = a sensitive requests like action=del, action=remove...
1059  // Value 3 makes also CSRF check for all GET requests with a param action or massaction (except some non sensitive values)
1060  $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 2; // TODO Switch value to 3
1061  // 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)
1062  }
1063 
1064  if (!isset($this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) {
1065  $this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1;
1066  }
1067 
1068  if (!isset($this->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
1069  $this->global->MAIL_SMTP_USE_FROM_FOR_HELO = 2; // Use the domain in $dolibarr_main_url_root (mydomain.com)
1070  }
1071 
1072  if (!defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
1073  if (defined('MAIN_ANTIVIRUS_COMMAND')) {
1074  $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
1075  }
1076  if (defined('MAIN_ANTIVIRUS_PARAM')) {
1077  $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
1078  }
1079  }
1080 
1081  // For backward compatibility
1082  if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
1083  if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
1084  $this->global->LDAP_SYNCHRO_ACTIVE = 1;
1085  } elseif ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
1086  $this->global->LDAP_SYNCHRO_ACTIVE = 2;
1087  }
1088  }
1089  // For backward compatibility
1090  if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') {
1091  $this->global->LDAP_MEMBER_ACTIVE = 2;
1092  }
1093  // For backward compatibility
1094  if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') {
1095  $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2;
1096  }
1097 
1098  if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
1099  $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
1100  }
1101 
1102  if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) {
1103  $this->global->MAIN_NO_CONCAT_DESCRIPTION = 1;
1104  } else {
1105  unset($this->global->MAIN_NO_CONCAT_DESCRIPTION);
1106  }
1107 
1108 
1109  // Simple deprecation management. We do not use DolDeprecationHandlet for $conf.
1110 
1111  // product is new use
1112  if (isset($this->product)) {
1113  // For backward compatibility
1114  $this->produit = $this->product;
1115  }
1116  // invoice is new use, facture is old use still initialised
1117  if (isset($this->facture)) {
1118  $this->invoice = $this->facture;
1119  }
1120  // order is new use, commande is old use still initialised
1121  if (isset($this->commande)) {
1122  $this->order = $this->commande;
1123  }
1124  // contract is new use, contrat is old use still initialised
1125  if (isset($this->contrat)) {
1126  $this->contract = $this->contrat;
1127  }
1128  // category is new use, categorie is old use still initialised
1129  if (isset($this->categorie)) {
1130  $this->category = $this->categorie;
1131  }
1132  // project is new use, projet is old use still initialised
1133  if (isset($this->projet) && !isset($this->project)) {
1134  $this->project = $this->projet;
1135  }
1136  // member is new use, adherent is old use still initialised
1137  if (isset($this->adherent) && !isset($this->member)) {
1138  $this->member = $this->adherent;
1139  }
1140 
1141  // Object $mc
1142  if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
1143  if (is_object($mc)) {
1144  $mc->setValues($this);
1145  }
1146  }
1147 
1148  if (isModEnabled('syslog')) {
1149  // We init log handlers
1150  if (!empty($this->global->SYSLOG_HANDLERS)) {
1151  $handlers = json_decode($this->global->SYSLOG_HANDLERS);
1152  } else {
1153  $handlers = array();
1154  }
1155  foreach ($handlers as $handler) {
1156  $handler_file_found = '';
1157  $dirsyslogs = array('/core/modules/syslog/');
1158  if (!empty($this->modules_parts['syslog']) && is_array($this->modules_parts['syslog'])) {
1159  $dirsyslogs = array_merge($dirsyslogs, $this->modules_parts['syslog']);
1160  }
1161  foreach ($dirsyslogs as $reldir) {
1162  $dir = dol_buildpath($reldir, 0);
1163  $newdir = dol_osencode($dir);
1164  if (is_dir($newdir)) {
1165  $file = $newdir.$handler.'.php';
1166  if (file_exists($file)) {
1167  $handler_file_found = $file;
1168  break;
1169  }
1170  }
1171  }
1172 
1173  if (empty($handler_file_found)) {
1174  // If log handler has been removed of is badly setup, we must be able to continue code.
1175  //throw new Exception('Missing log handler file '.$handler.'.php');
1176  continue;
1177  }
1178 
1179  require_once $handler_file_found;
1180  $loghandlerinstance = new $handler();
1181  if (!$loghandlerinstance instanceof LogHandler) {
1182  throw new Exception('Log handler does not extend LogHandler');
1183  }
1184 
1185  if (empty($this->loghandlers[$handler])) {
1186  $this->loghandlers[$handler] = $loghandlerinstance;
1187  }
1188  }
1189  }
1190  }
1191 
1192  // Overwrite database values from conf into the conf.php file.
1193  if (!empty($this->file->mailing_limit_sendbyweb)) {
1194  $this->global->MAILING_LIMIT_SENDBYWEB = $this->file->mailing_limit_sendbyweb;
1195  }
1196  if (empty($this->global->MAILING_LIMIT_SENDBYWEB)) { // Limit by web can't be 0
1197  $this->global->MAILING_LIMIT_SENDBYWEB = 25;
1198  }
1199  if (!empty($this->file->mailing_limit_sendbycli)) {
1200  $this->global->MAILING_LIMIT_SENDBYCLI = $this->file->mailing_limit_sendbycli;
1201  }
1202  if (!empty($this->file->mailing_limit_sendbyday)) {
1203  $this->global->MAILING_LIMIT_SENDBYDAY = $this->file->mailing_limit_sendbyday;
1204  }
1205 
1206  return 0;
1207  }
1208 }
Class to stock current configuration.
Definition: conf.class.php:34
setValues($db)
Load setup values into conf object (read llx_const) Note that this->db->xxx, this->file->xxx have bee...
Definition: conf.class.php:296
$use_javascript_ajax
To store if javascript/ajax is enabked.
Definition: conf.class.php:68
$standard_menu
Used to store current menu handler.
Definition: conf.class.php:87
$expedition_bon
To store module status of special module names.
Definition: conf.class.php:63
$mycompany
To store some setup of generic modules.
Definition: conf.class.php:56
__construct()
Constructor.
Definition: conf.class.php:208
setEntityValues($db, $entity)
Load setup values into conf object (read llx_const) for a specified entity Note that this->db->xxx,...
Definition: conf.class.php:278
$currency
Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs-...
Definition: conf.class.php:72
$disable_compute
To store if javascript/ajax is enabked.
Definition: conf.class.php:70
$multicompany
To store properties of multi-company.
Definition: conf.class.php:60
Parent class for log handlers.
Definition: logHandler.php:25
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db user
Active Directory does not allow anonymous connections.
Definition: repair.php:126
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.