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