dolibarr 22.0.5
conf.class.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
5 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
6 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
8 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
35class Conf extends stdClass
36{
40 public $file;
41
45 public $db;
46
50 public $global;
51
55 public $browser;
56
58
61 public $mycompany;
62
66 public $admin;
67
71 public $medias;
72
76 public $multicompany;
77
79
82 public $expedition_bon;
86 public $delivery_note;
87
91 public $use_javascript_ajax;
92
96 public $disable_compute;
97
101 public $currency;
102
106 public $theme;
107
111 public $css;
112
116 public $email_from;
117
121 public $standard_menu;
122
126 public $modules;
130 public $modules_parts;
131
135 public $cache;
136
140 public $headerdone;
141
145 public $logbuffer = array();
146
150 public $loghandlers = array();
151
155 public $entity = 1;
156
160 public $entities = array();
161
165 public $dol_hide_topmenu;
166
170 public $dol_hide_leftmenu;
171
175 public $dol_optimize_smallscreen;
176
180 public $dol_no_mouse_hover;
184 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
185
189 public $format_date_short; // Format of day with PHP/C tags (strftime functions)
193 public $format_date_short_java; // Format of day with Java tags
197 public $format_hour_short;
201 public $format_hour_short_duration;
205 public $format_date_text_short;
209 public $format_date_text;
213 public $format_date_hour_short;
217 public $format_date_hour_sec_short;
221 public $format_date_hour_text_short;
225 public $format_date_hour_text;
226
230 public $liste_limit;
231
235 public $main_checkbox_left_column;
236
240 public $tzuserinputkey = 'tzserver';
241
242
243 // TODO Remove this part.
244
248 public $fournisseur;
249
253 public $product;
254
259 public $produit;
260
264 public $service;
265
270 public $contrat;
271
275 public $contract;
276
280 public $actions;
281
285 public $agenda;
286
290 public $propal;
291
296 public $commande;
297
301 public $order;
302
307 public $facture;
308
312 public $invoice;
313
317 public $user;
318
323 public $adherent;
324
328 public $member;
329
333 public $bank;
334
338 public $notification;
339
343 public $expensereport;
344
348 public $productbatch;
349
353 public $api;
354
359 public $projet;
360
364 public $project;
365
369 public $supplier_proposal;
370
374 public $supplier_order;
375
379 public $supplier_invoice;
380
384 public $category;
385
389 public $mrp;
390
394 public function __construct()
395 {
396 // Properly declare multi-modules objects.
397 $this->file = new stdClass();
398 $this->db = new stdClass();
400 $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1
401
402 // Common objects that are not modules
403 $this->mycompany = new stdClass();
404 $this->admin = new stdClass();
405 $this->medias = new stdClass();
406 $this->global = new stdClass();
407
408 // Common objects that are not modules and set by the main and not into the this->setValues()
409 $this->browser = new stdClass();
410
411 // Common arrays
412 $this->cache = array();
413 $this->modules = array();
414 $this->modules_parts = array(
415 'css' => array(),
416 'js' => array(),
417 'tabs' => array(),
418 'triggers' => array(),
419 'login' => array(),
420 'substitutions' => array(),
421 'menus' => array(),
422 'theme' => array(),
423 'sms' => array(),
424 'tpl' => array(),
425 'barcode' => array(),
426 'models' => array(),
427 'societe' => array(),
428 'member' => array(),
429 'hooks' => array(),
430 'dir' => array(),
431 'syslog' => array(),
432 'websitetemplates' => array(),
433 //'captcha' => array() // Can be removed,this does not generates warning
434 );
435
436 // First level object that are modules.
437 // TODO Remove this part.
438 $this->multicompany = new stdClass();
439 $this->fournisseur = new stdClass();
440 $this->product = new stdClass();
441 $this->service = new stdClass();
442 $this->contrat = new stdClass();
443 $this->actions = new stdClass();
444 $this->agenda = new stdClass();
445 $this->commande = new stdClass();
446 $this->propal = new stdClass();
447 $this->facture = new stdClass();
448 $this->user = new stdClass();
449 $this->adherent = new stdClass();
450 $this->bank = new stdClass();
451 $this->mailing = new stdClass();
452 $this->notification = new stdClass();
453 $this->expensereport = new stdClass();
454 $this->productbatch = new stdClass();
455 $this->api = new stdClass();
456 }
457
458
467 public function setEntityValues($db, $entity)
468 {
469 if ($this->entity != $entity) {
470 // If we ask to reload setup for a new entity
471 $this->entity = $entity;
472 return $this->setValues($db);
473 }
474
475 return 0;
476 }
477
485 public function setValues($db)
486 {
487 dol_syslog(get_class($this)."::setValues");
488
489 // Unset all old modules values
490 if (!empty($this->modules)) {
491 foreach ($this->modules as $m) {
492 if (isset($this->$m)) {
493 unset($this->$m);
494 }
495 }
496 }
497
498 // Common objects that are not modules
499 $this->mycompany = new stdClass();
500 $this->admin = new stdClass();
501 $this->medias = new stdClass();
502 $this->global = new stdClass();
503
504 // Common objects that are not modules and set by the main and not into the this->setValues()
505 //$this->browser = new stdClass(); // This is set by main and not into this setValues(), so we keep it intact.
506
507 // First level object
508 // TODO Remove this part.
509 $this->fournisseur = new stdClass();
510 $this->compta = new stdClass();
511 $this->product = new stdClass();
512 $this->service = new stdClass();
513 $this->contrat = new stdClass();
514 $this->actions = new stdClass();
515 $this->agenda = new stdClass();
516 $this->commande = new stdClass();
517 $this->propal = new stdClass();
518 $this->facture = new stdClass();
519 $this->user = new stdClass();
520 $this->adherent = new stdClass();
521 $this->bank = new stdClass();
522 $this->notification = new stdClass();
523 $this->expensereport = new stdClass();
524 $this->productbatch = new stdClass();
525 $this->api = new stdClass();
526
527 // Common arrays
528 $this->cache = array();
529 $this->modules = array();
530 $this->modules_parts = array(
531 'css' => array(),
532 'js' => array(),
533 'tabs' => array(),
534 'triggers' => array(),
535 'login' => array(),
536 'substitutions' => array(),
537 'menus' => array(),
538 'theme' => array(),
539 'sms' => array(),
540 'tpl' => array(),
541 'barcode' => array(),
542 'models' => array(),
543 'societe' => array(),
544 'member' => array(),
545 'hooks' => array(),
546 'dir' => array(),
547 'syslog' => array(),
548 'websitetemplates' => array(),
549 );
550
551 if (!is_null($db) && is_object($db)) {
552 include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
553
554 // Define all global constants into $this->global->key=value
555 $sql = "SELECT ".$db->decrypt('name')." as name,";
556 $sql .= " ".$db->decrypt('value')." as value, entity";
557 $sql .= " FROM ".$db->prefix()."const";
558 $sql .= " WHERE entity IN (0,".$this->entity.")";
559 $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
560
561 $resql = $db->query($sql);
562 if ($resql) {
563 $i = 0;
564 $numr = $db->num_rows($resql);
565 while ($i < $numr) {
566 $objp = $db->fetch_object($resql);
567 $key = $objp->name;
568 $value = $objp->value;
569 if ($key) {
570 // Allow constants values to be overridden by environment variables
571 if (isset($_SERVER['DOLIBARR_'.$key])) {
572 $value = $_SERVER['DOLIBARR_'.$key];
573 } elseif (isset($_ENV['DOLIBARR_'.$key])) {
574 $value = $_ENV['DOLIBARR_'.$key];
575 }
576
577 $this->global->$key = dolDecrypt($value); // decrypt data excrypted with dolibarr_set_const($db, $name, $value)
578
579 if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
580 $reg = array();
581 // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
582 if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
583 $partname = 'tabs';
584 $params = explode(':', $value, 2);
585 if (!is_array($this->modules_parts[$partname])) {
586 $this->modules_parts[$partname] = array();
587 }
588 $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
589 } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
590 // If this is a constant for all generic part activated by a module. It initializes
591 // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
592 // modules_parts['models'], modules_parts['theme']
593 // modules_parts['sms'],
594 // modules_parts['css'], modules_parts['js'],...
595
596 $modulename = strtolower($reg[1]);
597 $partname = strtolower($reg[2]);
598 if (!array_key_exists($partname, $this->modules_parts) || !is_array($this->modules_parts[$partname])) {
599 $this->modules_parts[$partname] = array();
600 }
601
602 //$arrValue = json_decode($value, true, null, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR);
603 $arrValue = json_decode($value, true);
604 //var_dump($key); var_dump($value); var_dump($arrValue);
605
606 if (is_array($arrValue)) {
607 $newvalue = $arrValue;
608 } elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
609 $newvalue = '/'.$modulename.'/core/'.$partname.'/';
610 } elseif (in_array($partname, array('models', 'theme', 'websitetemplates'))) {
611 $newvalue = '/'.$modulename.'/';
612 } elseif (in_array($partname, array('captcha'))) {
613 $newvalue = '/'.$modulename.'/core/modules/security/'.$partname.'/';
614 } elseif ($value == 1) {
615 $newvalue = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
616 } else { // $partname can be any other value like 'sms', ...
617 $newvalue = $value;
618 }
619
620 if (!empty($newvalue)) {
621 $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $newvalue)); // $value may be a string or an array
622 }
623 } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
624 // If this is a module constant (must be at end)
625 $modulename = strtolower($reg[1]);
626 if ($modulename == 'propale') {
627 $modulename = 'propal';
628 }
629 if ($modulename == 'supplierproposal') {
630 $modulename = 'supplier_proposal';
631 }
632 $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules
633
634 // deprecated in php 8.2
635 //if (version_compare(phpversion(), '8.2') < 0) {
636 if (!isset($this->$modulename) || !is_object($this->$modulename)) {
637 $this->$modulename = new stdClass(); // We need this to use the ->enabled and the ->multidir, ->dir...
638 }
639 $this->$modulename->enabled = true; // TODO Remove this
640
641 // Duplicate entry with the new name
642 /*
643 $mapping = $this->deprecatedProperties();
644 if (array_key_exists($modulename, $mapping)) {
645 $newmodulename = $mapping[$modulename];
646 $this->modules[$newmodulename] = $newmodulename;
647
648 if (!isset($this->$newmodulename) || !is_object($this->$newmodulename)) {
649 $this->$newmodulename = new stdClass(); // We need this to use the ->enabled and the ->multidir, ->dir...
650 }
651 $this->$newmodulename->enabled = true; // TODO Remove this
652 }
653 */
654 }
655 }
656 }
657 $i++;
658 }
659
660 $db->free($resql);
661 }
662
663 // Include other local file xxx/zzz_consts.php to overwrite some variables
664 if (!empty($this->global->LOCAL_CONSTS_FILES)) {
665 $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
666 foreach ($filesList as $file) {
667 $file = dol_sanitizeFileName($file);
668 dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
669 }
670 }
671
672 //var_dump($this->modules);
673 //var_dump($this->modules_parts['theme']);
674
675 // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
676 // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
677 //$this->global->MAIN_SERVER_TZ='Europe/Paris';
678 if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
679 try {
680 date_default_timezone_set($this->global->MAIN_SERVER_TZ);
681 } catch (Exception $e) {
682 dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
683 }
684 }
685
686 // Object $mc
687 global $mc;
688 $mc = null;
689 if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
690 $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
691 if ($ret && class_exists('ActionsMulticompany')) {
692 $mc = new ActionsMulticompany($db);
693 }
694 }
695
696 // Clean some variables
697 if (empty($this->global->MAIN_MENU_STANDARD)) {
698 $this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
699 }
700 if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
701 $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
702 }
703 if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
704 $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
705 }
706 if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
707 $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
708 }
709 if (!isset($this->global->FACTURE_TVAOPTION)) {
710 $this->global->FACTURE_TVAOPTION = 1;
711 }
712
713 // Variable globales LDAP
714 if (empty($this->global->LDAP_FIELD_FULLNAME)) {
715 $this->global->LDAP_FIELD_FULLNAME = '';
716 }
717 if (!isset($this->global->LDAP_KEY_USERS)) {
718 $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
719 }
720 if (!isset($this->global->LDAP_KEY_GROUPS)) {
721 $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
722 }
723 if (!isset($this->global->LDAP_KEY_CONTACTS)) {
724 $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
725 }
726 if (!isset($this->global->LDAP_KEY_MEMBERS)) {
727 $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
728 }
729 if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
730 $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
731 }
732
733 // Load translation object with current language
734 if (empty($this->global->MAIN_LANG_DEFAULT)) {
735 $this->global->MAIN_LANG_DEFAULT = "en_US";
736 }
737
738 $rootfordata = DOL_DATA_ROOT;
739 $rootforuser = DOL_DATA_ROOT;
740 // If multicompany module is enabled, we redefine the root of data
741 if (isModEnabled('multicompany') && !empty($this->entity) && $this->entity > 1) {
742 $rootfordata .= '/'.$this->entity;
743 }
744 // Set standard temporary folder name or global override
745 $rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
746
747 // Define default dir_output and dir_temp for directories of modules
748 foreach ($this->modules as $module) {
749 //var_dump($module);
750 // For multicompany sharings
751 $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
752 $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
753 // For backward compatibility
754 $this->$module->dir_output = $rootfordata."/".$module;
755 $this->$module->dir_temp = $rootfortemp."/".$module."/temp";
756 }
757
758 // External modules storage
759 if (!empty($this->modules_parts['dir'])) {
760 foreach ($this->modules_parts['dir'] as $module => $dirs) {
761 if (!empty($this->$module->enabled)) {
762 foreach ($dirs as $type => $name) { // $type is 'output' or 'temp'
763 $multidirname = 'multidir_'.$type;
764 $dirname = 'dir_'.$type;
765
766 if ($type != 'temp') {
767 // For multicompany sharings
768 $this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
769
770 // For backward compatibility
771 $this->$module->$dirname = $rootfordata."/".$name;
772 } else {
773 // For multicompany sharings
774 $this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
775
776 // For backward compatibility
777 $this->$module->$dirname = $rootfortemp."/".$name."/temp";
778 }
779 }
780 }
781 }
782 }
783
784 // For mycompany storage
785 $this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
786 $this->mycompany->multidir_temp = array($this->entity => $rootfortemp."/mycompany/temp");
787 // For backward compatibility
788 $this->mycompany->dir_output = $rootfordata."/mycompany";
789 $this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
790
791 // For admin storage
792 $this->admin->dir_output = $rootfordata.'/admin';
793 $this->admin->dir_temp = $rootfortemp.'/admin/temp';
794
795 // For api storage
796 $this->api->dir_output = $rootfordata.'/api';
797 $this->api->dir_temp = $rootfortemp.'/api/temp';
798
799 // For user storage
800 $this->user->multidir_output = array($this->entity => $rootfordata."/users");
801 $this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
802 // For backward compatibility
803 $this->user->dir_output = $rootforuser."/users";
804 $this->user->dir_temp = $rootfortemp."/users/temp";
805
806 // For proposal storage
807 $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
808 $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
809 // For backward compatibility
810 $this->propal->dir_output = $rootfordata."/propale";
811 $this->propal->dir_temp = $rootfortemp."/propale/temp";
812
813 // For medias storage
814 $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
815 $this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
816
817 // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
818
819 // Module supplier is on
820 if (isModEnabled('fournisseur')) {
821 $this->fournisseur->commande = new stdClass();
822 $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
823 $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
824 $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
825 $this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
826
827 $this->fournisseur->facture = new stdClass();
828 $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
829 $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
830 $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
831 $this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
832
833 $this->supplier_proposal = new stdClass();
834 $this->supplier_proposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
835 $this->supplier_proposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
836 $this->supplier_proposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
837 $this->supplier_proposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
838
839 $this->fournisseur->payment = new stdClass();
840 $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
841 $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
842 $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
843 $this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
844
845 // To prepare split of module supplier into module 'supplier' + 'supplier_order' + 'supplier_invoice'
846 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
847 $this->supplier_order = new stdClass();
848 $this->supplier_order->enabled = 1;
849 $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
850 $this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
851 $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
852 $this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
853
854 $this->supplier_invoice = new stdClass();
855 $this->supplier_invoice->enabled = 1;
856 $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
857 $this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
858 $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
859 $this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
860 }
861 }
862
863 // Module compta
864 $this->compta->payment = new stdClass();
865 $this->compta->payment->dir_output = $rootfordata."/compta/payment";
866 $this->compta->payment->dir_temp = $rootfortemp."/compta/payment/temp";
867
868 // Module product/service
869 $this->product->multidir_output = array($this->entity => $rootfordata."/produit");
870 $this->product->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
871 $this->service->multidir_output = array($this->entity => $rootfordata."/produit");
872 $this->service->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
873 // For backward compatibility
874 $this->product->dir_output = $rootfordata."/produit";
875 $this->product->dir_temp = $rootfortemp."/produit/temp";
876 $this->service->dir_output = $rootfordata."/produit";
877 $this->service->dir_temp = $rootfortemp."/produit/temp";
878
879 // Module productbatch
880 $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
881 $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
882
883 // Module contrat
884 $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
885 $this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
886 // For backward compatibility
887 $this->contrat->dir_output = $rootfordata."/contract";
888 $this->contrat->dir_temp = $rootfortemp."/contract/temp";
889
890 // Module bank
891 $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
892 $this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
893 // For backward compatibility
894 $this->bank->dir_output = $rootfordata."/bank";
895 $this->bank->dir_temp = $rootfortemp."/bank/temp";
896
897 // Set some default values
898 //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
899 $this->global->MAIN_MAIL_USE_MULTI_PART = 1;
900
901 // societe
902 if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
903 $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
904 }
905 if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
906 $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
907 }
908
909 if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
910 $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
911 }
912 if (empty($this->global->TICKET_ADDON)) {
913 $this->global->TICKET_ADDON = 'mod_ticket_simple';
914 }
915
916 // Security
917 if (empty($this->global->USER_PASSWORD_GENERATED)) {
918 $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
919 }
920 if (empty($this->global->MAIN_UMASK)) {
921 $this->global->MAIN_UMASK = '0660'; // Default mask
922 } else {
923 // We remove the execute bits on the file umask
924 $tmpumask = (octdec(getDolGlobalString('MAIN_UMASK')) & 0666);
925 $tmpumask = decoct($tmpumask);
926 if (!preg_match('/^0/', $tmpumask)) { // Convert string '123' into octal representation '0123'
927 $tmpumask = '0'.$tmpumask;
928 }
929 if (empty($tmpumask)) { // when $tmpmask is null, '', or '0'
930 $tmpumask = '0664';
931 }
932 $this->global->MAIN_UMASK = $tmpumask;
933 }
934
935 // conf->use_javascript_ajax
936 $this->use_javascript_ajax = 1;
937 if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
938 $this->use_javascript_ajax = (int) !$this->global->MAIN_DISABLE_JAVASCRIPT;
939 }
940 // If no javascript_ajax, Ajax features are disabled.
941 if (empty($this->use_javascript_ajax)) {
942 unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
943 unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
944 unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
945 unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
946 }
947
948 if (isModEnabled('productbatch')) {
949 // If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE
950 $this->global->STOCK_CALCULATE_ON_BILL = 0;
951 $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
952 if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) {
953 $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1;
954 }
955 if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
956 $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
957 }
958 $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
959 $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
960 if (!isModEnabled('reception')) {
961 $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
962 } else {
963 if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) {
964 $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1;
965 }
966 if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
967 $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
968 }
969 }
970 }
971 if (!isset($this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT)) {
972 $this->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT = 1;
973 }
974
975 // conf->currency
976 if (empty($this->global->MAIN_MONNAIE)) {
977 $this->global->MAIN_MONNAIE = 'EUR';
978 }
979 $this->currency = $this->global->MAIN_MONNAIE;
980
981 if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
982 $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
983 }
984
985 // Option for accounting modules (simple or double parties). Define mode of calculation of reports.
986 if (empty($this->global->ACCOUNTING_MODE)) {
987 $this->global->ACCOUNTING_MODE = 'CREANCES-DETTES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' (default)
988 }
989
990 if (!isset($this->global->MAIN_ENABLE_AJAX_TOOLTIP)) {
991 $this->global->MAIN_ENABLE_AJAX_TOOLTIP = 1; // Try to have it enabled by default with v21+
992 }
993
994 // By default, suppliers objects can be linked to all projects
995 if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
996 $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
997 }
998
999 // By default we enable feature to bill time spent
1000 if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
1001 $this->global->PROJECT_BILL_TIME_SPENT = 1;
1002 }
1003
1004 // MAIN_HTML_TITLE
1005 if (!isset($this->global->MAIN_HTML_TITLE)) {
1006 $this->global->MAIN_HTML_TITLE = 'thirdpartynameonly,contactnameonly,projectnameonly';
1007 }
1008 // MAIN_FEATURE_TO_SHOW_TOP_MENU_URL_IN_FRAME
1009 if (!isset($this->global->MAIN_FEATURE_TO_SHOW_TOP_MENU_URL_IN_FRAME)) {
1010 $this->global->MAIN_FEATURE_TO_SHOW_TOP_MENU_URL_IN_FRAME = 1;
1011 }
1012
1013 // conf->liste_limit = constant to limit size of lists
1014 // This value can be overwritten by user choice in main.inc.php
1015 $this->liste_limit = getDolGlobalInt('MAIN_SIZE_LISTE_LIMIT', 15);
1016 if ((int) $this->liste_limit <= 0) {
1017 // Mode automatic. Similar code than into main.inc.php
1018 $this->liste_limit = 15;
1019 if (!empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 700) {
1020 $this->liste_limit = 8;
1021 } elseif (!empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 910) {
1022 $this->liste_limit = 10;
1023 } elseif (!empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] > 1130) {
1024 $this->liste_limit = 20;
1025 }
1026 }
1027
1028 // Set PRODUIT_LIMIT_SIZE if never defined
1029 if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
1030 $this->global->PRODUIT_LIMIT_SIZE = 1000;
1031 }
1032
1033 // Set PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE, may be modified later according to browser
1034 $this->global->PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE = getDolGlobalInt('PRODUIT_DESC_IN_FORM');
1035
1036 // conf->theme et $this->css
1037 if (empty($this->global->MAIN_THEME)) {
1038 $this->global->MAIN_THEME = "eldy";
1039 }
1040 if (!empty($this->global->MAIN_FORCETHEME)) {
1041 $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
1042 }
1043 $this->theme = $this->global->MAIN_THEME;
1044 $this->css = "/theme/".$this->theme."/style.css.php";
1045
1046 // conf->email_from = email by default to send Dolibarr automatic emails
1047 $this->email_from = "robot@example.com";
1048 if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
1049 $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
1050 }
1051
1052 // conf->notification->email_from = email by default to send Dolibarr notifications
1053 if (isModEnabled('notification')) {
1054 $this->notification->email_from = $this->email_from;
1055 if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
1056 $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
1057 }
1058 }
1059
1060 if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
1061 $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
1062 }
1063
1064 if (!isset($this->global->MAIN_FIX_FOR_BUGGED_MTA)) {
1065 $this->global->MAIN_FIX_FOR_BUGGED_MTA = 1;
1066 }
1067
1068 // Format for date (used by default when not found or not searched in lang)
1069 $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
1070 $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
1071 $this->format_hour_short = "%H:%M";
1072 $this->format_hour_short_duration = "%H:%M";
1073 $this->format_date_text_short = "%d %b %Y";
1074 $this->format_date_text = "%d %B %Y";
1075 $this->format_date_hour_short = "%d/%m/%Y %H:%M";
1076 $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
1077 $this->format_date_hour_text_short = "%d %b %Y %H:%M";
1078 $this->format_date_hour_text = "%d %B %Y %H:%M";
1079
1080 // Duration of workday
1081 if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
1082 $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
1083 }
1084
1085 // Limites decimales si non definie (peuvent etre egale a 0)
1086 if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
1087 $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
1088 }
1089 if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
1090 $this->global->MAIN_MAX_DECIMALS_TOT = 2;
1091 }
1092 if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
1093 $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
1094 }
1095
1096 // Non working days by default if not set in setup
1097 if (!isset($this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) {
1098 $this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1;
1099 }
1100 if (!isset($this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) {
1101 $this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1;
1102 }
1103
1104 // Default pdf option
1105 if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
1106 $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
1107 }
1108 if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
1109 $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
1110 }
1111 if (!isset($this->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1112 $this->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING = 1;
1113 }
1114
1115 // Default max file size for upload (deprecated)
1116 //$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
1117
1118 // By default, we propagate contacts
1119 if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
1120 $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
1121 }
1122
1123 // By default, we do not use the zip town table but the table of third parties
1124 if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
1125 $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
1126 }
1127
1128 // By default, we open card if one found
1129 if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
1130 $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
1131 }
1132
1133 // By default, we show state code in combo list
1134 if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
1135 $this->global->MAIN_SHOW_STATE_CODE = 1;
1136 }
1137
1138 // By default, we show state code in combo list
1139 if (!isset($this->global->MULTICURRENCY_USE_ORIGIN_TX)) {
1140 $this->global->MULTICURRENCY_USE_ORIGIN_TX = 1;
1141 }
1142
1143 // By default, use an enclosure " for field with CRL or LF into content, + we also remove also CRL/LF chars.
1144 if (!isset($this->global->USE_STRICT_CSV_RULES)) {
1145 $this->global->USE_STRICT_CSV_RULES = 2;
1146 }
1147
1148 // By default, accept to create members with no login
1149 if (!isset($this->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
1150 $this->global->ADHERENT_LOGIN_NOT_REQUIRED = 1;
1151 }
1152
1153 // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
1154 if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
1155 $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
1156 }
1157
1158 // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
1159 if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
1160 $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.
1161 }
1162 if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
1163 foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
1164 $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
1165 }
1166 }
1167 //$this->global->MAIN_MODULES_FOR_EXTERNAL .= ",ecm";
1168
1169 // Enable select2
1170 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
1171 $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
1172 }
1173
1174 // Timeouts
1175 if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
1176 $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
1177 }
1178 if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
1179 $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
1180 }
1181
1182 // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
1183 if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
1184 $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
1185 }
1186 if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
1187 $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
1188 }
1189 if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
1190 $this->global->TAX_MODE_SELL_SERVICE = 'payment';
1191 }
1192 if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
1193 $this->global->TAX_MODE_BUY_SERVICE = 'payment';
1194 }
1195
1196 // Delay before warnings
1197 // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
1198 if (isset($this->agenda)) {
1199 $this->adherent->subscription = new stdClass();
1200 $this->adherent->subscription->warning_delay = getDolGlobalInt('MAIN_DELAY_MEMBERS') * 86400;
1201 }
1202 if (isset($this->agenda)) {
1203 $this->agenda->warning_delay = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO', 7) * 86400;
1204 }
1205 if (isset($this->projet)) {
1206 $this->projet->warning_delay = (getDolGlobalInt('MAIN_DELAY_PROJECT_TO_CLOSE', 7) * 86400);
1207 $this->projet->task = new StdClass();
1208 $this->projet->task->warning_delay = (getDolGlobalInt('MAIN_DELAY_TASKS_TODO', 7) * 86400);
1209 }
1210
1211 if (isset($this->commande)) {
1212 $this->commande->client = new stdClass();
1213 $this->commande->fournisseur = new stdClass();
1214 $this->commande->client->warning_delay = getDolGlobalInt('MAIN_DELAY_ORDERS_TO_PROCESS', 2) * 86400;
1215 $this->commande->fournisseur->warning_delay = getDolGlobalInt('MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', 7) * 86400;
1216 }
1217 if (isset($this->propal)) {
1218 $this->propal->cloture = new stdClass();
1219 $this->propal->facturation = new stdClass();
1220 $this->propal->cloture->warning_delay = getDolGlobalInt('MAIN_DELAY_PROPALS_TO_CLOSE') * 86400;
1221 $this->propal->facturation->warning_delay = getDolGlobalInt('MAIN_DELAY_PROPALS_TO_BILL') * 86400;
1222 }
1223 // @phpstan-ignore-next-line
1224 if (isset($this->supplier_proposal)) {
1225 $this->supplier_proposal->cloture = new stdClass();
1226 $this->supplier_proposal->facturation = new stdClass();
1227 $this->supplier_proposal->cloture->warning_delay = getDolGlobalInt('MAIN_DELAY_SUPPLIER_PROPALS_TO_CLOSE') * 86400;
1228 $this->supplier_proposal->facturation->warning_delay = getDolGlobalInt('MAIN_DELAY_SUPPLIER_PROPALS_TO_BILL') * 86400;
1229 }
1230 if (isset($this->facture)) {
1231 $this->facture->client = new stdClass();
1232 $this->facture->fournisseur = new stdClass();
1233 $this->facture->client->warning_delay = getDolGlobalInt('MAIN_DELAY_CUSTOMER_BILLS_UNPAYED') * 86400;
1234 $this->facture->fournisseur->warning_delay = getDolGlobalInt('MAIN_DELAY_SUPPLIER_BILLS_TO_PAY') * 86400;
1235 }
1236 if (isset($this->contrat)) {
1237 $this->contrat->services = new stdClass();
1238 $this->contrat->services->inactifs = new stdClass();
1239 $this->contrat->services->expires = new stdClass();
1240 $this->contrat->services->inactifs->warning_delay = getDolGlobalInt('MAIN_DELAY_NOT_ACTIVATED_SERVICES') * 86400;
1241 $this->contrat->services->expires->warning_delay = getDolGlobalInt('MAIN_DELAY_RUNNING_SERVICES') * 86400;
1242 }
1243
1244 $this->bank->rappro = new stdClass();
1245 $this->bank->cheque = new stdClass();
1246 $this->bank->rappro->warning_delay = getDolGlobalInt('MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE') * 86400;
1247 $this->bank->cheque->warning_delay = getDolGlobalInt('MAIN_DELAY_CHEQUES_TO_DEPOSIT') * 86400;
1248
1249 if (isset($this->expensereport)) {
1250 $this->expensereport->approve = new stdClass();
1251 $this->expensereport->approve->warning_delay = getDolGlobalInt('MAIN_DELAY_EXPENSEREPORTS') * 86400;
1252 $this->expensereport->payment = new stdClass();
1253 $this->expensereport->payment->warning_delay = getDolGlobalInt('MIN_DELAY_EXPENSEREPORTS_TO_PAY') * 86400;
1254 }
1255 if (isset($this->holiday)) {
1256 $this->holiday->approve = new stdClass();
1257 $this->holiday->approve->warning_delay = getDolGlobalInt('MAIN_DELAY_HOLIDAYS') * 86400;
1258 }
1259 if (isset($this->mrp)) {
1260 $this->mrp->progress = new stdClass();
1261 $this->mrp->progress->warning_delay = getDolGlobalInt('MAIN_DELAY_MRP') * 86400;
1262 }
1263
1264 if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT')) {
1265 $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
1266 }
1267
1268 if (!isset($this->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
1269 $this->global->MAIN_CHECKBOX_LEFT_COLUMN = 1;
1270 }
1271
1272 // conf->main_checkbox_left_column = constant to set checkbox list to left
1273 if (!isset($this->main_checkbox_left_column)) {
1274 $this->main_checkbox_left_column = getDolGlobalInt("MAIN_CHECKBOX_LEFT_COLUMN");
1275 }
1276
1277 // For modules that want to disable top or left menu
1278 if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
1279 $this->dol_hide_topmenu = (int) (bool) getDolGlobalInt('MAIN_HIDE_TOP_MENU');
1280 }
1281 if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
1282 $this->dol_hide_leftmenu = (int) (bool) getDolGlobalInt('MAIN_HIDE_LEFT_MENU');
1283 }
1284
1285 if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
1286 $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
1287 }
1288
1289 // Save inconsistent option
1290 if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
1291 $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
1292 }
1293
1294 if (!isset($this->global->MAIN_JS_GRAPH)) {
1295 $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
1296 }
1297
1298 if (!isset($this->global->THEME_ELDY_USEBORDERONTABLE)) {
1299 $this->global->THEME_ELDY_USEBORDERONTABLE = 1;
1300 }
1301
1302 if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
1303 $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com/api/';
1304 }
1305 if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
1306 $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorepublicapi';
1307 }
1308
1309 // Enable by default the CSRF protection by token.
1310 if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) {
1311 // Value 1 makes CSRF check for all POST parameters only
1312 // Value 2 makes also CSRF check for GET requests with action = a sensitive requests like action=del, action=remove...
1313 // Value 3 makes also CSRF check for all GET requests with a param action or massaction (except some non sensitive values)
1314 $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 2; // TODO Switch value to 3
1315 // 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)
1316 }
1317
1318 if (!isset($this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) {
1319 $this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1;
1320 }
1321
1322 if (!isset($this->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
1323 $this->global->MAIL_SMTP_USE_FROM_FOR_HELO = 2; // Use the domain in $dolibarr_main_url_root (mydomain.com)
1324 }
1325
1326 if (!empty($this->use_javascript_ajax) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) {
1327 $this->global->EMAILING_USE_ADVANCED_SELECTOR = 1;
1328 }
1329
1330 // Security
1331 if (!defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
1332 if (defined('MAIN_ANTIVIRUS_COMMAND')) {
1333 $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
1334 }
1335 if (defined('MAIN_ANTIVIRUS_PARAM')) {
1336 $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
1337 }
1338 }
1339
1340 if (!isset($this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)) {
1341 $this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
1342 }
1343 if (!isset($this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY) && extension_loaded('tidy') && class_exists("tidy")) {
1344 $this->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
1345 }
1346
1347 if (!isset($this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER)) {
1348 // Note value is always forced to 1 in API context to avoid bind SQL injection into API filters.
1349 $this->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 0; // TODO Move this into 1 by default
1350 }
1351
1352 // For backward compatibility
1353 if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
1354 if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
1355 $this->global->LDAP_SYNCHRO_ACTIVE = 1;
1356 } elseif ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
1357 $this->global->LDAP_SYNCHRO_ACTIVE = 2;
1358 }
1359 }
1360 // For backward compatibility
1361 if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') {
1362 $this->global->LDAP_MEMBER_ACTIVE = 2;
1363 }
1364 // For backward compatibility
1365 if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') {
1366 $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2;
1367 }
1368
1369 if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
1370 $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
1371 }
1372
1373 // Simple deprecation management. We do not use DolDeprecationHandlet for $conf.
1374
1375 // product is new use
1376 if (isset($this->product)) {
1377 // For backward compatibility
1378 $this->produit = $this->product;
1379 }
1380 // invoice is new use, facture is old use still initialised
1381 if (isset($this->facture)) {
1382 $this->invoice = $this->facture;
1383 }
1384 // order is new use, commande is old use still initialised
1385 if (isset($this->commande)) {
1386 $this->order = $this->commande;
1387 }
1388 // contract is new use, contrat is old use still initialised
1389 if (isset($this->contrat)) {
1390 $this->contract = $this->contrat;
1391 }
1392 // category is new use, categorie is old use still initialised
1393 if (isset($this->categorie)) {
1394 $this->category = $this->categorie;
1395 }
1396 // project is new use, projet is old use still initialised
1397 if (isset($this->projet) && !isset($this->project)) {
1398 $this->project = $this->projet;
1399 }
1400 // member is new use, adherent is old use still initialised
1401 if (isset($this->adherent) && !isset($this->member)) {
1402 $this->member = $this->adherent;
1403 }
1404
1405 // Object $mc
1406 if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
1407 if (is_object($mc)) {
1408 $mc->setValues($this);
1409 }
1410 }
1411
1412 if (isModEnabled('syslog')) {
1413 // We init log handlers
1414 if (!empty($this->global->SYSLOG_HANDLERS)) {
1415 $handlers = json_decode($this->global->SYSLOG_HANDLERS);
1416 } else {
1417 $handlers = array();
1418 }
1419 foreach ($handlers as $handler) {
1420 $handler_file_found = '';
1421 $dirsyslogs = array('/core/modules/syslog/');
1422 if (!empty($this->modules_parts['syslog']) && is_array($this->modules_parts['syslog'])) {
1423 $dirsyslogs = array_merge($dirsyslogs, $this->modules_parts['syslog']);
1424 }
1425 foreach ($dirsyslogs as $reldir) {
1426 $dir = dol_buildpath($reldir, 0);
1427 $newdir = dol_osencode($dir);
1428 if (is_dir($newdir)) {
1429 $file = $newdir.$handler.'.php';
1430 if (file_exists($file)) {
1431 $handler_file_found = $file;
1432 break;
1433 }
1434 }
1435 }
1436
1437 if (empty($handler_file_found)) {
1438 // If log handler has been removed of is badly setup, we must be able to continue code.
1439 //throw new Exception('Missing log handler file '.$handler.'.php');
1440 continue;
1441 }
1442
1443 require_once $handler_file_found;
1444 $loghandlerinstance = new $handler();
1445 if (!$loghandlerinstance instanceof LogHandler) {
1446 throw new Exception('Log handler does not extend LogHandler');
1447 }
1448
1449 if (empty($this->loghandlers[$handler])) {
1450 $this->loghandlers[$handler] = $loghandlerinstance;
1451 }
1452 }
1453 }
1454 }
1455
1456 // Overwrite database values from conf into the conf.php file.
1457 if (!empty($this->file->mailing_limit_sendbyweb)) {
1458 $this->global->MAILING_LIMIT_SENDBYWEB = $this->file->mailing_limit_sendbyweb;
1459 }
1460 if (empty($this->global->MAILING_LIMIT_SENDBYWEB)) { // Limit by web can't be 0
1461 $this->global->MAILING_LIMIT_SENDBYWEB = 25;
1462 }
1463 if (!empty($this->file->mailing_limit_sendbycli)) {
1464 $this->global->MAILING_LIMIT_SENDBYCLI = $this->file->mailing_limit_sendbycli;
1465 }
1466 if (!empty($this->file->mailing_limit_sendbyday)) {
1467 $this->global->MAILING_LIMIT_SENDBYDAY = $this->file->mailing_limit_sendbyday;
1468 }
1469
1470 return 0;
1471 }
1472}
Class to stock current configuration.
setValues($db)
Load setup values into conf object (read llx_const) Note that this->db->xxx, this->file->xxx have bee...
__construct()
Constructor.
setEntityValues($db, $entity)
Load setup values into conf object (read llx_const) for a specified entity Note that this->db->xxx,...
Parent class for log handlers.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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:162
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.