config.class.inc.php 21 KB

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