config.class.inc.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. define('ITOP_APPLICATION', 'iTop');
  17. define('ITOP_VERSION', '$ITOP_VERSION$');
  18. define('ITOP_REVISION', '$WCREV$');
  19. define('ITOP_BUILD_DATE', '$WCNOW$');
  20. define('ACCESS_USER_WRITE', 1);
  21. define('ACCESS_ADMIN_WRITE', 2);
  22. define('ACCESS_FULL', ACCESS_USER_WRITE | ACCESS_ADMIN_WRITE);
  23. define('ACCESS_READONLY', 0);
  24. /**
  25. * Configuration read/write
  26. *
  27. * @author Erwan Taloc <erwan.taloc@combodo.com>
  28. * @author Romain Quetiez <romain.quetiez@combodo.com>
  29. * @author Denis Flaven <denis.flaven@combodo.com>
  30. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  31. */
  32. require_once('coreexception.class.inc.php');
  33. class ConfigException extends CoreException
  34. {
  35. }
  36. define ('DEFAULT_CHARACTER_SET', 'utf8');
  37. define ('DEFAULT_COLLATION', 'utf8_unicode_ci');
  38. define ('DEFAULT_LOG_GLOBAL', true);
  39. define ('DEFAULT_LOG_NOTIFICATION', true);
  40. define ('DEFAULT_LOG_ISSUE', true);
  41. define ('DEFAULT_LOG_WEB_SERVICE', true);
  42. define ('DEFAULT_LOG_KPI_DURATION', false);
  43. define ('DEFAULT_LOG_KPI_MEMORY', false);
  44. define ('DEFAULT_DEBUG_QUERIES', false);
  45. define ('DEFAULT_QUERY_CACHE_ENABLED', true);
  46. define ('DEFAULT_MIN_DISPLAY_LIMIT', 10);
  47. define ('DEFAULT_MAX_DISPLAY_LIMIT', 15);
  48. define ('DEFAULT_STANDARD_RELOAD_INTERVAL', 5*60);
  49. define ('DEFAULT_FAST_RELOAD_INTERVAL', 1*60);
  50. define ('DEFAULT_SECURE_CONNECTION_REQUIRED', false);
  51. define ('DEFAULT_HTTPS_HYPERLINKS', false);
  52. define ('DEFAULT_ALLOWED_LOGIN_TYPES', 'form|basic|external');
  53. define ('DEFAULT_EXT_AUTH_VARIABLE', '$_SERVER[\'REMOTE_USER\']');
  54. define ('DEFAULT_ENCRYPTION_KEY', '@iT0pEncr1pti0n!'); // We'll use a random value, later...
  55. /**
  56. * Config
  57. * configuration data (this class cannot not be localized, because it is responsible for loading the dictionaries)
  58. *
  59. * @package iTopORM
  60. */
  61. class Config
  62. {
  63. //protected $m_bIsLoaded = false;
  64. protected $m_sFile = '';
  65. protected $m_aAppModules;
  66. protected $m_aDataModels;
  67. protected $m_aWebServiceCategories;
  68. protected $m_aAddons;
  69. protected $m_aDictionaries;
  70. protected $m_aModuleSettings;
  71. // New way to store the settings !
  72. //
  73. protected $m_aSettings = array(
  74. 'skip_check_to_write' => array(
  75. 'type' => 'bool',
  76. 'description' => 'Disable data format and integrity checks to boost up data load (insert or update)',
  77. 'default' => false,
  78. 'value' => false,
  79. 'source_of_value' => '',
  80. 'show_in_conf_sample' => false,
  81. ),
  82. 'skip_check_ext_keys' => array(
  83. 'type' => 'bool',
  84. 'description' => 'Disable external key check when checking the value of attributes',
  85. 'default' => false,
  86. 'value' => false,
  87. 'source_of_value' => '',
  88. 'show_in_conf_sample' => false,
  89. ),
  90. 'skip_strong_security' => array(
  91. 'type' => 'bool',
  92. 'description' => 'Disable strong security - TEMPORY: this flag should be removed when we are more confident in the recent change in security',
  93. 'default' => true,
  94. 'value' => true,
  95. 'source_of_value' => '',
  96. 'show_in_conf_sample' => false,
  97. ),
  98. 'graphviz_path' => array(
  99. 'type' => 'string',
  100. 'description' => 'Path to the Graphviz "dot" executable for graphing objects lifecycle',
  101. 'default' => '/usr/bin/dot',
  102. 'value' => '',
  103. 'source_of_value' => '',
  104. 'show_in_conf_sample' => false,
  105. ),
  106. 'session_name' => array(
  107. 'type' => 'string',
  108. 'description' => 'The name of the cookie used to store the PHP session id',
  109. 'default' => 'iTop',
  110. 'value' => '',
  111. 'source_of_value' => '',
  112. 'show_in_conf_sample' => true,
  113. ),
  114. 'max_combo_length' => array(
  115. 'type' => 'integer',
  116. 'description' => 'The maximum number of elements in a drop-down list. If more then an autocomplete will be used',
  117. 'default' => 50,
  118. 'value' => 50,
  119. 'source_of_value' => '',
  120. 'show_in_conf_sample' => false,
  121. ),
  122. 'min_autocomplete_chars' => array(
  123. 'type' => 'integer',
  124. 'description' => 'The minimum number of characters to type in order to trigger the "autocomplete" behavior',
  125. 'default' => 3,
  126. 'value' => 3,
  127. 'source_of_value' => '',
  128. 'show_in_conf_sample' => false,
  129. ),
  130. 'allow_target_creation' => array(
  131. 'type' => 'bool',
  132. 'description' => 'Displays the + button on external keys to create target objects',
  133. 'default' => true,
  134. 'value' => true,
  135. 'source_of_value' => '',
  136. 'show_in_conf_sample' => false,
  137. ),
  138. // Levels that trigger a confirmation in the CSV import/synchro wizard
  139. 'csv_import_min_object_confirmation' => array(
  140. 'type' => 'integer',
  141. 'description' => 'Minimum number of objects to check for the confirmation percentages',
  142. 'default' => 3,
  143. 'value' => 3,
  144. 'source_of_value' => '',
  145. 'show_in_conf_sample' => false,
  146. ),
  147. 'csv_import_errors_percentage' => array(
  148. 'type' => 'integer',
  149. 'description' => 'Percentage of errors that trigger a confirmation in the CSV import',
  150. 'default' => 50,
  151. 'value' => 50,
  152. 'source_of_value' => '',
  153. 'show_in_conf_sample' => false,
  154. ),
  155. 'csv_import_modifications_percentage' => array(
  156. 'type' => 'integer',
  157. 'description' => 'Percentage of modifications that trigger a confirmation in the CSV import',
  158. 'default' => 50,
  159. 'value' => 50,
  160. 'source_of_value' => '',
  161. 'show_in_conf_sample' => false,
  162. ),
  163. 'csv_import_creations_percentage' => array(
  164. 'type' => 'integer',
  165. 'description' => 'Percentage of creations that trigger a confirmation in the CSV import',
  166. 'default' => 50,
  167. 'value' => 50,
  168. 'source_of_value' => '',
  169. 'show_in_conf_sample' => false,
  170. ),
  171. 'access_mode' => array(
  172. 'type' => 'integer',
  173. 'description' => 'Combination of flags (ACCESS_USER_WRITE | ACCESS_ADMIN_WRITE, or ACCESS_FULL)',
  174. 'default' => ACCESS_FULL,
  175. 'value' => ACCESS_FULL,
  176. 'source_of_value' => '',
  177. 'show_in_conf_sample' => true,
  178. ),
  179. 'access_message' => array(
  180. 'type' => 'string',
  181. 'description' => 'Message displayed to the users when there is any access restriction',
  182. 'default' => 'iTop is temporarily frozen, please wait... (the admin team)',
  183. 'value' => '',
  184. 'source_of_value' => '',
  185. 'show_in_conf_sample' => true,
  186. ),
  187. 'online_help' => array(
  188. 'type' => 'string',
  189. 'description' => 'Hyperlink to the online-help web page',
  190. 'default' => 'http://www.combodo.com/itop-help',
  191. 'value' => '',
  192. 'source_of_value' => '',
  193. 'show_in_conf_sample' => true,
  194. ),
  195. 'log_usage' => array(
  196. 'type' => 'bool',
  197. 'description' => 'Log the usage of the application (i.e. the date/time and the user name of each login)',
  198. 'default' => false,
  199. 'value' => false,
  200. 'source_of_value' => '',
  201. 'show_in_conf_sample' => false,
  202. ),
  203. 'synchro_trace' => array(
  204. 'type' => 'string',
  205. 'description' => 'Synchronization details: none, display, save (includes \'display\')',
  206. 'default' => 'none',
  207. 'value' => 'none',
  208. 'source_of_value' => '',
  209. 'show_in_conf_sample' => true,
  210. ),
  211. 'link_set_item_separator' => array(
  212. 'type' => 'string',
  213. 'description' => 'Link set from string: line separator',
  214. 'default' => '|',
  215. 'value' => '|',
  216. 'source_of_value' => '',
  217. 'show_in_conf_sample' => true,
  218. ),
  219. 'link_set_attribute_separator' => array(
  220. 'type' => 'string',
  221. 'description' => 'Link set from string: attribute separator',
  222. 'default' => ';',
  223. 'value' => ';',
  224. 'source_of_value' => '',
  225. 'show_in_conf_sample' => true,
  226. ),
  227. 'link_set_value_separator' => array(
  228. 'type' => 'string',
  229. 'description' => 'Link set from string: value separator (between the attcode and the value itself',
  230. 'default' => ':',
  231. 'value' => ':',
  232. 'source_of_value' => '',
  233. 'show_in_conf_sample' => true,
  234. ),
  235. 'link_set_attribute_qualifier' => array(
  236. 'type' => 'string',
  237. 'description' => 'Link set from string: attribute qualifier (encloses both the attcode and the value)',
  238. 'default' => "'",
  239. 'value' => "'",
  240. 'source_of_value' => '',
  241. 'show_in_conf_sample' => true,
  242. ),
  243. 'cron_max_execution_time' => array(
  244. 'type' => 'integer',
  245. 'description' => 'Duration (seconds) of the page cron.php, must be shorter than php setting max_execution_time and shorter than the web server response timeout',
  246. 'default' => 600,
  247. 'value' => 600,
  248. 'source_of_value' => '',
  249. 'show_in_conf_sample' => true,
  250. ),
  251. 'cron_sleep' => array(
  252. 'type' => 'integer',
  253. 'description' => 'Duration (seconds) before cron.php checks again if something must be done',
  254. 'default' => 2,
  255. 'value' => 2,
  256. 'source_of_value' => '',
  257. 'show_in_conf_sample' => false,
  258. ),
  259. 'email_asynchronous' => array(
  260. 'type' => 'bool',
  261. 'description' => 'If set, the emails are sent off line, which requires cron.php to be activated. Exception: some features like the email test utility will force the serialized mode',
  262. 'default' => false,
  263. 'value' => false,
  264. 'source_of_value' => '',
  265. 'show_in_conf_sample' => true,
  266. ),
  267. 'apc_cache.enabled' => array(
  268. 'type' => 'bool',
  269. 'description' => 'If set, the APC cache is allowed (the PHP extension must also be active)',
  270. 'default' => true,
  271. 'value' => true,
  272. 'source_of_value' => '',
  273. 'show_in_conf_sample' => true,
  274. ),
  275. 'apc_cache.query_ttl' => array(
  276. 'type' => 'integer',
  277. 'description' => 'Time to live set in APC for the prepared queries (seconds - 0 means no timeout)',
  278. 'default' => 3600,
  279. 'value' => 3600,
  280. 'source_of_value' => '',
  281. 'show_in_conf_sample' => true,
  282. ),
  283. 'timezone' => array(
  284. 'type' => 'string',
  285. 'description' => 'Timezone (reference: http://php.net/manual/en/timezones.php). If empty, it will be left unchanged and MUST be explicitely configured in PHP',
  286. // examples... not used (nor 'description')
  287. 'examples' => array('America/Sao_Paulo', 'America/New_York (standing for EDT)', 'America/Los_Angeles (standing for PDT)', 'Asia/Istanbul', 'Asia/Singapore', 'Africa/Casablanca', 'Australia/Sydney'),
  288. 'default' => 'Europe/Paris',
  289. 'value' => 'Europe/Paris',
  290. 'source_of_value' => '',
  291. 'show_in_conf_sample' => true,
  292. ),
  293. 'cas_include_path' => array(
  294. 'type' => 'string',
  295. 'description' => 'The path where to find the phpCAS library',
  296. // examples... not used (nor 'description')
  297. 'default' => '/usr/share/php',
  298. 'value' => '/usr/share/php',
  299. 'source_of_value' => '',
  300. 'show_in_conf_sample' => true,
  301. ),
  302. 'cas_version' => array(
  303. 'type' => 'string',
  304. 'description' => 'The CAS protocol version to use',
  305. // examples... not used (nor 'description')
  306. 'default' => '2.0',
  307. 'value' => '',
  308. 'source_of_value' => '',
  309. 'show_in_conf_sample' => true,
  310. ),
  311. 'cas_host' => array(
  312. 'type' => 'string',
  313. 'description' => 'The name of the CAS host',
  314. // examples... not used (nor 'description')
  315. 'default' => '',
  316. 'value' => '',
  317. 'source_of_value' => '',
  318. 'show_in_conf_sample' => true,
  319. ),
  320. 'cas_port' => array(
  321. 'type' => 'integer',
  322. 'description' => 'The port used by the CAS server',
  323. // examples... not used (nor 'description')
  324. 'default' => 443,
  325. 'value' => 443,
  326. 'source_of_value' => '',
  327. 'show_in_conf_sample' => true,
  328. ),
  329. 'cas_context' => array(
  330. 'type' => 'string',
  331. 'description' => 'The CAS context',
  332. // examples... not used (nor 'description')
  333. 'default' => '',
  334. 'value' => '',
  335. 'source_of_value' => '',
  336. 'show_in_conf_sample' => true,
  337. ),
  338. 'cas_server_ca_cert_path' => array(
  339. 'type' => 'string',
  340. 'description' => 'The path where to find the certificate of the CA for validating the certificate of the CAS server',
  341. // examples... not used (nor 'description')
  342. 'default' => '',
  343. 'value' => '',
  344. 'source_of_value' => '',
  345. 'show_in_conf_sample' => true,
  346. ),
  347. 'cas_debug' => array(
  348. 'type' => 'bool',
  349. 'description' => 'Activate the CAS debug',
  350. // examples... not used (nor 'description')
  351. 'default' => false,
  352. 'value' => false,
  353. 'source_of_value' => '',
  354. 'show_in_conf_sample' => true,
  355. ),
  356. );
  357. public function IsProperty($sPropCode)
  358. {
  359. return (array_key_exists($sPropCode, $this->m_aSettings));
  360. }
  361. public function Set($sPropCode, $value, $sSourceDesc = 'unknown')
  362. {
  363. $sType = $this->m_aSettings[$sPropCode]['type'];
  364. switch($sType)
  365. {
  366. case 'bool':
  367. $value = (bool) $value;
  368. break;
  369. case 'string':
  370. $value = (string) $value;
  371. break;
  372. case 'integer':
  373. $value = (integer) $value;
  374. break;
  375. case 'float':
  376. $value = (float) $value;
  377. break;
  378. default:
  379. throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
  380. }
  381. $this->m_aSettings[$sPropCode]['value'] = $value;
  382. $this->m_aSettings[$sPropCode]['source_of_value'] = $sSourceDesc;
  383. }
  384. public function Get($sPropCode)
  385. {
  386. return $this->m_aSettings[$sPropCode]['value'];
  387. }
  388. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  389. protected $m_sDBHost;
  390. protected $m_sDBUser;
  391. protected $m_sDBPwd;
  392. protected $m_sDBName;
  393. protected $m_sDBSubname;
  394. protected $m_sDBCharacterSet;
  395. protected $m_sDBCollation;
  396. /**
  397. * Event log options (see LOG_... definition)
  398. */
  399. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  400. protected $m_bLogGlobal;
  401. protected $m_bLogNotification;
  402. protected $m_bLogIssue;
  403. protected $m_bLogWebService;
  404. protected $m_bLogKpiDuration; // private setting
  405. protected $m_bLogKpiMemory; // private setting
  406. protected $m_bDebugQueries; // private setting
  407. protected $m_bQueryCacheEnabled; // private setting
  408. /**
  409. * @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
  410. */
  411. protected $m_iMinDisplayLimit;
  412. /**
  413. * @var integer Max number of elements before truncating the display
  414. */
  415. protected $m_iMaxDisplayLimit;
  416. /**
  417. * @var integer Number of seconds between two reloads of the display (standard)
  418. */
  419. protected $m_iStandardReloadInterval;
  420. /**
  421. * @var integer Number of seconds between two reloads of the display (fast)
  422. */
  423. protected $m_iFastReloadInterval;
  424. /**
  425. * @var boolean Whether or not a secure connection is required for using the application.
  426. * If set, any attempt to connect to an iTop page with http:// will be redirected
  427. * to https://
  428. */
  429. protected $m_bSecureConnectionRequired;
  430. /**
  431. * @var boolean Forces iTop to output hyperlinks starting with https:// even
  432. * if the current page is not using https. This can be useful when
  433. * the application runs behind a SSL gateway
  434. */
  435. protected $m_bHttpsHyperlinks;
  436. /**
  437. * @var string Langage code, default if the user language is undefined
  438. */
  439. protected $m_sDefaultLanguage;
  440. /**
  441. * @var string Type of login process allowed: form|basic|url|external
  442. */
  443. protected $m_sAllowedLoginTypes;
  444. /**
  445. * @var string Name of the PHP variable in which external authentication information is passed by the web server
  446. */
  447. protected $m_sExtAuthVariable;
  448. /**
  449. * @var string Encryption key used for all attributes of type "encrypted string". Can be set to a random value
  450. * unless you want to import a database from another iTop instance, in which case you must use
  451. * the same encryption key in order to properly decode the encrypted fields
  452. */
  453. protected $m_sEncryptionKey;
  454. /**
  455. * @var array Additional character sets to be supported by the interactive CSV import
  456. * 'iconv_code' => 'display name'
  457. */
  458. protected $m_aCharsets;
  459. public function __construct($sConfigFile, $bLoadConfig = true)
  460. {
  461. $this->m_sFile = $sConfigFile;
  462. $this->m_aAppModules = array(
  463. // Some default modules, always present can be move to an official iTop Module later if needed
  464. 'application/transaction.class.inc.php',
  465. 'application/menunode.class.inc.php',
  466. 'application/user.preferences.class.inc.php',
  467. 'application/audit.rule.class.inc.php',
  468. // Romain - That's dirty, because those classes are in fact part of the core
  469. // but I needed those classes to be derived from cmdbAbstractObject
  470. // (to be managed via the GUI) and this class in not really known from
  471. // the core, PLUS I needed the includes to be there also for the setup
  472. // to create the tables.
  473. 'core/event.class.inc.php',
  474. 'core/action.class.inc.php',
  475. 'core/trigger.class.inc.php',
  476. 'synchro/synchrodatasource.class.inc.php',
  477. );
  478. $this->m_aDataModels = array();
  479. $this->m_aWebServiceCategories = array(
  480. 'webservices/webservices.basic.php',
  481. );
  482. $this->m_aAddons = array(
  483. // Default AddOn, always present can be moved to an official iTop Module later if needed
  484. 'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
  485. );
  486. $this->m_aDictionaries = array(
  487. // Default dictionaries, always present can be moved to an official iTop Module later if needed
  488. 'dictionaries/dictionary.itop.core.php',
  489. 'dictionaries/dictionary.itop.ui.php', // Support for English
  490. 'dictionaries/fr.dictionary.itop.ui.php', // Support for French
  491. 'dictionaries/fr.dictionary.itop.core.php', // Support for French
  492. 'dictionaries/es_cr.dictionary.itop.ui.php', // Support for Spanish (from Costa Rica)
  493. 'dictionaries/es_cr.dictionary.itop.core.php', // Support for Spanish (from Costa Rica)
  494. 'dictionaries/de.dictionary.itop.ui.php', // Support for German
  495. 'dictionaries/de.dictionary.itop.core.php', // Support for German
  496. 'dictionaries/pt_br.dictionary.itop.ui.php', // Support for Brazilian Portuguese
  497. 'dictionaries/pt_br.dictionary.itop.core.php', // Support for Brazilian Portuguese
  498. 'dictionaries/ru.dictionary.itop.ui.php', // Support for Russian
  499. 'dictionaries/ru.dictionary.itop.core.php', // Support for Russian
  500. 'dictionaries/tr.dictionary.itop.ui.php', // Support for Turkish
  501. 'dictionaries/tr.dictionary.itop.core.php', // Support for Turkish
  502. 'dictionaries/zh.dictionary.itop.ui.php', // Support for Chinese
  503. 'dictionaries/zh.dictionary.itop.core.php', // Support for Chinese
  504. 'dictionaries/it.dictionary.itop.ui.php', // Support for Italian
  505. 'dictionaries/it.dictionary.itop.core.php', // Support for Italian
  506. 'dictionaries/hu.dictionary.itop.ui.php', // Support for Hungarian
  507. 'dictionaries/hu.dictionary.itop.core.php', // Support for Hungarian
  508. );
  509. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  510. {
  511. $this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
  512. }
  513. $this->m_sDBHost = '';
  514. $this->m_sDBUser = '';
  515. $this->m_sDBPwd = '';
  516. $this->m_sDBName = '';
  517. $this->m_sDBSubname = '';
  518. $this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
  519. $this->m_sDBCollation = DEFAULT_COLLATION;
  520. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  521. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  522. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  523. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  524. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  525. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  526. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  527. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  528. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  529. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  530. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  531. $this->m_bHttpsHyperlinks = DEFAULT_HTTPS_HYPERLINKS;
  532. $this->m_sDefaultLanguage = 'EN US';
  533. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  534. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  535. $this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
  536. $this->m_aCharsets = array();
  537. $this->m_aModuleSettings = array();
  538. if ($bLoadConfig)
  539. {
  540. $this->Load($sConfigFile);
  541. $this->Verify();
  542. }
  543. }
  544. protected function CheckFile($sPurpose, $sFileName)
  545. {
  546. if (!file_exists($sFileName))
  547. {
  548. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  549. }
  550. }
  551. protected function Load($sConfigFile)
  552. {
  553. $this->CheckFile('configuration', $sConfigFile);
  554. $sConfigCode = trim(file_get_contents($sConfigFile));
  555. // This does not work on several lines
  556. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  557. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  558. try
  559. {
  560. ob_start();
  561. eval('?'.'>'.trim($sConfigCode));
  562. $sNoise = trim(ob_get_contents());
  563. ob_end_clean();
  564. }
  565. catch (Exception $e)
  566. {
  567. // well, never reach in case of parsing error :-(
  568. // will be improved in PHP 6 ?
  569. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  570. }
  571. if (strlen($sNoise) > 0)
  572. {
  573. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  574. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').'</tt>'));
  575. }
  576. if (!isset($MySettings) || !is_array($MySettings))
  577. {
  578. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  579. }
  580. if (!isset($MyModules) || !is_array($MyModules))
  581. {
  582. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  583. }
  584. if (!array_key_exists('application', $MyModules))
  585. {
  586. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  587. }
  588. if (!array_key_exists('business', $MyModules))
  589. {
  590. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  591. }
  592. if (!array_key_exists('addons', $MyModules))
  593. {
  594. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  595. }
  596. if (!array_key_exists('user rights', $MyModules['addons']))
  597. {
  598. // Add one, by default
  599. $MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
  600. }
  601. if (!array_key_exists('dictionaries', $MyModules))
  602. {
  603. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  604. }
  605. $this->m_aAppModules = $MyModules['application'];
  606. $this->m_aDataModels = $MyModules['business'];
  607. if (isset($MyModules['webservices']))
  608. {
  609. $this->m_aWebServiceCategories = $MyModules['webservices'];
  610. }
  611. $this->m_aAddons = $MyModules['addons'];
  612. $this->m_aDictionaries = $MyModules['dictionaries'];
  613. foreach($MySettings as $sPropCode => $rawvalue)
  614. {
  615. if ($this->IsProperty($sPropCode))
  616. {
  617. $value = trim($rawvalue);
  618. $this->Set($sPropCode, $value, $sConfigFile);
  619. }
  620. }
  621. $this->m_sDBHost = trim($MySettings['db_host']);
  622. $this->m_sDBUser = trim($MySettings['db_user']);
  623. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  624. $this->m_sDBName = trim($MySettings['db_name']);
  625. $this->m_sDBSubname = trim($MySettings['db_subname']);
  626. $this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
  627. $this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
  628. $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  629. $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  630. $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  631. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  632. $this->m_bLogKPIDuration = isset($MySettings['log_kpi_duration']) ? (bool) trim($MySettings['log_kpi_duration']) : DEFAULT_LOG_KPI_DURATION;
  633. $this->m_bLogKPIMemory = isset($MySettings['log_kpi_memory']) ? (bool) trim($MySettings['log_kpi_memory']) : DEFAULT_LOG_KPI_MEMORY;
  634. $this->m_bDebugQueries = isset($MySettings['debug_queries']) ? (bool) trim($MySettings['debug_queries']) : DEFAULT_DEBUG_QUERIES;
  635. $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
  636. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  637. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  638. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  639. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  640. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  641. $this->m_bHttpsHyperlinks = isset($MySettings['https_hyperlinks']) ? (bool) trim($MySettings['https_hyperlinks']) : DEFAULT_HTTPS_HYPERLINKS;
  642. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  643. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  644. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  645. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  646. $this->m_sEncryptionKey = isset($MySettings['encryption_key']) ? trim($MySettings['encryption_key']) : DEFAULT_ENCRYPTION_KEY;
  647. $this->m_aCharsets = isset($MySettings['csv_import_charsets']) ? $MySettings['csv_import_charsets'] : array();
  648. }
  649. protected function Verify()
  650. {
  651. // Files are verified later on, just before using them -see MetaModel::Plugin()
  652. // (we have their final path at that point)
  653. }
  654. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  655. {
  656. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  657. {
  658. return $this->m_aModuleSettings[$sModule][$sProperty];
  659. }
  660. return $defaultvalue;
  661. }
  662. public function SetModuleSetting($sModule, $sProperty, $value)
  663. {
  664. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  665. }
  666. public function GetAppModules()
  667. {
  668. return $this->m_aAppModules;
  669. }
  670. public function SetAppModules($aAppModules)
  671. {
  672. $this->m_aAppModules = $aAppModules;
  673. }
  674. public function GetDataModels()
  675. {
  676. return $this->m_aDataModels;
  677. }
  678. public function SetDataModels($aDataModels)
  679. {
  680. $this->m_aDataModels = $aDataModels;
  681. }
  682. public function GetWebServiceCategories()
  683. {
  684. return $this->m_aWebServiceCategories;
  685. }
  686. public function SetWebServiceCategories($aWebServiceCategories)
  687. {
  688. $this->m_aWebServiceCategories = $aWebServiceCategories;
  689. }
  690. public function GetAddons()
  691. {
  692. return $this->m_aAddons;
  693. }
  694. public function SetAddons($aAddons)
  695. {
  696. $this->m_aAddons = $aAddons;
  697. }
  698. public function GetDictionaries()
  699. {
  700. return $this->m_aDictionaries;
  701. }
  702. public function SetDictionaries($aDictionaries)
  703. {
  704. $this->m_aDictionaries = $aDictionaries;
  705. }
  706. public function GetDBHost()
  707. {
  708. return $this->m_sDBHost;
  709. }
  710. public function GetDBName()
  711. {
  712. return $this->m_sDBName;
  713. }
  714. public function GetDBSubname()
  715. {
  716. return $this->m_sDBSubname;
  717. }
  718. public function GetDBCharacterSet()
  719. {
  720. return $this->m_sDBCharacterSet;
  721. }
  722. public function GetDBCollation()
  723. {
  724. return $this->m_sDBCollation;
  725. }
  726. public function GetDBUser()
  727. {
  728. return $this->m_sDBUser;
  729. }
  730. public function GetDBPwd()
  731. {
  732. return $this->m_sDBPwd;
  733. }
  734. public function GetLogGlobal()
  735. {
  736. return $this->m_bLogGlobal;
  737. }
  738. public function GetLogNotification()
  739. {
  740. return $this->m_bLogNotification;
  741. }
  742. public function GetLogIssue()
  743. {
  744. return $this->m_bLogIssue;
  745. }
  746. public function GetLogWebService()
  747. {
  748. return $this->m_bLogWebService;
  749. }
  750. public function GetLogKPIDuration()
  751. {
  752. return $this->m_bLogKPIDuration;
  753. }
  754. public function GetLogKPIMemory()
  755. {
  756. return $this->m_bLogKPIMemory;
  757. }
  758. public function GetDebugQueries()
  759. {
  760. return $this->m_bDebugQueries;
  761. }
  762. public function GetQueryCacheEnabled()
  763. {
  764. return $this->m_bQueryCacheEnabled;
  765. }
  766. public function GetMinDisplayLimit()
  767. {
  768. return $this->m_iMinDisplayLimit;
  769. }
  770. public function GetMaxDisplayLimit()
  771. {
  772. return $this->m_iMaxDisplayLimit;
  773. }
  774. public function GetStandardReloadInterval()
  775. {
  776. return $this->m_iStandardReloadInterval;
  777. }
  778. public function GetFastReloadInterval()
  779. {
  780. return $this->m_iFastReloadInterval;
  781. }
  782. public function GetSecureConnectionRequired()
  783. {
  784. return $this->m_bSecureConnectionRequired;
  785. }
  786. public function GetHttpsHyperlinks()
  787. {
  788. return $this->m_bHttpsHyperlinks;
  789. }
  790. public function GetDefaultLanguage()
  791. {
  792. return $this->m_sDefaultLanguage;
  793. }
  794. public function GetEncryptionKey()
  795. {
  796. return $this->m_sEncryptionKey;
  797. }
  798. public function GetAllowedLoginTypes()
  799. {
  800. return explode('|', $this->m_sAllowedLoginTypes);
  801. }
  802. public function GetExternalAuthenticationVariable()
  803. {
  804. return $this->m_sExtAuthVariable;
  805. }
  806. public function GetCSVImportCharsets()
  807. {
  808. return $this->m_aCharsets;
  809. }
  810. public function SetDBHost($sDBHost)
  811. {
  812. $this->m_sDBHost = $sDBHost;
  813. }
  814. public function SetDBName($sDBName)
  815. {
  816. $this->m_sDBName = $sDBName;
  817. }
  818. public function SetDBSubname($sDBSubName)
  819. {
  820. $this->m_sDBSubname = $sDBSubName;
  821. }
  822. public function SetDBCharacterSet($sDBCharacterSet)
  823. {
  824. $this->m_sDBCharacterSet = $sDBCharacterSet;
  825. }
  826. public function SetDBCollation($sDBCollation)
  827. {
  828. $this->m_sDBCollation = $sDBCollation;
  829. }
  830. public function SetDBUser($sUser)
  831. {
  832. $this->m_sDBUser = $sUser;
  833. }
  834. public function SetDBPwd($sPwd)
  835. {
  836. $this->m_sDBPwd = $sPwd;
  837. }
  838. public function SetLogGlobal($iLogGlobal)
  839. {
  840. $this->m_iLogGlobal = $iLogGlobal;
  841. }
  842. public function SetLogNotification($iLogNotification)
  843. {
  844. $this->m_iLogNotification = $iLogNotification;
  845. }
  846. public function SetLogIssue($iLogIssue)
  847. {
  848. $this->m_iLogIssue = $iLogIssue;
  849. }
  850. public function SetLogWebService($iLogWebService)
  851. {
  852. $this->m_iLogWebService = $iLogWebService;
  853. }
  854. public function SetMinDisplayLimit($iMinDisplayLimit)
  855. {
  856. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  857. }
  858. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  859. {
  860. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  861. }
  862. public function SetStandardReloadInterval($iStandardReloadInterval)
  863. {
  864. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  865. }
  866. public function SetFastReloadInterval($iFastReloadInterval)
  867. {
  868. $this->m_iFastReloadInterval = $iFastReloadInterval;
  869. }
  870. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  871. {
  872. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  873. }
  874. public function SetHttpsHyperlinks($bHttpsHyperlinks)
  875. {
  876. $this->m_bHttpsHyperlinks = $bHttpsHyperlinks;
  877. }
  878. public function SetDefaultLanguage($sLanguageCode)
  879. {
  880. $this->m_sDefaultLanguage = $sLanguageCode;
  881. }
  882. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  883. {
  884. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  885. }
  886. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  887. {
  888. $this->m_sExtAuthVariable = $sExtAuthVariable;
  889. }
  890. public function SetEncryptionKey($sKey)
  891. {
  892. $this->m_sEncryptionKey = $sKey;
  893. }
  894. public function SetCSVImportCharsets($aCharsets)
  895. {
  896. $this->m_aCharsets = $aCharsets;
  897. }
  898. public function AddCSVImportCharset($sIconvCode, $sDisplayName)
  899. {
  900. $this->m_aCharsets[$sIconvCode] = $sDisplayName;
  901. }
  902. public function FileIsWritable()
  903. {
  904. return is_writable($this->m_sFile);
  905. }
  906. public function GetLoadedFile()
  907. {
  908. return $this->m_sFile;
  909. }
  910. /**
  911. * Render the configuration as an associative array
  912. * @return boolean True otherwise throws an Exception
  913. */
  914. public function ToArray()
  915. {
  916. $aSettings = array();
  917. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  918. {
  919. $aSettings[$sPropCode] = $aSettingInfo['value'];
  920. }
  921. $aSettings['db_host'] = $this->m_sDBHost;
  922. $aSettings['db_user'] = $this->m_sDBUser;
  923. $aSettings['db_pwd'] = $this->m_sDBPwd;
  924. $aSettings['db_name'] = $this->m_sDBName;
  925. $aSettings['db_subname'] = $this->m_sDBSubname;
  926. $aSettings['db_character_set'] = $this->m_sDBCharacterSet;
  927. $aSettings['db_collation'] = $this->m_sDBCollation;
  928. $aSettings['log_global'] = $this->m_bLogGlobal;
  929. $aSettings['log_notification'] = $this->m_bLogNotification;
  930. $aSettings['log_issue'] = $this->m_bLogIssue;
  931. $aSettings['log_web_service'] = $this->m_bLogWebService;
  932. $aSettings['min_display_limit'] = $this->m_iMinDisplayLimit;
  933. $aSettings['max_display_limit'] = $this->m_iMaxDisplayLimit;
  934. $aSettings['standard_reload_interval'] = $this->m_iStandardReloadInterval;
  935. $aSettings['fast_reload_interval'] = $this->m_iFastReloadInterval;
  936. $aSettings['secure_connection_required'] = $this->m_bSecureConnectionRequired;
  937. $aSettings['https_hyperlinks'] = $this->m_bHttpsHyperlinks;
  938. $aSettings['default_language'] = $this->m_sDefaultLanguage;
  939. $aSettings['allowed_login_types'] = $this->m_sAllowedLoginTypes;
  940. $aSettings['encryption_key'] = $this->m_sEncryptionKey;
  941. $aSettings['csv_import_charsets'] = $this->m_aCharsets;
  942. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  943. {
  944. foreach ($aProperties as $sProperty => $value)
  945. {
  946. $aSettings['module_settings'][$sModule][$sProperty] = $value;
  947. }
  948. }
  949. foreach($this->m_aAppModules as $sFile)
  950. {
  951. $aSettings['application_list'][] = $sFile;
  952. }
  953. foreach($this->m_aDataModels as $sFile)
  954. {
  955. $aSettings['datamodel_list'][] = $sFile;
  956. }
  957. foreach($this->m_aWebServiceCategories as $sFile)
  958. {
  959. $aSettings['webservice_list'][] = $sFile;
  960. }
  961. foreach($this->m_aAddons as $sKey => $sFile)
  962. {
  963. $aSettings['addon_list'][] = $sFile;
  964. }
  965. foreach($this->m_aDictionaries as $sFile)
  966. {
  967. $aSettings['dictionary_list'][] = $sFile;
  968. }
  969. return $aSettings;
  970. }
  971. /**
  972. * Write the configuration to a file (php format) that can be reloaded later
  973. * By default write to the same file that was specified when constructing the object
  974. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  975. * @return boolean True otherwise throws an Exception
  976. */
  977. public function WriteToFile($sFileName = '')
  978. {
  979. if (empty($sFileName))
  980. {
  981. $sFileName = $this->m_sFile;
  982. }
  983. $hFile = @fopen($sFileName, 'w');
  984. if ($hFile !== false)
  985. {
  986. fwrite($hFile, "<?php\n");
  987. fwrite($hFile, "\n/**\n");
  988. fwrite($hFile, " *\n");
  989. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  990. fwrite($hFile, " *\n");
  991. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  992. fwrite($hFile, " *\n");
  993. fwrite($hFile, " */\n");
  994. fwrite($hFile, "\n");
  995. fwrite($hFile, "\$MySettings = array(\n");
  996. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  997. {
  998. if ($aSettingInfo['show_in_conf_sample'])
  999. {
  1000. $sType = $this->m_aSettings[$sPropCode]['type'];
  1001. switch($sType)
  1002. {
  1003. case 'bool':
  1004. $sSeenAs = $aSettingInfo['value'] ? '1' : '0';
  1005. break;
  1006. default:
  1007. $sSeenAs = "'".addslashes($aSettingInfo['value'])."'";
  1008. }
  1009. fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
  1010. }
  1011. }
  1012. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  1013. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  1014. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  1015. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  1016. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  1017. fwrite($hFile, "\t'db_character_set' => '{$this->m_sDBCharacterSet}',\n");
  1018. fwrite($hFile, "\t'db_collation' => '{$this->m_sDBCollation}',\n");
  1019. fwrite($hFile, "\n");
  1020. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  1021. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  1022. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  1023. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  1024. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  1025. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  1026. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  1027. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  1028. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  1029. fwrite($hFile, "\t'https_hyperlinks' => ".($this->m_bHttpsHyperlinks ? 'true' : 'false').",\n");
  1030. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  1031. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  1032. fwrite($hFile, "\t'encryption_key' => '{$this->m_sEncryptionKey}',\n");
  1033. $sExport = var_export($this->m_aCharsets, true);
  1034. fwrite($hFile, "\t'csv_import_charsets' => $sExport,\n");
  1035. fwrite($hFile, ");\n");
  1036. fwrite($hFile, "\n");
  1037. fwrite($hFile, "\$MyModuleSettings = array(\n");
  1038. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  1039. {
  1040. fwrite($hFile, "\t'$sModule' => array (\n");
  1041. foreach ($aProperties as $sProperty => $value)
  1042. {
  1043. $sExport = var_export($value, true);
  1044. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  1045. }
  1046. fwrite($hFile, "\t),\n");
  1047. }
  1048. fwrite($hFile, ");\n");
  1049. fwrite($hFile, "\n/**\n");
  1050. fwrite($hFile, " *\n");
  1051. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  1052. fwrite($hFile, " *\n");
  1053. fwrite($hFile, " */\n");
  1054. fwrite($hFile, "\$MyModules = array(\n");
  1055. fwrite($hFile, "\t'application' => array (\n");
  1056. foreach($this->m_aAppModules as $sFile)
  1057. {
  1058. fwrite($hFile, "\t\t'$sFile',\n");
  1059. }
  1060. fwrite($hFile, "\t),\n");
  1061. fwrite($hFile, "\t'business' => array (\n");
  1062. foreach($this->m_aDataModels as $sFile)
  1063. {
  1064. fwrite($hFile, "\t\t'$sFile',\n");
  1065. }
  1066. fwrite($hFile, "\t),\n");
  1067. fwrite($hFile, "\t'webservices' => array (\n");
  1068. foreach($this->m_aWebServiceCategories as $sFile)
  1069. {
  1070. fwrite($hFile, "\t\t'$sFile',\n");
  1071. }
  1072. fwrite($hFile, "\t),\n");
  1073. fwrite($hFile, "\t'addons' => array (\n");
  1074. foreach($this->m_aAddons as $sKey => $sFile)
  1075. {
  1076. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  1077. }
  1078. fwrite($hFile, "\t),\n");
  1079. fwrite($hFile, "\t'dictionaries' => array (\n");
  1080. foreach($this->m_aDictionaries as $sFile)
  1081. {
  1082. fwrite($hFile, "\t\t'$sFile',\n");
  1083. }
  1084. fwrite($hFile, "\t),\n");
  1085. fwrite($hFile, ");\n");
  1086. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  1087. return fclose($hFile);
  1088. }
  1089. else
  1090. {
  1091. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  1092. }
  1093. }
  1094. }
  1095. ?>