config.class.inc.php 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  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. );
  294. public function IsProperty($sPropCode)
  295. {
  296. return (array_key_exists($sPropCode, $this->m_aSettings));
  297. }
  298. public function Set($sPropCode, $value, $sSourceDesc = 'unknown')
  299. {
  300. $sType = $this->m_aSettings[$sPropCode]['type'];
  301. switch($sType)
  302. {
  303. case 'bool':
  304. $value = (bool) $value;
  305. break;
  306. case 'string':
  307. $value = (string) $value;
  308. break;
  309. case 'integer':
  310. $value = (integer) $value;
  311. break;
  312. case 'float':
  313. $value = (float) $value;
  314. break;
  315. default:
  316. throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
  317. }
  318. $this->m_aSettings[$sPropCode]['value'] = $value;
  319. $this->m_aSettings[$sPropCode]['source_of_value'] = $sSourceDesc;
  320. }
  321. public function Get($sPropCode)
  322. {
  323. return $this->m_aSettings[$sPropCode]['value'];
  324. }
  325. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  326. protected $m_sDBHost;
  327. protected $m_sDBUser;
  328. protected $m_sDBPwd;
  329. protected $m_sDBName;
  330. protected $m_sDBSubname;
  331. protected $m_sDBCharacterSet;
  332. protected $m_sDBCollation;
  333. /**
  334. * Event log options (see LOG_... definition)
  335. */
  336. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  337. protected $m_bLogGlobal;
  338. protected $m_bLogNotification;
  339. protected $m_bLogIssue;
  340. protected $m_bLogWebService;
  341. protected $m_bLogKpiDuration; // private setting
  342. protected $m_bLogKpiMemory; // private setting
  343. protected $m_bDebugQueries; // private setting
  344. protected $m_bQueryCacheEnabled; // private setting
  345. /**
  346. * @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
  347. */
  348. protected $m_iMinDisplayLimit;
  349. /**
  350. * @var integer Max number of elements before truncating the display
  351. */
  352. protected $m_iMaxDisplayLimit;
  353. /**
  354. * @var integer Number of seconds between two reloads of the display (standard)
  355. */
  356. protected $m_iStandardReloadInterval;
  357. /**
  358. * @var integer Number of seconds between two reloads of the display (fast)
  359. */
  360. protected $m_iFastReloadInterval;
  361. /**
  362. * @var boolean Whether or not a secure connection is required for using the application.
  363. * If set, any attempt to connect to an iTop page with http:// will be redirected
  364. * to https://
  365. */
  366. protected $m_bSecureConnectionRequired;
  367. /**
  368. * @var boolean Forces iTop to output hyperlinks starting with https:// even
  369. * if the current page is not using https. This can be useful when
  370. * the application runs behind a SSL gateway
  371. */
  372. protected $m_bHttpsHyperlinks;
  373. /**
  374. * @var string Langage code, default if the user language is undefined
  375. */
  376. protected $m_sDefaultLanguage;
  377. /**
  378. * @var string Type of login process allowed: form|basic|url|external
  379. */
  380. protected $m_sAllowedLoginTypes;
  381. /**
  382. * @var string Name of the PHP variable in which external authentication information is passed by the web server
  383. */
  384. protected $m_sExtAuthVariable;
  385. /**
  386. * @var string Encryption key used for all attributes of type "encrypted string". Can be set to a random value
  387. * unless you want to import a database from another iTop instance, in which case you must use
  388. * the same encryption key in order to properly decode the encrypted fields
  389. */
  390. protected $m_sEncryptionKey;
  391. /**
  392. * @var array Additional character sets to be supported by the interactive CSV import
  393. * 'iconv_code' => 'display name'
  394. */
  395. protected $m_aCharsets;
  396. public function __construct($sConfigFile, $bLoadConfig = true)
  397. {
  398. $this->m_sFile = $sConfigFile;
  399. $this->m_aAppModules = array(
  400. // Some default modules, always present can be move to an official iTop Module later if needed
  401. 'application/transaction.class.inc.php',
  402. 'application/menunode.class.inc.php',
  403. 'application/user.preferences.class.inc.php',
  404. 'application/audit.rule.class.inc.php',
  405. // Romain - That's dirty, because those classes are in fact part of the core
  406. // but I needed those classes to be derived from cmdbAbstractObject
  407. // (to be managed via the GUI) and this class in not really known from
  408. // the core, PLUS I needed the includes to be there also for the setup
  409. // to create the tables.
  410. 'core/event.class.inc.php',
  411. 'core/action.class.inc.php',
  412. 'core/trigger.class.inc.php',
  413. 'synchro/synchrodatasource.class.inc.php',
  414. );
  415. $this->m_aDataModels = array();
  416. $this->m_aWebServiceCategories = array(
  417. 'webservices/webservices.basic.php',
  418. );
  419. $this->m_aAddons = array(
  420. // Default AddOn, always present can be moved to an official iTop Module later if needed
  421. 'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
  422. );
  423. $this->m_aDictionaries = array(
  424. // Default dictionaries, always present can be moved to an official iTop Module later if needed
  425. 'dictionaries/dictionary.itop.core.php',
  426. 'dictionaries/dictionary.itop.ui.php', // Support for English
  427. 'dictionaries/fr.dictionary.itop.ui.php', // Support for French
  428. 'dictionaries/fr.dictionary.itop.core.php', // Support for French
  429. 'dictionaries/es_cr.dictionary.itop.ui.php', // Support for Spanish (from Costa Rica)
  430. 'dictionaries/es_cr.dictionary.itop.core.php', // Support for Spanish (from Costa Rica)
  431. 'dictionaries/de.dictionary.itop.ui.php', // Support for German
  432. 'dictionaries/de.dictionary.itop.core.php', // Support for German
  433. 'dictionaries/pt_br.dictionary.itop.ui.php', // Support for Brazilian Portuguese
  434. 'dictionaries/pt_br.dictionary.itop.core.php', // Support for Brazilian Portuguese
  435. 'dictionaries/ru.dictionary.itop.ui.php', // Support for Russian
  436. 'dictionaries/ru.dictionary.itop.core.php', // Support for Russian
  437. 'dictionaries/tr.dictionary.itop.ui.php', // Support for Turkish
  438. 'dictionaries/tr.dictionary.itop.core.php', // Support for Turkish
  439. 'dictionaries/zh.dictionary.itop.ui.php', // Support for Chinese
  440. 'dictionaries/zh.dictionary.itop.core.php', // Support for Chinese
  441. 'dictionaries/it.dictionary.itop.ui.php', // Support for Italian
  442. 'dictionaries/it.dictionary.itop.core.php', // Support for Italian
  443. 'dictionaries/hu.dictionary.itop.ui.php', // Support for Hungarian
  444. 'dictionaries/hu.dictionary.itop.core.php', // Support for Hungarian
  445. );
  446. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  447. {
  448. $this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
  449. }
  450. $this->m_sDBHost = '';
  451. $this->m_sDBUser = '';
  452. $this->m_sDBPwd = '';
  453. $this->m_sDBName = '';
  454. $this->m_sDBSubname = '';
  455. $this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
  456. $this->m_sDBCollation = DEFAULT_COLLATION;
  457. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  458. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  459. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  460. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  461. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  462. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  463. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  464. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  465. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  466. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  467. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  468. $this->m_bHttpsHyperlinks = DEFAULT_HTTPS_HYPERLINKS;
  469. $this->m_sDefaultLanguage = 'EN US';
  470. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  471. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  472. $this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
  473. $this->m_aCharsets = array();
  474. $this->m_aModuleSettings = array();
  475. if ($bLoadConfig)
  476. {
  477. $this->Load($sConfigFile);
  478. $this->Verify();
  479. }
  480. }
  481. protected function CheckFile($sPurpose, $sFileName)
  482. {
  483. if (!file_exists($sFileName))
  484. {
  485. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  486. }
  487. }
  488. protected function Load($sConfigFile)
  489. {
  490. $this->CheckFile('configuration', $sConfigFile);
  491. $sConfigCode = trim(file_get_contents($sConfigFile));
  492. // This does not work on several lines
  493. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  494. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  495. try
  496. {
  497. ob_start();
  498. eval('?'.'>'.trim($sConfigCode));
  499. $sNoise = trim(ob_get_contents());
  500. ob_end_clean();
  501. }
  502. catch (Exception $e)
  503. {
  504. // well, never reach in case of parsing error :-(
  505. // will be improved in PHP 6 ?
  506. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  507. }
  508. if (strlen($sNoise) > 0)
  509. {
  510. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  511. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').'</tt>'));
  512. }
  513. if (!isset($MySettings) || !is_array($MySettings))
  514. {
  515. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  516. }
  517. if (!isset($MyModules) || !is_array($MyModules))
  518. {
  519. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  520. }
  521. if (!array_key_exists('application', $MyModules))
  522. {
  523. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  524. }
  525. if (!array_key_exists('business', $MyModules))
  526. {
  527. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  528. }
  529. if (!array_key_exists('addons', $MyModules))
  530. {
  531. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  532. }
  533. if (!array_key_exists('user rights', $MyModules['addons']))
  534. {
  535. // Add one, by default
  536. $MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
  537. }
  538. if (!array_key_exists('dictionaries', $MyModules))
  539. {
  540. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  541. }
  542. $this->m_aAppModules = $MyModules['application'];
  543. $this->m_aDataModels = $MyModules['business'];
  544. if (isset($MyModules['webservices']))
  545. {
  546. $this->m_aWebServiceCategories = $MyModules['webservices'];
  547. }
  548. $this->m_aAddons = $MyModules['addons'];
  549. $this->m_aDictionaries = $MyModules['dictionaries'];
  550. foreach($MySettings as $sPropCode => $rawvalue)
  551. {
  552. if ($this->IsProperty($sPropCode))
  553. {
  554. $value = trim($rawvalue);
  555. $this->Set($sPropCode, $value, $sConfigFile);
  556. }
  557. }
  558. $this->m_sDBHost = trim($MySettings['db_host']);
  559. $this->m_sDBUser = trim($MySettings['db_user']);
  560. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  561. $this->m_sDBName = trim($MySettings['db_name']);
  562. $this->m_sDBSubname = trim($MySettings['db_subname']);
  563. $this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
  564. $this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
  565. $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  566. $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  567. $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  568. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  569. $this->m_bLogKPIDuration = isset($MySettings['log_kpi_duration']) ? (bool) trim($MySettings['log_kpi_duration']) : DEFAULT_LOG_KPI_DURATION;
  570. $this->m_bLogKPIMemory = isset($MySettings['log_kpi_memory']) ? (bool) trim($MySettings['log_kpi_memory']) : DEFAULT_LOG_KPI_MEMORY;
  571. $this->m_bDebugQueries = isset($MySettings['debug_queries']) ? (bool) trim($MySettings['debug_queries']) : DEFAULT_DEBUG_QUERIES;
  572. $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
  573. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  574. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  575. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  576. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  577. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  578. $this->m_bHttpsHyperlinks = isset($MySettings['https_hyperlinks']) ? (bool) trim($MySettings['https_hyperlinks']) : DEFAULT_HTTPS_HYPERLINKS;
  579. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  580. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  581. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  582. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  583. $this->m_sEncryptionKey = isset($MySettings['encryption_key']) ? trim($MySettings['encryption_key']) : DEFAULT_ENCRYPTION_KEY;
  584. $this->m_aCharsets = isset($MySettings['csv_import_charsets']) ? $MySettings['csv_import_charsets'] : array();
  585. }
  586. protected function Verify()
  587. {
  588. // Files are verified later on, just before using them -see MetaModel::Plugin()
  589. // (we have their final path at that point)
  590. }
  591. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  592. {
  593. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  594. {
  595. return $this->m_aModuleSettings[$sModule][$sProperty];
  596. }
  597. return $defaultvalue;
  598. }
  599. public function SetModuleSetting($sModule, $sProperty, $value)
  600. {
  601. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  602. }
  603. public function GetAppModules()
  604. {
  605. return $this->m_aAppModules;
  606. }
  607. public function SetAppModules($aAppModules)
  608. {
  609. $this->m_aAppModules = $aAppModules;
  610. }
  611. public function GetDataModels()
  612. {
  613. return $this->m_aDataModels;
  614. }
  615. public function SetDataModels($aDataModels)
  616. {
  617. $this->m_aDataModels = $aDataModels;
  618. }
  619. public function GetWebServiceCategories()
  620. {
  621. return $this->m_aWebServiceCategories;
  622. }
  623. public function SetWebServiceCategories($aWebServiceCategories)
  624. {
  625. $this->m_aWebServiceCategories = $aWebServiceCategories;
  626. }
  627. public function GetAddons()
  628. {
  629. return $this->m_aAddons;
  630. }
  631. public function SetAddons($aAddons)
  632. {
  633. $this->m_aAddons = $aAddons;
  634. }
  635. public function GetDictionaries()
  636. {
  637. return $this->m_aDictionaries;
  638. }
  639. public function SetDictionaries($aDictionaries)
  640. {
  641. $this->m_aDictionaries = $aDictionaries;
  642. }
  643. public function GetDBHost()
  644. {
  645. return $this->m_sDBHost;
  646. }
  647. public function GetDBName()
  648. {
  649. return $this->m_sDBName;
  650. }
  651. public function GetDBSubname()
  652. {
  653. return $this->m_sDBSubname;
  654. }
  655. public function GetDBCharacterSet()
  656. {
  657. return $this->m_sDBCharacterSet;
  658. }
  659. public function GetDBCollation()
  660. {
  661. return $this->m_sDBCollation;
  662. }
  663. public function GetDBUser()
  664. {
  665. return $this->m_sDBUser;
  666. }
  667. public function GetDBPwd()
  668. {
  669. return $this->m_sDBPwd;
  670. }
  671. public function GetLogGlobal()
  672. {
  673. return $this->m_bLogGlobal;
  674. }
  675. public function GetLogNotification()
  676. {
  677. return $this->m_bLogNotification;
  678. }
  679. public function GetLogIssue()
  680. {
  681. return $this->m_bLogIssue;
  682. }
  683. public function GetLogWebService()
  684. {
  685. return $this->m_bLogWebService;
  686. }
  687. public function GetLogKPIDuration()
  688. {
  689. return $this->m_bLogKPIDuration;
  690. }
  691. public function GetLogKPIMemory()
  692. {
  693. return $this->m_bLogKPIMemory;
  694. }
  695. public function GetDebugQueries()
  696. {
  697. return $this->m_bDebugQueries;
  698. }
  699. public function GetQueryCacheEnabled()
  700. {
  701. return $this->m_bQueryCacheEnabled;
  702. }
  703. public function GetMinDisplayLimit()
  704. {
  705. return $this->m_iMinDisplayLimit;
  706. }
  707. public function GetMaxDisplayLimit()
  708. {
  709. return $this->m_iMaxDisplayLimit;
  710. }
  711. public function GetStandardReloadInterval()
  712. {
  713. return $this->m_iStandardReloadInterval;
  714. }
  715. public function GetFastReloadInterval()
  716. {
  717. return $this->m_iFastReloadInterval;
  718. }
  719. public function GetSecureConnectionRequired()
  720. {
  721. return $this->m_bSecureConnectionRequired;
  722. }
  723. public function GetHttpsHyperlinks()
  724. {
  725. return $this->m_bHttpsHyperlinks;
  726. }
  727. public function GetDefaultLanguage()
  728. {
  729. return $this->m_sDefaultLanguage;
  730. }
  731. public function GetEncryptionKey()
  732. {
  733. return $this->m_sEncryptionKey;
  734. }
  735. public function GetAllowedLoginTypes()
  736. {
  737. return explode('|', $this->m_sAllowedLoginTypes);
  738. }
  739. public function GetExternalAuthenticationVariable()
  740. {
  741. return $this->m_sExtAuthVariable;
  742. }
  743. public function GetCSVImportCharsets()
  744. {
  745. return $this->m_aCharsets;
  746. }
  747. public function SetDBHost($sDBHost)
  748. {
  749. $this->m_sDBHost = $sDBHost;
  750. }
  751. public function SetDBName($sDBName)
  752. {
  753. $this->m_sDBName = $sDBName;
  754. }
  755. public function SetDBSubname($sDBSubName)
  756. {
  757. $this->m_sDBSubname = $sDBSubName;
  758. }
  759. public function SetDBCharacterSet($sDBCharacterSet)
  760. {
  761. $this->m_sDBCharacterSet = $sDBCharacterSet;
  762. }
  763. public function SetDBCollation($sDBCollation)
  764. {
  765. $this->m_sDBCollation = $sDBCollation;
  766. }
  767. public function SetDBUser($sUser)
  768. {
  769. $this->m_sDBUser = $sUser;
  770. }
  771. public function SetDBPwd($sPwd)
  772. {
  773. $this->m_sDBPwd = $sPwd;
  774. }
  775. public function SetLogGlobal($iLogGlobal)
  776. {
  777. $this->m_iLogGlobal = $iLogGlobal;
  778. }
  779. public function SetLogNotification($iLogNotification)
  780. {
  781. $this->m_iLogNotification = $iLogNotification;
  782. }
  783. public function SetLogIssue($iLogIssue)
  784. {
  785. $this->m_iLogIssue = $iLogIssue;
  786. }
  787. public function SetLogWebService($iLogWebService)
  788. {
  789. $this->m_iLogWebService = $iLogWebService;
  790. }
  791. public function SetMinDisplayLimit($iMinDisplayLimit)
  792. {
  793. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  794. }
  795. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  796. {
  797. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  798. }
  799. public function SetStandardReloadInterval($iStandardReloadInterval)
  800. {
  801. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  802. }
  803. public function SetFastReloadInterval($iFastReloadInterval)
  804. {
  805. $this->m_iFastReloadInterval = $iFastReloadInterval;
  806. }
  807. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  808. {
  809. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  810. }
  811. public function SetHttpsHyperlinks($bHttpsHyperlinks)
  812. {
  813. $this->m_bHttpsHyperlinks = $bHttpsHyperlinks;
  814. }
  815. public function SetDefaultLanguage($sLanguageCode)
  816. {
  817. $this->m_sDefaultLanguage = $sLanguageCode;
  818. }
  819. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  820. {
  821. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  822. }
  823. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  824. {
  825. $this->m_sExtAuthVariable = $sExtAuthVariable;
  826. }
  827. public function SetEncryptionKey($sKey)
  828. {
  829. $this->m_sEncryptionKey = $sKey;
  830. }
  831. public function SetCSVImportCharsets($aCharsets)
  832. {
  833. $this->m_aCharsets = $aCharsets;
  834. }
  835. public function AddCSVImportCharset($sIconvCode, $sDisplayName)
  836. {
  837. $this->m_aCharsets[$sIconvCode] = $sDisplayName;
  838. }
  839. public function FileIsWritable()
  840. {
  841. return is_writable($this->m_sFile);
  842. }
  843. public function GetLoadedFile()
  844. {
  845. return $this->m_sFile;
  846. }
  847. /**
  848. * Render the configuration as an associative array
  849. * @return boolean True otherwise throws an Exception
  850. */
  851. public function ToArray()
  852. {
  853. $aSettings = array();
  854. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  855. {
  856. $aSettings[$sPropCode] = $aSettingInfo['value'];
  857. }
  858. $aSettings['db_host'] = $this->m_sDBHost;
  859. $aSettings['db_user'] = $this->m_sDBUser;
  860. $aSettings['db_pwd'] = $this->m_sDBPwd;
  861. $aSettings['db_name'] = $this->m_sDBName;
  862. $aSettings['db_subname'] = $this->m_sDBSubname;
  863. $aSettings['db_character_set'] = $this->m_sDBCharacterSet;
  864. $aSettings['db_collation'] = $this->m_sDBCollation;
  865. $aSettings['log_global'] = $this->m_bLogGlobal;
  866. $aSettings['log_notification'] = $this->m_bLogNotification;
  867. $aSettings['log_issue'] = $this->m_bLogIssue;
  868. $aSettings['log_web_service'] = $this->m_bLogWebService;
  869. $aSettings['min_display_limit'] = $this->m_iMinDisplayLimit;
  870. $aSettings['max_display_limit'] = $this->m_iMaxDisplayLimit;
  871. $aSettings['standard_reload_interval'] = $this->m_iStandardReloadInterval;
  872. $aSettings['fast_reload_interval'] = $this->m_iFastReloadInterval;
  873. $aSettings['secure_connection_required'] = $this->m_bSecureConnectionRequired;
  874. $aSettings['https_hyperlinks'] = $this->m_bHttpsHyperlinks;
  875. $aSettings['default_language'] = $this->m_sDefaultLanguage;
  876. $aSettings['allowed_login_types'] = $this->m_sAllowedLoginTypes;
  877. $aSettings['encryption_key'] = $this->m_sEncryptionKey;
  878. $aSettings['csv_import_charsets'] = $this->m_aCharsets;
  879. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  880. {
  881. foreach ($aProperties as $sProperty => $value)
  882. {
  883. $aSettings['module_settings'][$sModule][$sProperty] = $value;
  884. }
  885. }
  886. foreach($this->m_aAppModules as $sFile)
  887. {
  888. $aSettings['application_list'][] = $sFile;
  889. }
  890. foreach($this->m_aDataModels as $sFile)
  891. {
  892. $aSettings['datamodel_list'][] = $sFile;
  893. }
  894. foreach($this->m_aWebServiceCategories as $sFile)
  895. {
  896. $aSettings['webservice_list'][] = $sFile;
  897. }
  898. foreach($this->m_aAddons as $sKey => $sFile)
  899. {
  900. $aSettings['addon_list'][] = $sFile;
  901. }
  902. foreach($this->m_aDictionaries as $sFile)
  903. {
  904. $aSettings['dictionary_list'][] = $sFile;
  905. }
  906. return $aSettings;
  907. }
  908. /**
  909. * Write the configuration to a file (php format) that can be reloaded later
  910. * By default write to the same file that was specified when constructing the object
  911. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  912. * @return boolean True otherwise throws an Exception
  913. */
  914. public function WriteToFile($sFileName = '')
  915. {
  916. if (empty($sFileName))
  917. {
  918. $sFileName = $this->m_sFile;
  919. }
  920. $hFile = @fopen($sFileName, 'w');
  921. if ($hFile !== false)
  922. {
  923. fwrite($hFile, "<?php\n");
  924. fwrite($hFile, "\n/**\n");
  925. fwrite($hFile, " *\n");
  926. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  927. fwrite($hFile, " *\n");
  928. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  929. fwrite($hFile, " *\n");
  930. fwrite($hFile, " */\n");
  931. fwrite($hFile, "\n");
  932. fwrite($hFile, "\$MySettings = array(\n");
  933. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  934. {
  935. if ($aSettingInfo['show_in_conf_sample'])
  936. {
  937. $sType = $this->m_aSettings[$sPropCode]['type'];
  938. switch($sType)
  939. {
  940. case 'bool':
  941. $sSeenAs = $aSettingInfo['value'] ? '1' : '0';
  942. break;
  943. default:
  944. $sSeenAs = "'".addslashes($aSettingInfo['value'])."'";
  945. }
  946. fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
  947. }
  948. }
  949. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  950. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  951. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  952. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  953. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  954. fwrite($hFile, "\t'db_character_set' => '{$this->m_sDBCharacterSet}',\n");
  955. fwrite($hFile, "\t'db_collation' => '{$this->m_sDBCollation}',\n");
  956. fwrite($hFile, "\n");
  957. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  958. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  959. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  960. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  961. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  962. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  963. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  964. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  965. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  966. fwrite($hFile, "\t'https_hyperlinks' => ".($this->m_bHttpsHyperlinks ? 'true' : 'false').",\n");
  967. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  968. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  969. fwrite($hFile, "\t'encryption_key' => '{$this->m_sEncryptionKey}',\n");
  970. $sExport = var_export($this->m_aCharsets, true);
  971. fwrite($hFile, "\t'csv_import_charsets' => $sExport,\n");
  972. fwrite($hFile, ");\n");
  973. fwrite($hFile, "\n");
  974. fwrite($hFile, "\$MyModuleSettings = array(\n");
  975. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  976. {
  977. fwrite($hFile, "\t'$sModule' => array (\n");
  978. foreach ($aProperties as $sProperty => $value)
  979. {
  980. $sExport = var_export($value, true);
  981. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  982. }
  983. fwrite($hFile, "\t),\n");
  984. }
  985. fwrite($hFile, ");\n");
  986. fwrite($hFile, "\n/**\n");
  987. fwrite($hFile, " *\n");
  988. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  989. fwrite($hFile, " *\n");
  990. fwrite($hFile, " */\n");
  991. fwrite($hFile, "\$MyModules = array(\n");
  992. fwrite($hFile, "\t'application' => array (\n");
  993. foreach($this->m_aAppModules as $sFile)
  994. {
  995. fwrite($hFile, "\t\t'$sFile',\n");
  996. }
  997. fwrite($hFile, "\t),\n");
  998. fwrite($hFile, "\t'business' => array (\n");
  999. foreach($this->m_aDataModels as $sFile)
  1000. {
  1001. fwrite($hFile, "\t\t'$sFile',\n");
  1002. }
  1003. fwrite($hFile, "\t),\n");
  1004. fwrite($hFile, "\t'webservices' => array (\n");
  1005. foreach($this->m_aWebServiceCategories as $sFile)
  1006. {
  1007. fwrite($hFile, "\t\t'$sFile',\n");
  1008. }
  1009. fwrite($hFile, "\t),\n");
  1010. fwrite($hFile, "\t'addons' => array (\n");
  1011. foreach($this->m_aAddons as $sKey => $sFile)
  1012. {
  1013. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  1014. }
  1015. fwrite($hFile, "\t),\n");
  1016. fwrite($hFile, "\t'dictionaries' => array (\n");
  1017. foreach($this->m_aDictionaries as $sFile)
  1018. {
  1019. fwrite($hFile, "\t\t'$sFile',\n");
  1020. }
  1021. fwrite($hFile, "\t),\n");
  1022. fwrite($hFile, ");\n");
  1023. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  1024. return fclose($hFile);
  1025. }
  1026. else
  1027. {
  1028. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  1029. }
  1030. }
  1031. }
  1032. ?>