config.class.inc.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  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. );
  442. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  443. {
  444. $this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
  445. }
  446. $this->m_sDBHost = '';
  447. $this->m_sDBUser = '';
  448. $this->m_sDBPwd = '';
  449. $this->m_sDBName = '';
  450. $this->m_sDBSubname = '';
  451. $this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
  452. $this->m_sDBCollation = DEFAULT_COLLATION;
  453. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  454. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  455. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  456. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  457. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  458. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  459. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  460. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  461. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  462. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  463. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  464. $this->m_bHttpsHyperlinks = DEFAULT_HTTPS_HYPERLINKS;
  465. $this->m_sDefaultLanguage = 'EN US';
  466. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  467. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  468. $this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
  469. $this->m_aCharsets = array();
  470. $this->m_aModuleSettings = array();
  471. if ($bLoadConfig)
  472. {
  473. $this->Load($sConfigFile);
  474. $this->Verify();
  475. }
  476. }
  477. protected function CheckFile($sPurpose, $sFileName)
  478. {
  479. if (!file_exists($sFileName))
  480. {
  481. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  482. }
  483. }
  484. protected function Load($sConfigFile)
  485. {
  486. $this->CheckFile('configuration', $sConfigFile);
  487. $sConfigCode = trim(file_get_contents($sConfigFile));
  488. // This does not work on several lines
  489. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  490. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  491. try
  492. {
  493. ob_start();
  494. eval('?'.'>'.trim($sConfigCode));
  495. $sNoise = trim(ob_get_contents());
  496. ob_end_clean();
  497. }
  498. catch (Exception $e)
  499. {
  500. // well, never reach in case of parsing error :-(
  501. // will be improved in PHP 6 ?
  502. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  503. }
  504. if (strlen($sNoise) > 0)
  505. {
  506. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  507. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').'</tt>'));
  508. }
  509. if (!isset($MySettings) || !is_array($MySettings))
  510. {
  511. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  512. }
  513. if (!isset($MyModules) || !is_array($MyModules))
  514. {
  515. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  516. }
  517. if (!array_key_exists('application', $MyModules))
  518. {
  519. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  520. }
  521. if (!array_key_exists('business', $MyModules))
  522. {
  523. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  524. }
  525. if (!array_key_exists('addons', $MyModules))
  526. {
  527. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  528. }
  529. if (!array_key_exists('user rights', $MyModules['addons']))
  530. {
  531. // Add one, by default
  532. $MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
  533. }
  534. if (!array_key_exists('dictionaries', $MyModules))
  535. {
  536. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  537. }
  538. $this->m_aAppModules = $MyModules['application'];
  539. $this->m_aDataModels = $MyModules['business'];
  540. if (isset($MyModules['webservices']))
  541. {
  542. $this->m_aWebServiceCategories = $MyModules['webservices'];
  543. }
  544. $this->m_aAddons = $MyModules['addons'];
  545. $this->m_aDictionaries = $MyModules['dictionaries'];
  546. foreach($MySettings as $sPropCode => $rawvalue)
  547. {
  548. if ($this->IsProperty($sPropCode))
  549. {
  550. $value = trim($rawvalue);
  551. $this->Set($sPropCode, $value, $sConfigFile);
  552. }
  553. }
  554. $this->m_sDBHost = trim($MySettings['db_host']);
  555. $this->m_sDBUser = trim($MySettings['db_user']);
  556. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  557. $this->m_sDBName = trim($MySettings['db_name']);
  558. $this->m_sDBSubname = trim($MySettings['db_subname']);
  559. $this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
  560. $this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
  561. $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  562. $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  563. $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  564. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  565. $this->m_bLogKPIDuration = isset($MySettings['log_kpi_duration']) ? (bool) trim($MySettings['log_kpi_duration']) : DEFAULT_LOG_KPI_DURATION;
  566. $this->m_bLogKPIMemory = isset($MySettings['log_kpi_memory']) ? (bool) trim($MySettings['log_kpi_memory']) : DEFAULT_LOG_KPI_MEMORY;
  567. $this->m_bDebugQueries = isset($MySettings['debug_queries']) ? (bool) trim($MySettings['debug_queries']) : DEFAULT_DEBUG_QUERIES;
  568. $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
  569. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  570. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  571. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  572. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  573. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  574. $this->m_bHttpsHyperlinks = isset($MySettings['https_hyperlinks']) ? (bool) trim($MySettings['https_hyperlinks']) : DEFAULT_HTTPS_HYPERLINKS;
  575. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  576. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  577. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  578. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  579. $this->m_sEncryptionKey = isset($MySettings['encryption_key']) ? trim($MySettings['encryption_key']) : DEFAULT_ENCRYPTION_KEY;
  580. $this->m_aCharsets = isset($MySettings['csv_import_charsets']) ? $MySettings['csv_import_charsets'] : array();
  581. }
  582. protected function Verify()
  583. {
  584. // Files are verified later on, just before using them -see MetaModel::Plugin()
  585. // (we have their final path at that point)
  586. }
  587. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  588. {
  589. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  590. {
  591. return $this->m_aModuleSettings[$sModule][$sProperty];
  592. }
  593. return $defaultvalue;
  594. }
  595. public function SetModuleSetting($sModule, $sProperty, $value)
  596. {
  597. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  598. }
  599. public function GetAppModules()
  600. {
  601. return $this->m_aAppModules;
  602. }
  603. public function SetAppModules($aAppModules)
  604. {
  605. $this->m_aAppModules = $aAppModules;
  606. }
  607. public function GetDataModels()
  608. {
  609. return $this->m_aDataModels;
  610. }
  611. public function SetDataModels($aDataModels)
  612. {
  613. $this->m_aDataModels = $aDataModels;
  614. }
  615. public function GetWebServiceCategories()
  616. {
  617. return $this->m_aWebServiceCategories;
  618. }
  619. public function SetWebServiceCategories($aWebServiceCategories)
  620. {
  621. $this->m_aWebServiceCategories = $aWebServiceCategories;
  622. }
  623. public function GetAddons()
  624. {
  625. return $this->m_aAddons;
  626. }
  627. public function SetAddons($aAddons)
  628. {
  629. $this->m_aAddons = $aAddons;
  630. }
  631. public function GetDictionaries()
  632. {
  633. return $this->m_aDictionaries;
  634. }
  635. public function SetDictionaries($aDictionaries)
  636. {
  637. $this->m_aDictionaries = $aDictionaries;
  638. }
  639. public function GetDBHost()
  640. {
  641. return $this->m_sDBHost;
  642. }
  643. public function GetDBName()
  644. {
  645. return $this->m_sDBName;
  646. }
  647. public function GetDBSubname()
  648. {
  649. return $this->m_sDBSubname;
  650. }
  651. public function GetDBCharacterSet()
  652. {
  653. return $this->m_sDBCharacterSet;
  654. }
  655. public function GetDBCollation()
  656. {
  657. return $this->m_sDBCollation;
  658. }
  659. public function GetDBUser()
  660. {
  661. return $this->m_sDBUser;
  662. }
  663. public function GetDBPwd()
  664. {
  665. return $this->m_sDBPwd;
  666. }
  667. public function GetLogGlobal()
  668. {
  669. return $this->m_bLogGlobal;
  670. }
  671. public function GetLogNotification()
  672. {
  673. return $this->m_bLogNotification;
  674. }
  675. public function GetLogIssue()
  676. {
  677. return $this->m_bLogIssue;
  678. }
  679. public function GetLogWebService()
  680. {
  681. return $this->m_bLogWebService;
  682. }
  683. public function GetLogKPIDuration()
  684. {
  685. return $this->m_bLogKPIDuration;
  686. }
  687. public function GetLogKPIMemory()
  688. {
  689. return $this->m_bLogKPIMemory;
  690. }
  691. public function GetDebugQueries()
  692. {
  693. return $this->m_bDebugQueries;
  694. }
  695. public function GetQueryCacheEnabled()
  696. {
  697. return $this->m_bQueryCacheEnabled;
  698. }
  699. public function GetMinDisplayLimit()
  700. {
  701. return $this->m_iMinDisplayLimit;
  702. }
  703. public function GetMaxDisplayLimit()
  704. {
  705. return $this->m_iMaxDisplayLimit;
  706. }
  707. public function GetStandardReloadInterval()
  708. {
  709. return $this->m_iStandardReloadInterval;
  710. }
  711. public function GetFastReloadInterval()
  712. {
  713. return $this->m_iFastReloadInterval;
  714. }
  715. public function GetSecureConnectionRequired()
  716. {
  717. return $this->m_bSecureConnectionRequired;
  718. }
  719. public function GetHttpsHyperlinks()
  720. {
  721. return $this->m_bHttpsHyperlinks;
  722. }
  723. public function GetDefaultLanguage()
  724. {
  725. return $this->m_sDefaultLanguage;
  726. }
  727. public function GetEncryptionKey()
  728. {
  729. return $this->m_sEncryptionKey;
  730. }
  731. public function GetAllowedLoginTypes()
  732. {
  733. return explode('|', $this->m_sAllowedLoginTypes);
  734. }
  735. public function GetExternalAuthenticationVariable()
  736. {
  737. return $this->m_sExtAuthVariable;
  738. }
  739. public function GetCSVImportCharsets()
  740. {
  741. return $this->m_aCharsets;
  742. }
  743. public function SetDBHost($sDBHost)
  744. {
  745. $this->m_sDBHost = $sDBHost;
  746. }
  747. public function SetDBName($sDBName)
  748. {
  749. $this->m_sDBName = $sDBName;
  750. }
  751. public function SetDBSubname($sDBSubName)
  752. {
  753. $this->m_sDBSubname = $sDBSubName;
  754. }
  755. public function SetDBCharacterSet($sDBCharacterSet)
  756. {
  757. $this->m_sDBCharacterSet = $sDBCharacterSet;
  758. }
  759. public function SetDBCollation($sDBCollation)
  760. {
  761. $this->m_sDBCollation = $sDBCollation;
  762. }
  763. public function SetDBUser($sUser)
  764. {
  765. $this->m_sDBUser = $sUser;
  766. }
  767. public function SetDBPwd($sPwd)
  768. {
  769. $this->m_sDBPwd = $sPwd;
  770. }
  771. public function SetLogGlobal($iLogGlobal)
  772. {
  773. $this->m_iLogGlobal = $iLogGlobal;
  774. }
  775. public function SetLogNotification($iLogNotification)
  776. {
  777. $this->m_iLogNotification = $iLogNotification;
  778. }
  779. public function SetLogIssue($iLogIssue)
  780. {
  781. $this->m_iLogIssue = $iLogIssue;
  782. }
  783. public function SetLogWebService($iLogWebService)
  784. {
  785. $this->m_iLogWebService = $iLogWebService;
  786. }
  787. public function SetMinDisplayLimit($iMinDisplayLimit)
  788. {
  789. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  790. }
  791. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  792. {
  793. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  794. }
  795. public function SetStandardReloadInterval($iStandardReloadInterval)
  796. {
  797. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  798. }
  799. public function SetFastReloadInterval($iFastReloadInterval)
  800. {
  801. $this->m_iFastReloadInterval = $iFastReloadInterval;
  802. }
  803. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  804. {
  805. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  806. }
  807. public function SetHttpsHyperlinks($bHttpsHyperlinks)
  808. {
  809. $this->m_bHttpsHyperlinks = $bHttpsHyperlinks;
  810. }
  811. public function SetDefaultLanguage($sLanguageCode)
  812. {
  813. $this->m_sDefaultLanguage = $sLanguageCode;
  814. }
  815. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  816. {
  817. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  818. }
  819. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  820. {
  821. $this->m_sExtAuthVariable = $sExtAuthVariable;
  822. }
  823. public function SetEncryptionKey($sKey)
  824. {
  825. $this->m_sEncryptionKey = $sKey;
  826. }
  827. public function SetCSVImportCharsets($aCharsets)
  828. {
  829. $this->m_aCharsets = $aCharsets;
  830. }
  831. public function AddCSVImportCharset($sIconvCode, $sDisplayName)
  832. {
  833. $this->m_aCharsets[$sIconvCode] = $sDisplayName;
  834. }
  835. public function FileIsWritable()
  836. {
  837. return is_writable($this->m_sFile);
  838. }
  839. public function GetLoadedFile()
  840. {
  841. return $this->m_sFile;
  842. }
  843. /**
  844. * Render the configuration as an associative array
  845. * @return boolean True otherwise throws an Exception
  846. */
  847. public function ToArray()
  848. {
  849. $aSettings = array();
  850. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  851. {
  852. $aSettings[$sPropCode] = $aSettingInfo['value'];
  853. }
  854. $aSettings['db_host'] = $this->m_sDBHost;
  855. $aSettings['db_user'] = $this->m_sDBUser;
  856. $aSettings['db_pwd'] = $this->m_sDBPwd;
  857. $aSettings['db_name'] = $this->m_sDBName;
  858. $aSettings['db_subname'] = $this->m_sDBSubname;
  859. $aSettings['db_character_set'] = $this->m_sDBCharacterSet;
  860. $aSettings['db_collation'] = $this->m_sDBCollation;
  861. $aSettings['log_global'] = $this->m_bLogGlobal;
  862. $aSettings['log_notification'] = $this->m_bLogNotification;
  863. $aSettings['log_issue'] = $this->m_bLogIssue;
  864. $aSettings['log_web_service'] = $this->m_bLogWebService;
  865. $aSettings['min_display_limit'] = $this->m_iMinDisplayLimit;
  866. $aSettings['max_display_limit'] = $this->m_iMaxDisplayLimit;
  867. $aSettings['standard_reload_interval'] = $this->m_iStandardReloadInterval;
  868. $aSettings['fast_reload_interval'] = $this->m_iFastReloadInterval;
  869. $aSettings['secure_connection_required'] = $this->m_bSecureConnectionRequired;
  870. $aSettings['https_hyperlinks'] = $this->m_bHttpsHyperlinks;
  871. $aSettings['default_language'] = $this->m_sDefaultLanguage;
  872. $aSettings['allowed_login_types'] = $this->m_sAllowedLoginTypes;
  873. $aSettings['encryption_key'] = $this->m_sEncryptionKey;
  874. $aSettings['csv_import_charsets'] = $this->m_aCharsets;
  875. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  876. {
  877. foreach ($aProperties as $sProperty => $value)
  878. {
  879. $aSettings['module_settings'][$sModule][$sProperty] = $value;
  880. }
  881. }
  882. foreach($this->m_aAppModules as $sFile)
  883. {
  884. $aSettings['application_list'][] = $sFile;
  885. }
  886. foreach($this->m_aDataModels as $sFile)
  887. {
  888. $aSettings['datamodel_list'][] = $sFile;
  889. }
  890. foreach($this->m_aWebServiceCategories as $sFile)
  891. {
  892. $aSettings['webservice_list'][] = $sFile;
  893. }
  894. foreach($this->m_aAddons as $sKey => $sFile)
  895. {
  896. $aSettings['addon_list'][] = $sFile;
  897. }
  898. foreach($this->m_aDictionaries as $sFile)
  899. {
  900. $aSettings['dictionary_list'][] = $sFile;
  901. }
  902. return $aSettings;
  903. }
  904. /**
  905. * Write the configuration to a file (php format) that can be reloaded later
  906. * By default write to the same file that was specified when constructing the object
  907. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  908. * @return boolean True otherwise throws an Exception
  909. */
  910. public function WriteToFile($sFileName = '')
  911. {
  912. if (empty($sFileName))
  913. {
  914. $sFileName = $this->m_sFile;
  915. }
  916. $hFile = @fopen($sFileName, 'w');
  917. if ($hFile !== false)
  918. {
  919. fwrite($hFile, "<?php\n");
  920. fwrite($hFile, "\n/**\n");
  921. fwrite($hFile, " *\n");
  922. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  923. fwrite($hFile, " *\n");
  924. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  925. fwrite($hFile, " *\n");
  926. fwrite($hFile, " */\n");
  927. fwrite($hFile, "\n");
  928. fwrite($hFile, "\$MySettings = array(\n");
  929. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  930. {
  931. if ($aSettingInfo['show_in_conf_sample'])
  932. {
  933. $sType = $this->m_aSettings[$sPropCode]['type'];
  934. switch($sType)
  935. {
  936. case 'bool':
  937. $sSeenAs = $aSettingInfo['value'] ? '1' : '0';
  938. break;
  939. default:
  940. $sSeenAs = "'".addslashes($aSettingInfo['value'])."'";
  941. }
  942. fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
  943. }
  944. }
  945. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  946. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  947. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  948. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  949. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  950. fwrite($hFile, "\t'db_character_set' => '{$this->m_sDBCharacterSet}',\n");
  951. fwrite($hFile, "\t'db_collation' => '{$this->m_sDBCollation}',\n");
  952. fwrite($hFile, "\n");
  953. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  954. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  955. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  956. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  957. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  958. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  959. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  960. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  961. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  962. fwrite($hFile, "\t'https_hyperlinks' => ".($this->m_bHttpsHyperlinks ? 'true' : 'false').",\n");
  963. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  964. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  965. fwrite($hFile, "\t'encryption_key' => '{$this->m_sEncryptionKey}',\n");
  966. $sExport = var_export($this->m_aCharsets, true);
  967. fwrite($hFile, "\t'csv_import_charsets' => $sExport,\n");
  968. fwrite($hFile, ");\n");
  969. fwrite($hFile, "\n");
  970. fwrite($hFile, "\$MyModuleSettings = array(\n");
  971. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  972. {
  973. fwrite($hFile, "\t'$sModule' => array (\n");
  974. foreach ($aProperties as $sProperty => $value)
  975. {
  976. $sExport = var_export($value, true);
  977. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  978. }
  979. fwrite($hFile, "\t),\n");
  980. }
  981. fwrite($hFile, ");\n");
  982. fwrite($hFile, "\n/**\n");
  983. fwrite($hFile, " *\n");
  984. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  985. fwrite($hFile, " *\n");
  986. fwrite($hFile, " */\n");
  987. fwrite($hFile, "\$MyModules = array(\n");
  988. fwrite($hFile, "\t'application' => array (\n");
  989. foreach($this->m_aAppModules as $sFile)
  990. {
  991. fwrite($hFile, "\t\t'$sFile',\n");
  992. }
  993. fwrite($hFile, "\t),\n");
  994. fwrite($hFile, "\t'business' => array (\n");
  995. foreach($this->m_aDataModels as $sFile)
  996. {
  997. fwrite($hFile, "\t\t'$sFile',\n");
  998. }
  999. fwrite($hFile, "\t),\n");
  1000. fwrite($hFile, "\t'webservices' => array (\n");
  1001. foreach($this->m_aWebServiceCategories as $sFile)
  1002. {
  1003. fwrite($hFile, "\t\t'$sFile',\n");
  1004. }
  1005. fwrite($hFile, "\t),\n");
  1006. fwrite($hFile, "\t'addons' => array (\n");
  1007. foreach($this->m_aAddons as $sKey => $sFile)
  1008. {
  1009. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  1010. }
  1011. fwrite($hFile, "\t),\n");
  1012. fwrite($hFile, "\t'dictionaries' => array (\n");
  1013. foreach($this->m_aDictionaries as $sFile)
  1014. {
  1015. fwrite($hFile, "\t\t'$sFile',\n");
  1016. }
  1017. fwrite($hFile, "\t),\n");
  1018. fwrite($hFile, ");\n");
  1019. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  1020. return fclose($hFile);
  1021. }
  1022. else
  1023. {
  1024. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  1025. }
  1026. }
  1027. }
  1028. ?>