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