dolibarr  13.0.2
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 {
36  public $file;
38 
42  public $db;
43 
45  public $global;
47  public $browser;
48 
54  public $currency;
55 
57  public $theme; // Contains current theme ("eldy", "auguria", ...)
58  public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
59 
62  // List of activated modules
63  public $modules = array();
64  public $modules_parts = array(
65  'css' => array(),
66  'js' => array(),
67  'tabs' => array(),
68  'triggers' => array(),
69  'login' => array(),
70  'substitutions' => array(),
71  'menus' => array(),
72  'theme' => array(),
73  'sms' => array(),
74  'tpl' => array(),
75  'barcode' => array(),
76  'models' => array(),
77  'societe' => array(),
78  'hooks' => array(),
79  'dir' => array(),
80  'syslog' => array(),
81  );
82 
83  public $logbuffer = array();
84 
88  public $loghandlers = array();
89 
91  public $multicompany;
93  public $entity = 1;
95  public $entities = array();
96 
97  public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url
98  public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url
99  public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone
100  public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
101  public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url
102 
103  public $liste_limit;
104 
105  public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user.
106 
107 
111  public function __construct()
112  {
113  // Properly declare multi-modules objects.
114  $this->file = new stdClass();
115  $this->db = new stdClass();
116  $this->global = new stdClass();
117  $this->mycompany = new stdClass();
118  $this->admin = new stdClass();
119  $this->user = new stdClass();
120  $this->syslog = new stdClass();
121  $this->browser = new stdClass();
122  $this->medias = new stdClass();
123  $this->multicompany = new stdClass();
124 
126  $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1
127 
128  // First level object
129  // TODO Remove this part.
130  $this->expedition_bon = new stdClass();
131  $this->delivery_note = new stdClass();
132  $this->fournisseur = new stdClass();
133  $this->product = new stdClass();
134  $this->service = new stdClass();
135  $this->contrat = new stdClass();
136  $this->actions = new stdClass();
137  $this->agenda = new stdClass();
138  $this->commande = new stdClass();
139  $this->propal = new stdClass();
140  $this->facture = new stdClass();
141  $this->contrat = new stdClass();
142  $this->usergroup = new stdClass();
143  $this->adherent = new stdClass();
144  $this->bank = new stdClass();
145  $this->notification = new stdClass();
146  $this->mailing = new stdClass();
147  $this->expensereport = new stdClass();
148  $this->productbatch = new stdClass();
149  }
150 
151 
159  public function setValues($db)
160  {
161  dol_syslog(get_class($this)."::setValues");
162 
163  //Define all global constants into $this->global->key=value
164  $sql = "SELECT ".$db->decrypt('name')." as name,";
165  $sql .= " ".$db->decrypt('value')." as value, entity";
166  $sql .= " FROM ".MAIN_DB_PREFIX."const";
167  $sql .= " WHERE entity IN (0,".$this->entity.")";
168  $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
169 
170  $resql = $db->query($sql);
171  if ($resql)
172  {
173  $i = 0;
174  $numr = $db->num_rows($resql);
175  while ($i < $numr)
176  {
177  $objp = $db->fetch_object($resql);
178  $key = $objp->name;
179  $value = $objp->value;
180  if ($key)
181  {
182  // Allow constants values to be overridden by environment variables
183  if (isset($_SERVER['DOLIBARR_'.$key])) {
184  $value = $_SERVER['DOLIBARR_'.$key];
185  } elseif (isset($_ENV['DOLIBARR_'.$key])) {
186  $value = $_ENV['DOLIBARR_'.$key];
187  }
188 
189  //if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
190  $this->global->$key = $value;
191 
192  if ($value && strpos($key, 'MAIN_MODULE_') === 0)
193  {
194  $reg = array();
195  // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
196  if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key))
197  {
198  $partname = 'tabs';
199  $params = explode(':', $value, 2);
200  if (!is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
201  $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
202  }
203  // If this is constant for all generic part activated by a module. It initializes
204  // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
205  // modules_parts['models'], modules_parts['theme']
206  // modules_parts['sms'],
207  // modules_parts['css'], ...
208  elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg))
209  {
210  $modulename = strtolower($reg[1]);
211  $partname = strtolower($reg[2]);
212  if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
213  $arrValue = json_decode($value, true);
214  if (is_array($arrValue) && !empty($arrValue)) $value = $arrValue;
215  elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/';
216  elseif (in_array($partname, array('models', 'theme'))) $value = '/'.$modulename.'/';
217  elseif (in_array($partname, array('sms'))) $value = '/'.$modulename.'/';
218  elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
219  $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
220  }
221  // If this is a module constant (must be at end)
222  elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg))
223  {
224  $modulename = strtolower($reg[1]);
225  if ($modulename == 'propale') $modulename = 'propal';
226  if ($modulename == 'supplierproposal') $modulename = 'supplier_proposal';
227  if (!isset($this->$modulename) || !is_object($this->$modulename)) $this->$modulename = new stdClass();
228  $this->$modulename->enabled = true;
229  $this->modules[] = $modulename; // Add this module in list of enabled modules
230  }
231  }
232  }
233  $i++;
234  }
235 
236  $db->free($resql);
237  }
238 
239  // Include other local consts.php files and fetch their values to the corresponding database constants.
240  if (!empty($this->global->LOCAL_CONSTS_FILES)) {
241  $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
242  foreach ($filesList as $file) {
243  $file = dol_sanitizeFileName($file);
244  dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
245  }
246  }
247 
248  //var_dump($this->modules);
249  //var_dump($this->modules_parts['theme']);
250 
251  // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
252  // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
253  //$this->global->MAIN_SERVER_TZ='Europe/Paris';
254  if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto')
255  {
256  try {
257  date_default_timezone_set($this->global->MAIN_SERVER_TZ);
258  } catch (Exception $e)
259  {
260  dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
261  }
262  }
263 
264  // Object $mc
265  if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
266  global $mc;
267  $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
268  if ($ret) {
269  $mc = new ActionsMulticompany($db);
270  $this->mc = $mc;
271  }
272  }
273 
274  // Clean some variables
275  if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
276  if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
277  if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
278  if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
279  if (!isset($this->global->FACTURE_TVAOPTION)) $this->global->FACTURE_TVAOPTION = 1;
280 
281  // Variable globales LDAP
282  if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME = '';
283  if (!isset($this->global->LDAP_KEY_USERS)) $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
284  if (!isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
285  if (!isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
286  if (!isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
287  if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
288 
289  // Load translation object with current language
290  if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT = "en_US";
291 
292  $rootfordata = DOL_DATA_ROOT;
293  $rootforuser = DOL_DATA_ROOT;
294  // If multicompany module is enabled, we redefine the root of data
295  if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1)
296  {
297  $rootfordata .= '/'.$this->entity;
298  }
299  // Set standard temporary folder name or global override
300  $rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
301 
302  // Define default dir_output and dir_temp for directories of modules
303  foreach ($this->modules as $module)
304  {
305  //var_dump($module);
306  // For multicompany sharings
307  $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
308  $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp");
309  // For backward compatibility
310  $this->$module->dir_output = $rootfordata."/".$module;
311  $this->$module->dir_temp = $rootfortemp."/".$module."/temp";
312  }
313 
314  // External modules storage
315  if (!empty($this->modules_parts['dir']))
316  {
317  foreach ($this->modules_parts['dir'] as $module => $dirs)
318  {
319  if (!empty($this->$module->enabled))
320  {
321  foreach ($dirs as $type => $name) // $type is 'output' or 'temp'
322  {
323  $multidirname = 'multidir_'.$type;
324  $dirname = 'dir_'.$type;
325 
326  if ($type != 'temp')
327  {
328  // For multicompany sharings
329  $this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
330 
331  // For backward compatibility
332  $this->$module->$dirname = $rootfordata."/".$name;
333  } else {
334  // For multicompany sharings
335  $this->$module->$multidirname = array($this->entity => $rootfortemp."/".$name."/temp");
336 
337  // For backward compatibility
338  $this->$module->$dirname = $rootfortemp."/".$name."/temp";
339  }
340  }
341  }
342  }
343  }
344 
345  // For mycompany storage
346  $this->mycompany->dir_output = $rootfordata."/mycompany";
347  $this->mycompany->dir_temp = $rootfortemp."/mycompany/temp";
348 
349  // For admin storage
350  $this->admin->dir_output = $rootfordata.'/admin';
351  $this->admin->dir_temp = $rootfortemp.'/admin/temp';
352 
353  // For user storage
354  $this->user->multidir_output = array($this->entity => $rootfordata."/users");
355  $this->user->multidir_temp = array($this->entity => $rootfortemp."/users/temp");
356  // For backward compatibility
357  $this->user->dir_output = $rootforuser."/users";
358  $this->user->dir_temp = $rootfortemp."/users/temp";
359 
360  // For usergroup storage
361  $this->usergroup->dir_output = $rootforuser."/usergroups";
362  $this->usergroup->dir_temp = $rootfortemp."/usergroups/temp";
363 
364  // For proposal storage
365  $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
366  $this->propal->multidir_temp = array($this->entity => $rootfortemp."/propale/temp");
367  // For backward compatibility
368  $this->propal->dir_output = $rootfordata."/propale";
369  $this->propal->dir_temp = $rootfortemp."/propale/temp";
370 
371  // For medias storage
372  $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
373  $this->medias->multidir_temp = array($this->entity => $rootfortemp."/medias/temp");
374 
375  // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
376 
377  // Sous module bons d'expedition
378  $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
379  // Sub module delivery note Sous module bons de livraison
380  $this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0);
381 
382  // Module fournisseur
383  if (!empty($this->fournisseur))
384  {
385  $this->fournisseur->commande = new stdClass();
386  $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
387  $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
388  $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
389  $this->fournisseur->commande->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
390 
391  $this->fournisseur->facture = new stdClass();
392  $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
393  $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
394  $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
395  $this->fournisseur->facture->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
396 
397  $this->supplierproposal = new stdClass();
398  $this->supplierproposal->multidir_output = array($this->entity => $rootfordata."/supplier_proposal");
399  $this->supplierproposal->multidir_temp = array($this->entity => $rootfortemp."/supplier_proposal/temp");
400  $this->supplierproposal->dir_output = $rootfordata."/supplier_proposal"; // For backward compatibility
401  $this->supplierproposal->dir_temp = $rootfortemp."/supplier_proposal/temp"; // For backward compatibility
402 
403  $this->fournisseur->payment = new stdClass();
404  $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
405  $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/payment/temp");
406  $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
407  $this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
408 
409  // To prepare split of module fournisseur into module 'fournisseur' + supplier_order + supplier_invoice
410  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 artificialy the module properties
411  {
412  $this->supplier_order = new stdClass();
413  $this->supplier_order->enabled = 1;
414  $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
415  $this->supplier_order->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
416  $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
417  $this->supplier_order->dir_temp = $rootfortemp."/fournisseur/commande/temp"; // For backward compatibility
418 
419  $this->supplier_invoice = new stdClass();
420  $this->supplier_invoice->enabled = 1;
421  $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
422  $this->supplier_invoice->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/facture/temp");
423  $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
424  $this->supplier_invoice->dir_temp = $rootfortemp."/fournisseur/facture/temp"; // For backward compatibility
425  }
426  }
427 
428  // Module product/service
429  $this->product->multidir_output = array($this->entity => $rootfordata."/produit");
430  $this->product->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
431  $this->service->multidir_output = array($this->entity => $rootfordata."/produit");
432  $this->service->multidir_temp = array($this->entity => $rootfortemp."/produit/temp");
433  // For backward compatibility
434  $this->product->dir_output = $rootfordata."/produit";
435  $this->product->dir_temp = $rootfortemp."/produit/temp";
436  $this->service->dir_output = $rootfordata."/produit";
437  $this->service->dir_temp = $rootfortemp."/produit/temp";
438 
439  // Module productbatch
440  $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
441  $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");
442 
443  // Module contrat
444  $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
445  $this->contrat->multidir_temp = array($this->entity => $rootfortemp."/contract/temp");
446  // For backward compatibility
447  $this->contrat->dir_output = $rootfordata."/contract";
448  $this->contrat->dir_temp = $rootfortemp."/contract/temp";
449 
450  // Module bank
451  $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
452  $this->bank->multidir_temp = array($this->entity => $rootfortemp."/bank/temp");
453  // For backward compatibility
454  $this->bank->dir_output = $rootfordata."/bank";
455  $this->bank->dir_temp = $rootfortemp."/bank/temp";
456 
457  // Set some default values
458  //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
459  $this->global->MAIN_MAIL_USE_MULTI_PART = 1;
460 
461  // societe
462  if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
463  if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
464 
465  if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
466  if (empty($this->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple';
467 
468  // Security
469  if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
470  if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask
471 
472  // conf->use_javascript_ajax
473  $this->use_javascript_ajax = 1;
474  if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
475  // If no javascript_ajax, Ajax features are disabled.
476  if (empty($this->use_javascript_ajax))
477  {
478  unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
479  unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
480  unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
481  unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
482  }
483 
484  if (!empty($this->productbatch->enabled))
485  {
486  $this->global->STOCK_CALCULATE_ON_BILL = 0;
487  $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
488  $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
489  $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
490  $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
491  $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
492  if (empty($this->reception->enabled)) {
493  $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
494  }
495  else {
496  $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
497  $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
498  }
499  }
500 
501  // conf->currency
502  if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE = 'EUR';
503  $this->currency = $this->global->MAIN_MONNAIE;
504 
505  if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
506 
507  // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
508  if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
509 
510  // By default, suppliers objects can be linked to all projects
511  if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
512 
513  // By default we enable feature to bill time spent
514  if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
515 
516  // MAIN_HTML_TITLE
517  if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
518 
519  // conf->liste_limit = constante de taille maximale des listes
520  if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
521  $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
522 
523  // conf->product->limit_size = constante de taille maximale des select de produit
524  if (!isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE = 1000;
525  $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
526 
527  // conf->theme et $this->css
528  if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy";
529  if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
530  $this->theme = $this->global->MAIN_THEME;
531  $this->css = "/theme/".$this->theme."/style.css.php";
532 
533  // conf->email_from = email pour envoi par dolibarr des mails automatiques
534  $this->email_from = "robot@example.com";
535  if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
536 
537  // conf->notification->email_from = email pour envoi par Dolibarr des notifications
538  $this->notification->email_from = $this->email_from;
539  if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
540 
541  // conf->mailing->email_from = email pour envoi par Dolibarr des mailings
542  $this->mailing->email_from = $this->email_from;
543  if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
544  if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
545 
546  if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
547 
548  // Format for date (used by default when not found or not searched in lang)
549  $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
550  $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
551  $this->format_hour_short = "%H:%M";
552  $this->format_hour_short_duration = "%H:%M";
553  $this->format_date_text_short = "%d %b %Y";
554  $this->format_date_text = "%d %B %Y";
555  $this->format_date_hour_short = "%d/%m/%Y %H:%M";
556  $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
557  $this->format_date_hour_text_short = "%d %b %Y %H:%M";
558  $this->format_date_hour_text = "%d %B %Y %H:%M";
559 
560  // Duration of workday
561  if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
562 
563  // Limites decimales si non definie (peuvent etre egale a 0)
564  if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
565  if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT = 2;
566  if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
567 
568  // Default pdf option
569  if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
570  if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
571 
572  // Default max file size for upload
573  $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
574 
575  // By default, we propagate contacts
576  if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
577 
578  // By default, we do not use the zip town table but the table of third parties
579  if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
580 
581  // By default, we open card if one found
582  if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
583 
584  // By default, we show state code in combo list
585  if (!isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE = 1;
586 
587  // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
588  if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
589 
590  // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
591  if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
592  if (!empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
593  {
594  foreach ($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
595  }
596 
597  // Enable select2
598  if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
599 
600  // Timeouts
601  if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
602  if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
603 
604  // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
605  if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
606  if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
607  if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment';
608  if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment';
609 
610  // Delay before warnings
611  // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
612  if (isset($this->agenda)) {
613  $this->adherent->subscription = new stdClass();
614  $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400;
615  }
616  if (isset($this->agenda)) {
617  $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
618  }
619  if (isset($this->projet))
620  {
621  $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400;
622  $this->projet->task = new StdClass();
623  $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400;
624  }
625 
626  if (isset($this->commande)) {
627  $this->commande->client = new stdClass();
628  $this->commande->fournisseur = new stdClass();
629  $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400;
630  $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400;
631  }
632  if (isset($this->propal)) {
633  $this->propal->cloture = new stdClass();
634  $this->propal->facturation = new stdClass();
635  $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400;
636  $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400;
637  }
638  if (isset($this->facture)) {
639  $this->facture->client = new stdClass();
640  $this->facture->fournisseur = new stdClass();
641  $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400;
642  $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400;
643  }
644  if (isset($this->contrat)) {
645  $this->contrat->services = new stdClass();
646  $this->contrat->services->inactifs = new stdClass();
647  $this->contrat->services->expires = new stdClass();
648  $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
649  $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
650  }
651  if (isset($this->commande)) {
652  $this->bank->rappro = new stdClass();
653  $this->bank->cheque = new stdClass();
654  $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
655  $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
656  }
657  if (isset($this->expensereport)) {
658  $this->expensereport->approve = new stdClass();
659  $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400;
660  $this->expensereport->payment = new stdClass();
661  $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400;
662  }
663  if (isset($this->holiday)) {
664  $this->holiday->approve = new stdClass();
665  $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
666  }
667 
668  if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
669  {
670  $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
671  }
672 
673  // For modules that want to disable top or left menu
674  if (!empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
675  if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
676 
677  if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
678 
679  if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
680 
681  // Save inconsistent option
682  if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
683  {
684  $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
685  }
686 
687  if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
688 
689  if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
690  if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
691 
692  // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
693  if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
694 
695  if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
696  if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
697 
698  if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
699 
700  // For backward compatibility
701  if (isset($this->product)) $this->produit = $this->product;
702  if (isset($this->facture)) $this->invoice = $this->facture;
703  if (isset($this->commande)) $this->order = $this->commande;
704  if (isset($this->contrat)) $this->contract = $this->contrat;
705  if (isset($this->categorie)) $this->category = $this->categorie;
706  if (isset($this->project)) $this->project = $this->projet;
707 
708  // Object $mc
709  if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled))
710  {
711  if (is_object($mc)) $mc->setValues($this);
712  }
713 
714  if (!empty($this->syslog->enabled)) {
715  // We init log handlers
716  if (!empty($this->global->SYSLOG_HANDLERS)) {
717  $handlers = json_decode($this->global->SYSLOG_HANDLERS);
718  } else {
719  $handlers = array();
720  }
721  foreach ($handlers as $handler) {
722  $handler_file_found = '';
723  $dirsyslogs = array_merge(array('/core/modules/syslog/'), $this->modules_parts['syslog']);
724  foreach ($dirsyslogs as $reldir) {
725  $dir = dol_buildpath($reldir, 0);
726  $newdir = dol_osencode($dir);
727  if (is_dir($newdir)) {
728  $file = $newdir.$handler.'.php';
729  if (file_exists($file)) {
730  $handler_file_found = $file;
731  break;
732  }
733  }
734  }
735 
736  if (empty($handler_file_found)) {
737  throw new Exception('Missing log handler file '.$handler.'.php');
738  }
739 
740  require_once $handler_file_found;
741  $loghandlerinstance = new $handler();
742  if (!$loghandlerinstance instanceof LogHandlerInterface) {
743  throw new Exception('Log handler does not extend LogHandlerInterface');
744  }
745 
746  if (empty($this->loghandlers[$handler])) {
747  $this->loghandlers[$handler] = $loghandlerinstance;
748  }
749  }
750  }
751 
752  return 0;
753  }
754 }
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
Class to stock current configuration.
Definition: conf.class.php:33
$entities
Used to store list of entities to use for each element.
Definition: conf.class.php:95
$theme
Used to store current css (from theme)
Definition: conf.class.php:57
$global
To store properties found into database.
Definition: conf.class.php:45
$multicompany
To store properties of multi-company.
Definition: conf.class.php:91
$currency
Used to store current currency (ISO code like &#39;USD&#39;, &#39;EUR&#39;, ...)
Definition: conf.class.php:54
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
LogHandlerInterface.
$conf db
API class for accounts.
Definition: inc.php:54
$disable_compute
To store if javascript/ajax is enabked.
Definition: conf.class.php:52
$file
To store properties found in conf file.
Definition: conf.class.php:37
$conf db user
Definition: repair.php:109
$use_javascript_ajax
To store if javascript/ajax is enabked.
Definition: conf.class.php:50
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
$browser
To store browser info.
Definition: conf.class.php:47
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
setValues($db)
Load setup values into conf object (read llx_const) Note that this-&gt;db-&gt;xxx, this-&gt;file-&gt;xxx and this...
Definition: conf.class.php:159
__construct()
Constructor.
Definition: conf.class.php:111
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
$entity
Used to store running instance for multi-company (default 1)
Definition: conf.class.php:93
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
$standard_menu
Used to store current menu handler.
Definition: conf.class.php:61