config.class.inc.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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_VERSION', '$ITOP_VERSION$');
  17. define('ITOP_REVISION', '$WCREV$');
  18. define('ITOP_BUILD_DATE', '$WCNOW$');
  19. /**
  20. * Configuration read/write
  21. *
  22. * @author Erwan Taloc <erwan.taloc@combodo.com>
  23. * @author Romain Quetiez <romain.quetiez@combodo.com>
  24. * @author Denis Flaven <denis.flaven@combodo.com>
  25. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  26. */
  27. require_once('coreexception.class.inc.php');
  28. class ConfigException extends CoreException
  29. {
  30. }
  31. define ('DEFAULT_LOG_GLOBAL', true);
  32. define ('DEFAULT_LOG_NOTIFICATION', true);
  33. define ('DEFAULT_LOG_ISSUE', true);
  34. define ('DEFAULT_LOG_WEB_SERVICE', true);
  35. define ('DEFAULT_MIN_DISPLAY_LIMIT', 10);
  36. define ('DEFAULT_MAX_DISPLAY_LIMIT', 15);
  37. define ('DEFAULT_STANDARD_RELOAD_INTERVAL', 5*60);
  38. define ('DEFAULT_FAST_RELOAD_INTERVAL', 1*60);
  39. define ('DEFAULT_SECURE_CONNECTION_REQUIRED', false);
  40. define ('DEFAULT_ALLOWED_LOGIN_TYPES', 'form|basic|external');
  41. define ('DEFAULT_EXT_AUTH_VARIABLE', '$_SERVER[\'REMOTE_USER\']');
  42. /**
  43. * Config
  44. * configuration data (this class cannot not be localized, because it is responsible for loading the dictionaries)
  45. *
  46. * @package iTopORM
  47. */
  48. class Config
  49. {
  50. //protected $m_bIsLoaded = false;
  51. protected $m_sFile = '';
  52. protected $m_aAppModules;
  53. protected $m_aDataModels;
  54. protected $m_aAddons;
  55. protected $m_aDictionaries;
  56. protected $m_aModuleSettings;
  57. protected $m_sDBHost;
  58. protected $m_sDBUser;
  59. protected $m_sDBPwd;
  60. protected $m_sDBName;
  61. protected $m_sDBSubname;
  62. /**
  63. * @var integer Event log options (see LOG_... definition)
  64. */
  65. protected $m_bLogGlobal;
  66. protected $m_bLogNotification;
  67. protected $m_bLogIssue;
  68. protected $m_bLogWebService;
  69. /**
  70. * @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
  71. */
  72. protected $m_iMinDisplayLimit;
  73. /**
  74. * @var integer Max number of elements before truncating the display
  75. */
  76. protected $m_iMaxDisplayLimit;
  77. /**
  78. * @var integer Number of seconds between two reloads of the display (standard)
  79. */
  80. protected $m_iStandardReloadInterval;
  81. /**
  82. * @var integer Number of seconds between two reloads of the display (fast)
  83. */
  84. protected $m_iFastReloadInterval;
  85. /**
  86. * @var boolean Whether or not a secure connection is required for using the application
  87. */
  88. protected $m_bSecureConnectionRequired;
  89. /**
  90. * @var string Langage code, default if the user language is undefined
  91. */
  92. protected $m_sDefaultLanguage;
  93. /**
  94. * @var string Type of login process allowed: form|basic|url|external
  95. */
  96. protected $m_sAllowedLoginTypes;
  97. /**
  98. * @var string Name of the PHP variable in which external authentication information is passed by the web server
  99. */
  100. protected $m_sExtAuthVariable;
  101. public function __construct($sConfigFile, $bLoadConfig = true)
  102. {
  103. $this->m_sFile = $sConfigFile;
  104. $this->m_aAppModules = array(
  105. // Some default modules, always present can be move to an official iTop Module later if needed
  106. '../application/transaction.class.inc.php',
  107. '../application/menunode.class.inc.php',
  108. '../application/user.preferences.class.inc.php',
  109. '../application/audit.rule.class.inc.php',
  110. // Romain - That's dirty, because those 3 classes are in fact part of the core
  111. // but I needed those classes to be derived from cmdbAbstractObject
  112. // (to be managed via the GUI) and this class in not really known from
  113. // the core, PLUS I needed the includes to be there also for the setup
  114. // to create the tables.
  115. '../core/event.class.inc.php',
  116. '../core/action.class.inc.php',
  117. '../core/trigger.class.inc.php',
  118. );
  119. $this->m_aDataModels = array();
  120. $this->m_aAddons = array(
  121. // Default AddOn, always present can be moved to an official iTop Module later if needed
  122. 'user rights' => '../addons/userrights/userrightsprofile.class.inc.php',
  123. );
  124. $this->m_aDictionaries = array(
  125. // Default dictionaries, always present can be moved to an official iTop Module later if needed
  126. '../dictionaries/dictionary.itop.core.php',
  127. '../dictionaries/dictionary.itop.ui.php', // Support for English
  128. '../dictionaries/fr.dictionary.itop.ui.php', // Support for French
  129. );
  130. $this->m_sDBHost = '';
  131. $this->m_sDBUser = '';
  132. $this->m_sDBPwd = '';
  133. $this->m_sDBName = '';
  134. $this->m_sDBSubname = '';
  135. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  136. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  137. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  138. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  139. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  140. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  141. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  142. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  143. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  144. $this->m_sDefaultLanguage = 'EN US';
  145. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  146. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  147. $this->m_aModuleSettings = array();
  148. if ($bLoadConfig)
  149. {
  150. $this->Load($sConfigFile);
  151. $this->Verify();
  152. }
  153. }
  154. protected function CheckFile($sPurpose, $sFileName)
  155. {
  156. if (!file_exists($sFileName))
  157. {
  158. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  159. }
  160. }
  161. protected function Load($sConfigFile)
  162. {
  163. $this->CheckFile('configuration', $sConfigFile);
  164. $sConfigCode = trim(file_get_contents($sConfigFile));
  165. // This does not work on several lines
  166. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  167. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  168. try
  169. {
  170. ob_start();
  171. eval('?'.'>'.trim($sConfigCode));
  172. $sNoise = trim(ob_get_contents());
  173. ob_end_clean();
  174. }
  175. catch (Exception $e)
  176. {
  177. // well, never reach in case of parsing error :-(
  178. // will be improved in PHP 6 ?
  179. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  180. }
  181. if (strlen($sNoise) > 0)
  182. {
  183. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  184. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise).'</tt>'));
  185. }
  186. if (!isset($MySettings) || !is_array($MySettings))
  187. {
  188. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  189. }
  190. if (!isset($MyModules) || !is_array($MyModules))
  191. {
  192. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  193. }
  194. if (!array_key_exists('application', $MyModules))
  195. {
  196. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  197. }
  198. if (!array_key_exists('business', $MyModules))
  199. {
  200. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  201. }
  202. if (!array_key_exists('addons', $MyModules))
  203. {
  204. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  205. }
  206. if (!array_key_exists('user rights', $MyModules['addons']))
  207. {
  208. $MyModules['addons']['user rights'] = '../addons/userrights/userrightsnull.class.inc.php';
  209. }
  210. if (!array_key_exists('dictionaries', $MyModules))
  211. {
  212. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  213. }
  214. $this->m_aAppModules = $MyModules['application'];
  215. $this->m_aDataModels = $MyModules['business'];
  216. $this->m_aAddons = $MyModules['addons'];
  217. $this->m_aDictionaries = $MyModules['dictionaries'];
  218. $this->m_sDBHost = trim($MySettings['db_host']);
  219. $this->m_sDBUser = trim($MySettings['db_user']);
  220. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  221. $this->m_sDBName = trim($MySettings['db_name']);
  222. $this->m_sDBSubname = trim($MySettings['db_subname']);
  223. $this->m_bLogGlobal = isset($MySettings['log_global']) ? trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  224. $this->m_bLogNotification = isset($MySettings['log_notification']) ? trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  225. $this->m_bLogIssue = isset($MySettings['log_issue']) ? trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  226. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  227. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  228. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  229. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  230. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  231. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  232. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  233. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  234. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  235. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  236. }
  237. protected function Verify()
  238. {
  239. foreach ($this->m_aAppModules as $sModule => $sToInclude)
  240. {
  241. $this->CheckFile('application module', $sToInclude);
  242. }
  243. foreach ($this->m_aDataModels as $sModule => $sToInclude)
  244. {
  245. $this->CheckFile('business model', $sToInclude);
  246. }
  247. foreach ($this->m_aAddons as $sModule => $sToInclude)
  248. {
  249. $this->CheckFile('addon module', $sToInclude);
  250. }
  251. foreach ($this->m_aDictionaries as $sModule => $sToInclude)
  252. {
  253. $this->CheckFile('dictionary', $sToInclude);
  254. }
  255. }
  256. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  257. {
  258. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  259. {
  260. return $this->m_aModuleSettings[$sModule][$sProperty];
  261. }
  262. return $defaultvalue;
  263. }
  264. public function SetModuleSetting($sModule, $sProperty, $value)
  265. {
  266. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  267. }
  268. public function GetAppModules()
  269. {
  270. return $this->m_aAppModules;
  271. }
  272. public function SetAppModules($aAppModules)
  273. {
  274. $this->m_aAppModules = $aAppModules;
  275. }
  276. public function GetDataModels()
  277. {
  278. return $this->m_aDataModels;
  279. }
  280. public function SetDataModels($aDataModels)
  281. {
  282. $this->m_aDataModels = $aDataModels;
  283. }
  284. public function GetAddons()
  285. {
  286. return $this->m_aAddons;
  287. }
  288. public function SetAddons($aAddons)
  289. {
  290. $this->m_aAddons = $aAddons;
  291. }
  292. public function GetDictionaries()
  293. {
  294. return $this->m_aDictionaries;
  295. }
  296. public function SetDictionaries($aDictionaries)
  297. {
  298. $this->m_aDictionaries = $aDictionaries;
  299. }
  300. public function GetDBHost()
  301. {
  302. return $this->m_sDBHost;
  303. }
  304. public function GetDBName()
  305. {
  306. return $this->m_sDBName;
  307. }
  308. public function GetDBSubname()
  309. {
  310. return $this->m_sDBSubname;
  311. }
  312. public function GetDBUser()
  313. {
  314. return $this->m_sDBUser;
  315. }
  316. public function GetDBPwd()
  317. {
  318. return $this->m_sDBPwd;
  319. }
  320. public function GetLogGlobal()
  321. {
  322. return $this->m_bLogGlobal;
  323. }
  324. public function GetLogNotification()
  325. {
  326. return $this->m_bLogNotification;
  327. }
  328. public function GetLogIssue()
  329. {
  330. return $this->m_bLogIssue;
  331. }
  332. public function GetLogWebService()
  333. {
  334. return $this->m_bLogWebService;
  335. }
  336. public function GetMinDisplayLimit()
  337. {
  338. return $this->m_iMinDisplayLimit;
  339. }
  340. public function GetMaxDisplayLimit()
  341. {
  342. return $this->m_iMaxDisplayLimit;
  343. }
  344. public function GetStandardReloadInterval()
  345. {
  346. return $this->m_iStandardReloadInterval;
  347. }
  348. public function GetFastReloadInterval()
  349. {
  350. return $this->m_iFastReloadInterval;
  351. }
  352. public function GetSecureConnectionRequired()
  353. {
  354. return $this->m_bSecureConnectionRequired;
  355. }
  356. public function GetDefaultLanguage()
  357. {
  358. return $this->m_sDefaultLanguage;
  359. }
  360. public function GetAllowedLoginTypes()
  361. {
  362. return explode('|', $this->m_sAllowedLoginTypes);
  363. }
  364. public function GetExternalAuthenticationVariable()
  365. {
  366. return $this->m_sExtAuthVariable;
  367. }
  368. public function SetDBHost($sDBHost)
  369. {
  370. $this->m_sDBHost = $sDBHost;
  371. }
  372. public function SetDBName($sDBName)
  373. {
  374. $this->m_sDBName = $sDBName;
  375. }
  376. public function SetDBSubname($sDBSubName)
  377. {
  378. $this->m_sDBSubname = $sDBSubName;
  379. }
  380. public function SetDBUser($sUser)
  381. {
  382. $this->m_sDBUser = $sUser;
  383. }
  384. public function SetDBPwd($sPwd)
  385. {
  386. $this->m_sDBPwd = $sPwd;
  387. }
  388. public function SetLogGlobal($iLogGlobal)
  389. {
  390. $this->m_iLogGlobal = $iLogGlobal;
  391. }
  392. public function SetLogNotification($iLogNotification)
  393. {
  394. $this->m_iLogNotification = $iLogNotification;
  395. }
  396. public function SetLogIssue($iLogIssue)
  397. {
  398. $this->m_iLogIssue = $iLogIssue;
  399. }
  400. public function SetLogWebService($iLogWebService)
  401. {
  402. $this->m_iLogWebService = $iLogWebService;
  403. }
  404. public function SetMinDisplayLimit($iMinDisplayLimit)
  405. {
  406. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  407. }
  408. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  409. {
  410. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  411. }
  412. public function SetStandardReloadInterval($iStandardReloadInterval)
  413. {
  414. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  415. }
  416. public function SetFastReloadInterval($iFastReloadInterval)
  417. {
  418. $this->m_iFastReloadInterval = $iFastReloadInterval;
  419. }
  420. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  421. {
  422. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  423. }
  424. public function SetDefaultLanguage($sLanguageCode)
  425. {
  426. $this->m_sDefaultLanguage = $sLanguageCode;
  427. }
  428. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  429. {
  430. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  431. }
  432. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  433. {
  434. $this->m_sExtAuthVariable = $sExtAuthVariable;
  435. }
  436. public function FileIsWritable()
  437. {
  438. return is_writable($this->m_sFile);
  439. }
  440. /**
  441. * Write the configuration to a file (php format) that can be reloaded later
  442. * By default write to the same file that was specified when constructing the object
  443. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  444. * @return boolean True otherwise throws an Exception
  445. */
  446. public function WriteToFile($sFileName = '')
  447. {
  448. if (empty($sFileName))
  449. {
  450. $sFileName = $this->m_sFile;
  451. }
  452. $hFile = @fopen($sFileName, 'w');
  453. if ($hFile !== false)
  454. {
  455. fwrite($hFile, "<?php\n");
  456. fwrite($hFile, "\n/**\n");
  457. fwrite($hFile, " *\n");
  458. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  459. fwrite($hFile, " *\n");
  460. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  461. fwrite($hFile, " *\n");
  462. fwrite($hFile, " */\n");
  463. fwrite($hFile, "\n");
  464. fwrite($hFile, "\$MySettings = array(\n");
  465. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  466. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  467. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  468. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  469. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  470. fwrite($hFile, "\n");
  471. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  472. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  473. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  474. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  475. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  476. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  477. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  478. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  479. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  480. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  481. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  482. fwrite($hFile, ");\n");
  483. fwrite($hFile, "\n");
  484. fwrite($hFile, "\$MyModuleSettings = array(\n");
  485. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  486. {
  487. fwrite($hFile, "\t'$sModule' => array (\n");
  488. foreach ($aProperties as $sProperty => $value)
  489. {
  490. $sExport = var_export($value, true);
  491. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  492. }
  493. fwrite($hFile, "\t),\n");
  494. }
  495. fwrite($hFile, ");\n");
  496. fwrite($hFile, "\n/**\n");
  497. fwrite($hFile, " *\n");
  498. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  499. fwrite($hFile, " *\n");
  500. fwrite($hFile, " */\n");
  501. fwrite($hFile, "\$MyModules = array(\n");
  502. fwrite($hFile, "\t'application' => array (\n");
  503. foreach($this->m_aAppModules as $sFile)
  504. {
  505. fwrite($hFile, "\t\t'$sFile',\n");
  506. }
  507. fwrite($hFile, "\t),\n");
  508. fwrite($hFile, "\t'business' => array (\n");
  509. foreach($this->m_aDataModels as $sFile)
  510. {
  511. fwrite($hFile, "\t\t'$sFile',\n");
  512. }
  513. fwrite($hFile, "\t),\n");
  514. fwrite($hFile, "\t'addons' => array (\n");
  515. foreach($this->m_aAddons as $sKey => $sFile)
  516. {
  517. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  518. }
  519. fwrite($hFile, "\t),\n");
  520. fwrite($hFile, "\t'dictionaries' => array (\n");
  521. foreach($this->m_aDictionaries as $sFile)
  522. {
  523. fwrite($hFile, "\t\t'$sFile',\n");
  524. }
  525. fwrite($hFile, "\t),\n");
  526. fwrite($hFile, ");\n");
  527. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  528. return fclose($hFile);
  529. }
  530. else
  531. {
  532. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  533. }
  534. }
  535. }
  536. ?>