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