dolibarr  7.0.0-beta
conf.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
20  */
21 
33 class Conf
34 {
36  var $file;
39  var $db;
41  var $global;
42 
46  public $currency;
48  public $theme; // Contains current theme ("eldy", "auguria", ...)
49  public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
52 
53  public $modules = array(); // List of activated modules
54  public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array(), 'syslog' =>array());
55 
56  var $logbuffer = array();
57 
61  var $loghandlers = array();
62 
64  public $multicompany;
66  public $entity = 1;
68  public $entities = array();
69 
70  public $dol_hide_topmenu; // Set if we force param dol_hide_topmenu into login url
71  public $dol_hide_leftmenu; // Set if we force param dol_hide_leftmenu into login url
72  public $dol_optimize_smallscreen; // Set if we force param dol_optimize_smallscreen into login url or if browser is smartphone
73  public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
74  public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url
75 
76 
80  function __construct()
81  {
82  // Properly declare multi-modules objects.
83  $this->file = new stdClass();
84  $this->db = new stdClass();
85  $this->global = new stdClass();
86  $this->mycompany = new stdClass();
87  $this->admin = new stdClass();
88  $this->user = new stdClass();
89  $this->syslog = new stdClass();
90  $this->browser = new stdClass();
91  $this->medias = new stdClass();
92  $this->multicompany = new stdClass();
93 
95  $this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1
96 
97  // First level object
98  // TODO Remove this part.
99  $this->expedition_bon = new stdClass();
100  $this->livraison_bon = new stdClass();
101  $this->fournisseur = new stdClass();
102  $this->product = new stdClass();
103  $this->service = new stdClass();
104  $this->contrat = new stdClass();
105  $this->actions = new stdClass();
106  $this->commande = new stdClass();
107  $this->propal = new stdClass();
108  $this->facture = new stdClass();
109  $this->contrat = new stdClass();
110  $this->usergroup = new stdClass();
111  $this->adherent = new stdClass();
112  $this->bank = new stdClass();
113  $this->notification = new stdClass();
114  $this->mailing = new stdClass();
115  $this->expensereport = new stdClass();
116  }
117 
118 
126  function setValues($db)
127  {
128  global $conf;
129 
130  dol_syslog(get_class($this)."::setValues");
131 
132  //Define all global constants into $this->global->key=value
133  $sql = "SELECT ".$db->decrypt('name')." as name,";
134  $sql.= " ".$db->decrypt('value')." as value, entity";
135  $sql.= " FROM ".MAIN_DB_PREFIX."const";
136  $sql.= " WHERE entity IN (0,".$this->entity.")";
137  $sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
138 
139  $resql = $db->query($sql);
140  if ($resql)
141  {
142  $i = 0;
143  $numr = $db->num_rows($resql);
144  while ($i < $numr)
145  {
146  $objp = $db->fetch_object($resql);
147  $key=$objp->name;
148  $value=$objp->value;
149  if ($key)
150  {
151  //if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
152  $this->global->$key=$value;
153 
154  if ($value && preg_match('/^MAIN_MODULE_/',$key))
155  {
156  // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
157  if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i',$key))
158  {
159  $partname = 'tabs';
160  $params=explode(':',$value,2);
161  if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
162  $this->modules_parts[$partname][$params[0]][]=$value; // $value may be a string or an array
163  }
164  // If this is constant for all generic part activated by a module. It initializes
165  // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
166  // modules_parts['models'], modules_parts['theme']
167  // modules_parts['sms'],
168  // modules_parts['css'], ...
169  elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i',$key,$reg))
170  {
171  $modulename = strtolower($reg[1]);
172  $partname = strtolower($reg[2]);
173  if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
174  $arrValue = json_decode($value,true);
175  if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
176  else if (in_array($partname,array('login','menus','substitutions','triggers','tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/';
177  else if (in_array($partname,array('models','theme'))) $value = '/'.$modulename.'/';
178  else if (in_array($partname,array('sms'))) $value = $modulename;
179  else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
180  $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
181  }
182  // If this is a module constant (must be at end)
183  elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i',$key,$reg))
184  {
185  $modulename=strtolower($reg[1]);
186  if ($modulename == 'propale') $modulename='propal';
187  if ($modulename == 'supplierproposal') $modulename='supplier_proposal';
188  if (! isset($this->$modulename) || ! is_object($this->$modulename)) $this->$modulename=new stdClass();
189  $this->$modulename->enabled=true;
190  $this->modules[]=$modulename; // Add this module in list of enabled modules
191  }
192  }
193  }
194  $i++;
195  }
196 
197  $db->free($resql);
198  }
199 
200  // Include other local consts.php files and fetch their values to the corresponding database constants.
201  if (! empty($this->global->LOCAL_CONSTS_FILES)) {
202  $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
203  foreach ($filesList as $file) {
204  $file=dol_sanitizeFileName($file);
205  include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php";
206  foreach ($file2bddconsts as $key=>$value) {
207  $this->global->$key=$value;
208  }
209  }
210  }
211 
212  //var_dump($this->modules);
213  //var_dump($this->modules_parts['theme']);
214 
215  // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
216  // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
217  //$this->global->MAIN_SERVER_TZ='Europe/Paris';
218  if (! empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto')
219  {
220  try {
221  date_default_timezone_set($this->global->MAIN_SERVER_TZ);
222  }
223  catch(Exception $e)
224  {
225  dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
226  }
227  }
228 
229  // Object $mc
230  if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
231  {
232  global $mc;
233  $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
234  if ($ret) $mc = new ActionsMulticompany($db);
235  }
236 
237  // Clean some variables
238  if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_menu.php";
239  if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_menu.php";
240  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
241  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
242  // Clean var use vat for company
243  if (! isset($this->global->FACTURE_TVAOPTION)) $this->global->FACTURE_TVAOPTION=1;
244  else if (! empty($this->global->FACTURE_TVAOPTION) && ! is_numeric($this->global->FACTURE_TVAOPTION))
245  {
246  // Old value of option, we clean to use new value (0 or 1)
247  if ($this->global->FACTURE_TVAOPTION != "franchise") $this->global->FACTURE_TVAOPTION=1;
248  else $this->global->FACTURE_TVAOPTION=0;
249  }
250 
251  // Variable globales LDAP
252  if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME='';
253  if (! isset($this->global->LDAP_KEY_USERS)) $this->global->LDAP_KEY_USERS=$this->global->LDAP_FIELD_FULLNAME;
254  if (! isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME;
255  if (! isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME;
256  if (! isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME;
257  if (! isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES=$this->global->LDAP_FIELD_FULLNAME;
258 
259  // Load translation object with current language
260  if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
261 
262  //if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
263  //if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1;
264 
265  $rootfordata = DOL_DATA_ROOT;
266  $rootforuser = DOL_DATA_ROOT;
267  // If multicompany module is enabled, we redefine the root of data
268  if (! empty($this->multicompany->enabled) && ! empty($this->entity) && $this->entity > 1)
269  {
270  $rootfordata.='/'.$this->entity;
271  }
272 
273  // Define default dir_output and dir_temp for directories of modules
274  foreach($this->modules as $module)
275  {
276  //var_dump($module);
277  // For multicompany sharings
278  $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
279  $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
280  // For backward compatibility
281  $this->$module->dir_output = $rootfordata."/".$module;
282  $this->$module->dir_temp = $rootfordata."/".$module."/temp";
283  }
284 
285  // External modules storage
286  if (! empty($this->modules_parts['dir']))
287  {
288  foreach($this->modules_parts['dir'] as $module => $dirs)
289  {
290  if (! empty($this->$module->enabled))
291  {
292  foreach($dirs as $type => $name)
293  {
294  $subdir=($type=='temp'?'/temp':'');
295  // For multicompany sharings
296  $varname = 'multidir_'.$type;
297  $this->$module->$varname = array($this->entity => $rootfordata."/".$name.$subdir);
298  // For backward compatibility
299  $varname = 'dir_'.$type;
300  $this->$module->$varname = $rootfordata."/".$name.$subdir;
301  }
302  }
303  }
304  }
305 
306  // For mycompany storage
307  $this->mycompany->dir_output=$rootfordata."/mycompany";
308  $this->mycompany->dir_temp=$rootfordata."/mycompany/temp";
309 
310  // For admin storage
311  $this->admin->dir_output=$rootfordata.'/admin';
312  $this->admin->dir_temp=$rootfordata.'/admin/temp';
313 
314  // For user storage
315  $this->user->multidir_output = array($this->entity => $rootfordata."/users");
316  $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
317  // For backward compatibility
318  $this->user->dir_output=$rootforuser."/users";
319  $this->user->dir_temp=$rootforuser."/users/temp";
320 
321  // UserGroup
322  $this->usergroup->dir_output=$rootforuser."/usergroups";
323  $this->usergroup->dir_temp=$rootforuser."/usergroups/temp";
324 
325  // For propal storage
326  $this->propal->dir_output=$rootfordata."/propale";
327  $this->propal->dir_temp=$rootfordata."/propale/temp";
328 
329  // For medias storage
330  $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
331  $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp");
332 
333  // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
334 
335  // Sous module bons d'expedition
336  $this->expedition_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_EXPEDITION)?$this->global->MAIN_SUBMODULE_EXPEDITION:0);
337  // Sous module bons de livraison
338  $this->livraison_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_LIVRAISON)?$this->global->MAIN_SUBMODULE_LIVRAISON:0);
339 
340  // Module fournisseur
341  if (! empty($this->fournisseur))
342  {
343  $this->fournisseur->commande=new stdClass();
344  $this->fournisseur->commande->dir_output=$rootfordata."/fournisseur/commande";
345  $this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp";
346  $this->fournisseur->facture=new stdClass();
347  $this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
348  $this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
349  $this->fournisseur->payment=new stdClass();
350  $this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment";
351  $this->fournisseur->payment->dir_temp =$rootfordata."/fournisseur/payment/temp";
352 
353  // To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice
354  if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties
355  {
356  $this->supplier_order=new stdClass();
357  $this->supplier_order->enabled=1;
358  $this->supplier_order->dir_output=$rootfordata."/fournisseur/commande";
359  $this->supplier_order->dir_temp=$rootfordata."/fournisseur/commande/temp";
360  $this->supplier_invoice=new stdClass();
361  $this->supplier_invoice->enabled=1;
362  $this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture";
363  $this->supplier_invoice->dir_temp=$rootfordata."/fournisseur/facture/temp";
364  }
365  }
366 
367  // Module product/service
368  $this->product->multidir_output=array($this->entity => $rootfordata."/produit");
369  $this->product->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
370  $this->service->multidir_output=array($this->entity => $rootfordata."/produit");
371  $this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
372  // For backward compatibility
373  $this->product->dir_output=$rootfordata."/produit";
374  $this->product->dir_temp =$rootfordata."/produit/temp";
375  $this->service->dir_output=$rootfordata."/produit";
376  $this->service->dir_temp =$rootfordata."/produit/temp";
377 
378  // Module contrat
379  $this->contrat->dir_output=$rootfordata."/contracts";
380  $this->contrat->dir_temp =$rootfordata."/contracts/temp";
381  // Module bank
382  $this->bank->dir_output=$rootfordata."/bank";
383  $this->bank->dir_temp =$rootfordata."/bank/temp";
384 
385 
386  // Set some default values
387 
388  $this->global->MAIN_ACTIVATE_HTML5=1;
389  $this->global->MAIN_MAIL_USE_MULTI_PART=1;
390 
391  // societe
392  if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard";
393  if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum";
394 
395  if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint';
396 
397  // Security
398  if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator
399  if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask
400 
401  // conf->use_javascript_ajax
402  $this->use_javascript_ajax=1;
403  if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax=! $this->global->MAIN_DISABLE_JAVASCRIPT;
404  // If no javascript_ajax, Ajax features are disabled.
405  if (empty($this->use_javascript_ajax))
406  {
407  unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
408  unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
409  unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
410  unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
411  }
412 
413  if (! empty($this->productbatch->enabled))
414  {
415  $this->global->STOCK_CALCULATE_ON_BILL=0;
416  $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0;
417  $this->global->STOCK_CALCULATE_ON_SHIPMENT=1;
418  $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0;
419  $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0;
420  $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0;
421  $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1;
422  }
423 
424  // conf->currency
425  if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
426  $this->currency=$this->global->MAIN_MONNAIE;
427 
428  if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
429 
430  // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
431  if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
432 
433  // By default, suppliers objects can be linked to all projects
434  $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
435 
436  // MAIN_HTML_TITLE
437  if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly';
438 
439  // conf->liste_limit = constante de taille maximale des listes
440  if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25;
441  $this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT;
442 
443  // conf->product->limit_size = constante de taille maximale des select de produit
444  if (! isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE=1000;
445  $this->product->limit_size=$this->global->PRODUIT_LIMIT_SIZE;
446 
447  // conf->theme et $this->css
448  if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME="eldy";
449  if (! empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME=$this->global->MAIN_FORCETHEME;
450  $this->theme=$this->global->MAIN_THEME;
451  $this->css = "/theme/".$this->theme."/style.css.php";
452 
453  // conf->email_from = email pour envoi par dolibarr des mails automatiques
454  $this->email_from = "robot@example.com";
455  if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
456 
457  // conf->notification->email_from = email pour envoi par Dolibarr des notifications
458  $this->notification->email_from=$this->email_from;
459  if (! empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from=$this->global->NOTIFICATION_EMAIL_FROM;
460 
461  // conf->mailing->email_from = email pour envoi par Dolibarr des mailings
462  $this->mailing->email_from=$this->email_from;
463  if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM;
464  if (! isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1;
465 
466  // Format for date (used by default when not found or not searched in lang)
467  $this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
468  $this->format_date_short_java="dd/MM/yyyy"; // Format of day with Java tags
469  $this->format_hour_short="%H:%M";
470  $this->format_hour_short_duration="%H:%M";
471  $this->format_date_text_short="%d %b %Y";
472  $this->format_date_text="%d %B %Y";
473  $this->format_date_hour_short="%d/%m/%Y %H:%M";
474  $this->format_date_hour_sec_short="%d/%m/%Y %H:%M:%S";
475  $this->format_date_hour_text_short="%d %b %Y %H:%M";
476  $this->format_date_hour_text="%d %B %Y %H:%M";
477 
478  // Duration of workday
479  if (! isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY=86400;
480 
481  // Limites decimales si non definie (peuvent etre egale a 0)
482  if (! isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT=5;
483  if (! isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2;
484  if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8;
485 
486  // Default pdf option
487  if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines
488  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
489 
490  // Set default value to MAIN_SHOW_LOGO
491  if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1;
492 
493  // Default max file size for upload
494  $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024);
495 
496  // By default, we propagate contacts
497  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)
498 
499  // By default, we do not use the zip town table but the table of third parties
500  if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0;
501 
502  // By default, we open card if one found
503  if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1;
504 
505  // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
506  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.
507 
508  // Enable select2
509  if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2';
510 
511  // Timeouts
512  if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10;
513  if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT=30;
514 
515  // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
516  if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT='invoice';
517  if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT='invoice';
518  if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE='payment';
519  if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE='payment';
520 
521  // Delay before warnings
522  // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
523  if (isset($this->agenda)) {
524  $this->adherent->subscription = new stdClass();
525  $this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60;
526  }
527  if (isset($this->agenda)) $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60;
528  if (isset($this->projet))
529  {
530  $this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60;
531  $this->projet->task = new StdClass();
532  $this->projet->task->warning_delay=(isset($this->global->MAIN_DELAY_TASKS_TODO)?$this->global->MAIN_DELAY_TASKS_TODO:7)*24*60*60;
533  }
534 
535  if (isset($this->commande)) {
536  $this->commande->client = new stdClass();
537  $this->commande->fournisseur = new stdClass();
538  $this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60;
539  $this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60;
540  }
541  if (isset($this->propal)) {
542  $this->propal->cloture = new stdClass();
543  $this->propal->facturation = new stdClass();
544  $this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60;
545  $this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60;
546  }
547  if (isset($this->facture)) {
548  $this->facture->client = new stdClass();
549  $this->facture->fournisseur = new stdClass();
550  $this->facture->client->warning_delay=(isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED)?$this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED:0)*24*60*60;
551  $this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60;
552  }
553  if (isset($this->contrat)) {
554  $this->contrat->services = new stdClass();
555  $this->contrat->services->inactifs = new stdClass();
556  $this->contrat->services->expires = new stdClass();
557  $this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60;
558  $this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60;
559  }
560  if (isset($this->commande)) {
561  $this->bank->rappro = new stdClass();
562  $this->bank->cheque = new stdClass();
563  $this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60;
564  $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60;
565  }
566  if (isset($this->expensereport)) {
567  $this->expensereport->approve = new stdClass();
568  $this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60;
569  $this->expensereport->payment = new stdClass();
570  $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60;
571  }
572 
573  if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
574  {
575  $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
576  }
577 
578  // For modules that want to disable top or left menu
579  if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU;
580  if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU;
581 
582  if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT=3;
583 
584  if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0;
585 
586  // Save inconsistent option
587  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
588  {
589  $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
590  }
591 
592  $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com';
593  $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567';
594 
595  // For backward compatibility
596  if (isset($this->product)) $this->produit=$this->product;
597  if (isset($this->facture)) $this->invoice=$this->facture;
598  if (isset($this->commande)) $this->order=$this->commande;
599  if (isset($this->contrat)) $this->contract=$this->contrat;
600  if (isset($this->categorie)) $this->category=$this->categorie;
601 
602  // Object $mc
603  if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
604  {
605  if (is_object($mc)) $mc->setValues($this);
606  }
607 
608  // We init log handlers
609  if (! empty($this->global->SYSLOG_HANDLERS)) {
610  $handlers = json_decode($this->global->SYSLOG_HANDLERS);
611  } else {
612  $handlers = array();
613  }
614  foreach ($handlers as $handler) {
615  $handler_files = array();
616  $dirsyslogs = array_merge(array('/core/modules/syslog/'), $this->modules_parts['syslog']);
617  foreach ($dirsyslogs as $reldir) {
618  $dir = dol_buildpath($reldir, 0);
619  $newdir = dol_osencode($dir);
620  if (is_dir($newdir)) {
621  $file = $newdir . $handler . '.php';
622  if (file_exists($file)) {
623  $handler_files[] = $file;
624  }
625  }
626  }
627 
628  if (empty($handler_files)) {
629  throw new Exception('Missing log handler file ' . $handler . '.php');
630  }
631 
632  require_once $handler_files[0];
633  $loghandlerinstance = new $handler();
634  if (!$loghandlerinstance instanceof LogHandlerInterface) {
635  throw new Exception('Log handler does not extend LogHandlerInterface');
636  }
637 
638  if (empty($this->loghandlers[$handler])) {
639  $this->loghandlers[$handler] = $loghandlerinstance;
640  }
641  }
642 
643  }
644 }
645 
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:68
$theme
Used to store current css (from theme)
Definition: conf.class.php:48
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
$global
To store properties found into database.
Definition: conf.class.php:41
$db
Object with database handler.
Definition: conf.class.php:39
$multicompany
To store properties of multi-company.
Definition: conf.class.php:64
$currency
Used to store current currency.
Definition: conf.class.php:46
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
LogHandlerInterface.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
$file
To store properties found in conf file.
Definition: conf.class.php:37
$use_javascript_ajax
To store if javascript/ajax is enabked.
Definition: conf.class.php:44
$conf db user
Definition: repair.php:105
setValues($db)
Load setup values into conf object (read llx_const) Note that this->db->xxx, this->file->xxx and this...
Definition: conf.class.php:126
__construct()
Constructor.
Definition: conf.class.php:80
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Return a prefix to use for this Dolibarr instance, for session/cookie names or email id...
$entity
Used to store running instance for multi-company (default 1)
Definition: conf.class.php:66
$standard_menu
Used to store current menu handler.
Definition: conf.class.php:51