PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/core/class/conf.class.php

https://bitbucket.org/speedealing/speedealing
PHP | 499 lines | 303 code | 78 blank | 118 comment | 66 complexity | 53b689e0c625e110e78b64ac897a9ddb MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 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. /**
  22. * \file htdocs/core/class/conf.class.php
  23. * \ingroup core
  24. * \brief File of class to manage storage of current setup
  25. * Config is stored into file conf.php
  26. */
  27. require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php'; // Lib for memcached
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/nosqlDocument.class.php';
  29. require_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php';
  30. /**
  31. * Class to stock current configuration
  32. */
  33. class Conf extends nosqlDocument {
  34. /** \public */
  35. //! To store properties found in conf file
  36. var $file;
  37. //! Object with database handler
  38. var $db;
  39. //! To store properties found into database
  40. var $global;
  41. //! url of couchdb server
  42. var $Couchdb;
  43. //! url of memcached server
  44. var $memcached;
  45. //! To store if javascript/ajax is enabked
  46. public $use_javascript_ajax;
  47. //! Used to store current currency
  48. public $currency;
  49. //! Used to store current css (from theme)
  50. public $theme; // Contains current theme ("eldy", "auguria", ...)
  51. public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
  52. //! Used to store current menu handlers
  53. public $top_menu;
  54. public $smart_menu;
  55. public $modules = array(); // List of activated modules
  56. public $modules_parts = array('js' => array(), 'triggers' => array(), 'login' => array(), 'substitutions' => array(), 'menus' => array(), 'theme' => array(), 'tpl' => array(), 'barcode' => array(), 'models' => array(), 'hooks' => array()); // List of modules parts
  57. // TODO Remove thoose arrays with generic module_parts
  58. public $tabs_modules = array();
  59. public $sms_engine_modules = array();
  60. public $societe_modules = array();
  61. var $logbuffer = array();
  62. //! To store properties of multi-company
  63. public $multicompany;
  64. //! Used to store running instance for multi-company (default 1)
  65. public $entity = 1;
  66. //! Used to store list of entities to use for each element
  67. public $entities = array();
  68. /**
  69. * Constructor
  70. *
  71. * @return Conf
  72. */
  73. function __construct() {
  74. // Avoid warnings when filling this->xxx
  75. $this->file = new stdClass();
  76. $this->db = new stdClass();
  77. $this->Couchdb = new stdClass();
  78. $this->memcached = new stdClass();
  79. $this->global = new stdClass();
  80. $this->mycompany = new stdClass();
  81. $this->admin = new stdClass();
  82. $this->user = new stdClass();
  83. $this->syslog = new stdClass();
  84. $this->browser = new stdClass();
  85. $this->multicompany = new stdClass();
  86. // First level object
  87. $this->expedition_bon = new stdClass();
  88. $this->livraison_bon = new stdClass();
  89. $this->fournisseur = new stdClass();
  90. $this->product = new stdClass();
  91. $this->service = new stdClass();
  92. $this->contrat = new stdClass();
  93. $this->actions = new stdClass();
  94. $this->commande = new stdClass();
  95. $this->propal = new stdClass();
  96. $this->facture = new stdClass();
  97. $this->contrat = new stdClass();
  98. $this->adherent = new stdClass();
  99. $this->bank = new stdClass();
  100. $this->notification = new stdClass();
  101. $this->mailing = new stdClass();
  102. //! Charset for HTML output and for storing data in memory
  103. $this->file->character_set_client = 'UTF-8'; // UTF-8, ISO-8859-1
  104. //! Memcached disabled by default
  105. $this->memcached->enabled = false;
  106. }
  107. /**
  108. * Load setup values into conf object (read llx_const)
  109. *
  110. * @param DoliDB $db Handler d'acces base
  111. * @return int < 0 if KO, >= 0 if OK
  112. */
  113. function setValues() {
  114. global $user;
  115. // Avoid warning if not defined
  116. if (empty($this->db->dolibarr_main_db_encryption))
  117. $this->db->dolibarr_main_db_encryption = 0;
  118. if (empty($this->db->dolibarr_main_db_cryptkey))
  119. $this->db->dolibarr_main_db_cryptkey = '';
  120. /*
  121. * Definition de toutes les constantes globales d'environnement
  122. * - En constante php (TODO a virer)
  123. * - En $this->global->key=value
  124. */
  125. $found = false;
  126. $result = dol_getcache("const");
  127. if (is_object($result))
  128. $found = true;
  129. if (!$found) {
  130. $result = array();
  131. try {
  132. $result = $this->load('const');
  133. //print_r($result);
  134. dol_setcache("const", $result);
  135. } catch (Exception $e) {
  136. dol_print_error("", $e->getMessage());
  137. exit;
  138. }
  139. }
  140. $i = 0;
  141. if (count($result->values) == 0) {
  142. dol_print_error("", "Error in const document : values is empty !");
  143. exit;
  144. }
  145. foreach ($result->values as $key => $value) {
  146. if ($key) {
  147. if (!defined("$key"))
  148. define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install)
  149. $this->global->$key = $value;
  150. if ($value && preg_match('/^MAIN_MODULE_/', $key)) {
  151. // If this is constant for a new tab page activated by a module.
  152. if (preg_match('/^MAIN_MODULE_([A-Z_]+)_TABS_/i', $key)) {
  153. $params = explode(':', $value, 2);
  154. $this->tabs_modules[$params[0]][] = $value;
  155. }
  156. // If this is constant for a sms engine
  157. elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i', $key, $reg)) {
  158. $modulename = strtolower($reg[1]);
  159. $this->sms_engine_modules[$modulename] = $modulename; // Add this module in list of modules that provide SMS
  160. }
  161. // If this is constant for all generic part activated by a module
  162. elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
  163. $modulename = strtolower($reg[1]);
  164. $partname = strtolower($reg[2]);
  165. //$varname = $partname.'_modules'; // TODO deprecated
  166. //if (! isset($this->$varname) || ! is_array($this->$varname)) { $this->$varname = array(); } // TODO deprecated
  167. if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
  168. $this->modules_parts[$partname] = array();
  169. }
  170. $arrValue = json_decode($value, true);
  171. if (is_array($arrValue) && !empty($arrValue))
  172. $value = $arrValue;
  173. else if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl', 'theme')))
  174. $value = '/' . $modulename . '/core/' . $partname . '/';
  175. else if (in_array($partname, array('models')))
  176. $value = '/' . $modulename . '/';
  177. else if ($value == 1)
  178. $value = '/' . $modulename . '/core/modules/' . $partname . '/';
  179. //$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated
  180. $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value));
  181. }
  182. }
  183. }
  184. $i++;
  185. }
  186. // Load default DB if needed : only after login
  187. if($this->Couchdb->name == "_users")
  188. $this->Couchdb->name = $user->entity;
  189. // load configuration module
  190. $object = new DolibarrModules($this->db);
  191. $result = $object->getView("list", array(), true);
  192. foreach ($result->rows as $aRow) {
  193. $modulename = strtolower($aRow->key);
  194. $this->$modulename = $aRow->value;
  195. $this->modules[] = $modulename;
  196. }
  197. //print_r($this);exit;
  198. //var_dump($this->modules);
  199. //var_dump($this->modules_parts);
  200. // Second or others levels object
  201. $this->propal->cloture = new stdClass();
  202. $this->propal->facturation = new stdClass();
  203. $this->commande->client = new stdClass();
  204. $this->commande->fournisseur = new stdClass();
  205. $this->facture->client = new stdClass();
  206. $this->facture->fournisseur = new stdClass();
  207. $this->fournisseur->commande = new stdClass();
  208. $this->fournisseur->facture = new stdClass();
  209. $this->contrat->services = new stdClass();
  210. $this->contrat->services->inactifs = new stdClass();
  211. $this->contrat->services->expires = new stdClass();
  212. $this->adherent->cotisation = new stdClass();
  213. $this->bank->rappro = new stdClass();
  214. $this->bank->cheque = new stdClass();
  215. // Clean some variables
  216. if (empty($this->global->MAIN_MENU_STANDARD))
  217. $this->global->MAIN_MENU_STANDARD = "eldy_backoffice.php";
  218. if (empty($this->global->MAIN_MENUFRONT_STANDARD))
  219. $this->global->MAIN_MENUFRONT_STANDARD = "eldy_frontoffice.php";
  220. if (empty($this->global->MAIN_MENU_SMARTPHONE))
  221. $this->global->MAIN_MENU_SMARTPHONE = "eldy_backoffice.php"; // Use eldy by default because smartphone does not work on all phones
  222. if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE))
  223. $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_frontoffice.php"; // Ue eldy by default because smartphone does not work on all phones
  224. // Variable globales LDAP
  225. if (empty($this->global->LDAP_FIELD_FULLNAME))
  226. $this->global->LDAP_FIELD_FULLNAME = '';
  227. if (!isset($this->global->LDAP_KEY_USERS))
  228. $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
  229. if (!isset($this->global->LDAP_KEY_GROUPS))
  230. $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
  231. if (!isset($this->global->LDAP_KEY_CONTACTS))
  232. $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
  233. if (!isset($this->global->LDAP_KEY_MEMBERS))
  234. $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
  235. // Load translation object with current language
  236. if (empty($this->global->MAIN_LANG_DEFAULT))
  237. $this->global->MAIN_LANG_DEFAULT = "en_US";
  238. // By default, we repeat info on all tabs
  239. if (!isset($this->global->MAIN_REPEATCONTACTONEACHTAB))
  240. $this->global->MAIN_REPEATCONTACTONEACHTAB = 1;
  241. if (!isset($this->global->MAIN_REPEATADDRESSONEACHTAB))
  242. $this->global->MAIN_REPEATADDRESSONEACHTAB = 1;
  243. $rootfordata = DOL_DATA_ROOT;
  244. $rootforuser = DOL_DATA_ROOT;
  245. // Define default dir_output and dir_temp for directories of modules
  246. foreach ($this->modules as $module) {
  247. $this->$module->multidir_output = array($this->entity => $rootfordata . "/" . $module);
  248. $this->$module->multidir_temp = array($this->entity => $rootfordata . "/" . $module . "/temp");
  249. // For backward compatibility
  250. $this->$module->dir_output = $rootfordata . "/" . $module;
  251. $this->$module->dir_temp = $rootfordata . "/" . $module . "/temp";
  252. }
  253. // For mycompany storage
  254. $this->mycompany->dir_output = $rootfordata . "/mycompany";
  255. $this->mycompany->dir_temp = $rootfordata . "/mycompany/temp";
  256. // For admin storage
  257. $this->admin->dir_output = $rootfordata . '/admin';
  258. $this->admin->dir_temp = $rootfordata . '/admin/temp';
  259. // For user storage
  260. $this->user->multidir_output = array($this->entity => $rootfordata . "/users");
  261. $this->user->multidir_temp = array($this->entity => $rootfordata . "/users/temp");
  262. // For backward compatibility
  263. $this->user->dir_output = $rootforuser . "/users";
  264. $this->user->dir_temp = $rootforuser . "/users/temp";
  265. // For propal storage
  266. $this->propal->dir_output = $rootforuser . "/propal";
  267. $this->propal->dir_temp = $rootforuser . "/propal/temp";
  268. // Exception: Some dir are not the name of module. So we keep exception here
  269. // for backward compatibility.
  270. // Sous module bons d'expedition
  271. $this->expedition_bon->enabled = defined("MAIN_SUBMODULE_EXPEDITION") ? MAIN_SUBMODULE_EXPEDITION : 0;
  272. // Sous module bons de livraison
  273. $this->livraison_bon->enabled = defined("MAIN_SUBMODULE_LIVRAISON") ? MAIN_SUBMODULE_LIVRAISON : 0;
  274. // Module fournisseur
  275. $this->fournisseur->commande->dir_output = $rootfordata . "/fournisseur/commande";
  276. $this->fournisseur->commande->dir_temp = $rootfordata . "/fournisseur/commande/temp";
  277. $this->fournisseur->facture->dir_output = $rootfordata . "/fournisseur/facture";
  278. $this->fournisseur->facture->dir_temp = $rootfordata . "/fournisseur/facture/temp";
  279. // Module product/service
  280. $this->product->multidir_output = array($this->entity => $rootfordata . "/produit");
  281. $this->product->multidir_temp = array($this->entity => $rootfordata . "/produit/temp");
  282. $this->service->multidir_output = array($this->entity => $rootfordata . "/produit");
  283. $this->service->multidir_temp = array($this->entity => $rootfordata . "/produit/temp");
  284. // For backward compatibility
  285. $this->product->dir_output = $rootfordata . "/produit";
  286. $this->product->dir_temp = $rootfordata . "/produit/temp";
  287. $this->service->dir_output = $rootfordata . "/produit";
  288. $this->service->dir_temp = $rootfordata . "/produit/temp";
  289. // Module contrat
  290. $this->contrat->dir_output = $rootfordata . "/contracts";
  291. $this->contrat->dir_temp = $rootfordata . "/contracts/temp";
  292. // Set some default values
  293. // societe
  294. if (empty($this->global->SOCIETE_CODECLIENT_ADDON))
  295. $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
  296. if (empty($this->global->SOCIETE_CODEFOURNISSEUR_ADDON))
  297. $this->global->SOCIETE_CODEFOURNISSEUR_ADDON = $this->global->SOCIETE_CODECLIENT_ADDON;
  298. if (empty($this->global->SOCIETE_CODECOMPTA_ADDON))
  299. $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
  300. // Security
  301. if (empty($this->global->USER_PASSWORD_GENERATED))
  302. $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
  303. if (empty($this->global->MAIN_UMASK))
  304. $this->global->MAIN_UMASK = '0664'; // Default mask
  305. // conf->use_javascript_ajax
  306. $this->use_javascript_ajax = 1;
  307. // conf->currency
  308. if (empty($this->global->MAIN_MONNAIE))
  309. $this->global->MAIN_MONNAIE = 'EUR';
  310. $this->currency = $this->global->MAIN_MONNAIE;
  311. // conf->global->COMPTA_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
  312. if (empty($this->global->COMPTA_MODE))
  313. $this->global->COMPTA_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
  314. // conf->liste_limit = constante de taille maximale des listes
  315. if (empty($this->global->MAIN_SIZE_LISTE_LIMIT))
  316. $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
  317. $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
  318. // conf->liste_limit = constante de taille maximale des listes
  319. if (empty($this->global->MAIN_SIZE_VIEW_LIMIT))
  320. $this->global->MAIN_SIZE_VIEW_LIMIT = 10000;
  321. $this->view_limit = $this->global->MAIN_SIZE_VIEW_LIMIT;
  322. // conf->product->limit_size = constante de taille maximale des select de produit
  323. if (!isset($this->global->PRODUIT_LIMIT_SIZE))
  324. $this->global->PRODUIT_LIMIT_SIZE = 100;
  325. $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
  326. // conf->theme et $this->css
  327. if (empty($this->global->MAIN_THEME))
  328. $this->global->MAIN_THEME = "eldy";
  329. $this->theme = $this->global->MAIN_THEME;
  330. $this->css = "/theme/" . $this->theme . "/style.css.php";
  331. // conf->email_from = email pour envoi par dolibarr des mails automatiques
  332. $this->email_from = "dolibarr-robot@domain.com";
  333. if (!empty($this->global->MAIN_MAIL_EMAIL_FROM))
  334. $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
  335. // conf->notification->email_from = email pour envoi par Dolibarr des notifications
  336. $this->notification->email_from = $this->email_from;
  337. if (!empty($this->global->NOTIFICATION_EMAIL_FROM))
  338. $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
  339. // conf->mailing->email_from = email pour envoi par Dolibarr des mailings
  340. $this->mailing->email_from = $this->email_from;
  341. if (!empty($this->global->MAILING_EMAIL_FROM))
  342. $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
  343. // Format for date (used by default when not found or searched in lang)
  344. $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
  345. $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
  346. $this->format_hour_short = "%H:%M";
  347. $this->format_hour_short_duration = "%H:%M";
  348. $this->format_date_text_short = "%d %b %Y";
  349. $this->format_date_text = "%d %B %Y";
  350. $this->format_date_hour_short = "%d/%m/%Y %H:%M";
  351. $this->format_date_hour_text_short = "%d %b %Y %H:%M";
  352. $this->format_date_hour_text = "%d %B %Y %H:%M";
  353. // Limites decimales si non definie (peuvent etre egale a 0)
  354. if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT))
  355. $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
  356. if (!isset($this->global->MAIN_MAX_DECIMALS_TOT))
  357. $this->global->MAIN_MAX_DECIMALS_TOT = 2;
  358. if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN))
  359. $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
  360. // Timeouts
  361. if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT))
  362. $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
  363. if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT))
  364. $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
  365. // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
  366. if (empty($this->global->TAX_MODE_SELL_PRODUCT))
  367. $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
  368. if (empty($this->global->TAX_MODE_BUY_PRODUCT))
  369. $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
  370. if (empty($this->global->TAX_MODE_SELL_SERVICE))
  371. $this->global->TAX_MODE_SELL_SERVICE = 'payment';
  372. if (empty($this->global->TAX_MODE_BUY_SERVICE))
  373. $this->global->TAX_MODE_BUY_SERVICE = 'payment';
  374. // Delay before warnings
  375. $this->actions->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60;
  376. $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60;
  377. $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;
  378. $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60;
  379. $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60;
  380. $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60;
  381. $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;
  382. $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;
  383. $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60;
  384. $this->adherent->cotisation->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60;
  385. $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60;
  386. $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60;
  387. // For backward compatibility
  388. if (isset($this->product))
  389. $this->produit = $this->product;
  390. if (isset($this->facture))
  391. $this->invoice = $this->facture;
  392. if (isset($this->commande))
  393. $this->order = $this->commande;
  394. if (isset($this->contrat))
  395. $this->contract = $this->contrat;
  396. if (isset($this->categorie))
  397. $this->category = $this->categorie;
  398. // Define menu manager in setup
  399. if (empty($user->societe_id)) { // If internal user or not defined
  400. $this->top_menu = (empty($this->global->MAIN_MENU_STANDARD_FORCED) ? $this->global->MAIN_MENU_STANDARD : $this->global->MAIN_MENU_STANDARD_FORCED);
  401. $this->smart_menu = (empty($this->global->MAIN_MENU_SMARTPHONE_FORCED) ? $this->global->MAIN_MENU_SMARTPHONE : $this->global->MAIN_MENU_SMARTPHONE_FORCED);
  402. } else { // If external user
  403. $this->top_menu = (empty($this->global->MAIN_MENUFRONT_STANDARD_FORCED) ? $this->global->MAIN_MENUFRONT_STANDARD : $this->global->MAIN_MENUFRONT_STANDARD_FORCED);
  404. $this->smart_menu = (empty($this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $this->global->MAIN_MENUFRONT_SMARTPHONE : $this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED);
  405. }
  406. }
  407. /**
  408. * Specific record for conf
  409. */
  410. function record() {
  411. $result = $this->load("const");
  412. unset($result->values); // reset old values
  413. $result->values = new stdClass();
  414. foreach ($this->global as $key => $value)
  415. $result->values->$key = $value; // Write New Value
  416. $this->couchdb->storeDoc($result); // record new values
  417. dol_delcache("const"); //reset cache
  418. return 1;
  419. }
  420. }
  421. ?>