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