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