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