config.class.inc.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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. );
  139. $this->m_sDBHost = '';
  140. $this->m_sDBUser = '';
  141. $this->m_sDBPwd = '';
  142. $this->m_sDBName = '';
  143. $this->m_sDBSubname = '';
  144. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  145. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  146. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  147. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  148. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  149. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  150. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  151. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  152. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  153. $this->m_bHttpsHyperlinks = DEFAULT_HTTPS_HYPERLINKS;
  154. $this->m_sDefaultLanguage = 'EN US';
  155. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  156. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  157. $this->m_aModuleSettings = array();
  158. if ($bLoadConfig)
  159. {
  160. $this->Load($sConfigFile);
  161. $this->Verify();
  162. }
  163. }
  164. protected function CheckFile($sPurpose, $sFileName)
  165. {
  166. if (!file_exists($sFileName))
  167. {
  168. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  169. }
  170. }
  171. protected function Load($sConfigFile)
  172. {
  173. $this->CheckFile('configuration', $sConfigFile);
  174. $sConfigCode = trim(file_get_contents($sConfigFile));
  175. // This does not work on several lines
  176. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  177. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  178. try
  179. {
  180. ob_start();
  181. eval('?'.'>'.trim($sConfigCode));
  182. $sNoise = trim(ob_get_contents());
  183. ob_end_clean();
  184. }
  185. catch (Exception $e)
  186. {
  187. // well, never reach in case of parsing error :-(
  188. // will be improved in PHP 6 ?
  189. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  190. }
  191. if (strlen($sNoise) > 0)
  192. {
  193. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  194. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise).'</tt>'));
  195. }
  196. if (!isset($MySettings) || !is_array($MySettings))
  197. {
  198. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  199. }
  200. if (!isset($MyModules) || !is_array($MyModules))
  201. {
  202. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  203. }
  204. if (!array_key_exists('application', $MyModules))
  205. {
  206. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  207. }
  208. if (!array_key_exists('business', $MyModules))
  209. {
  210. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  211. }
  212. if (!array_key_exists('addons', $MyModules))
  213. {
  214. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  215. }
  216. if (!array_key_exists('user rights', $MyModules['addons']))
  217. {
  218. $MyModules['addons']['user rights'] = '../addons/userrights/userrightsnull.class.inc.php';
  219. }
  220. if (!array_key_exists('dictionaries', $MyModules))
  221. {
  222. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  223. }
  224. $this->m_aAppModules = $MyModules['application'];
  225. $this->m_aDataModels = $MyModules['business'];
  226. $this->m_aAddons = $MyModules['addons'];
  227. $this->m_aDictionaries = $MyModules['dictionaries'];
  228. $this->m_sDBHost = trim($MySettings['db_host']);
  229. $this->m_sDBUser = trim($MySettings['db_user']);
  230. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  231. $this->m_sDBName = trim($MySettings['db_name']);
  232. $this->m_sDBSubname = trim($MySettings['db_subname']);
  233. $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  234. $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  235. $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  236. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  237. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  238. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  239. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  240. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  241. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  242. $this->m_bHttpsHyperlinks = isset($MySettings['https_hyperlinks']) ? (bool) trim($MySettings['https_hyperlinks']) : DEFAULT_HTTPS_HYPERLINKS;
  243. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  244. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  245. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  246. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  247. }
  248. protected function Verify()
  249. {
  250. foreach ($this->m_aAppModules as $sModule => $sToInclude)
  251. {
  252. $this->CheckFile('application module', $sToInclude);
  253. }
  254. foreach ($this->m_aDataModels as $sModule => $sToInclude)
  255. {
  256. $this->CheckFile('business model', $sToInclude);
  257. }
  258. foreach ($this->m_aAddons as $sModule => $sToInclude)
  259. {
  260. $this->CheckFile('addon module', $sToInclude);
  261. }
  262. foreach ($this->m_aDictionaries as $sModule => $sToInclude)
  263. {
  264. $this->CheckFile('dictionary', $sToInclude);
  265. }
  266. }
  267. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  268. {
  269. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  270. {
  271. return $this->m_aModuleSettings[$sModule][$sProperty];
  272. }
  273. return $defaultvalue;
  274. }
  275. public function SetModuleSetting($sModule, $sProperty, $value)
  276. {
  277. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  278. }
  279. public function GetAppModules()
  280. {
  281. return $this->m_aAppModules;
  282. }
  283. public function SetAppModules($aAppModules)
  284. {
  285. $this->m_aAppModules = $aAppModules;
  286. }
  287. public function GetDataModels()
  288. {
  289. return $this->m_aDataModels;
  290. }
  291. public function SetDataModels($aDataModels)
  292. {
  293. $this->m_aDataModels = $aDataModels;
  294. }
  295. public function GetAddons()
  296. {
  297. return $this->m_aAddons;
  298. }
  299. public function SetAddons($aAddons)
  300. {
  301. $this->m_aAddons = $aAddons;
  302. }
  303. public function GetDictionaries()
  304. {
  305. return $this->m_aDictionaries;
  306. }
  307. public function SetDictionaries($aDictionaries)
  308. {
  309. $this->m_aDictionaries = $aDictionaries;
  310. }
  311. public function GetDBHost()
  312. {
  313. return $this->m_sDBHost;
  314. }
  315. public function GetDBName()
  316. {
  317. return $this->m_sDBName;
  318. }
  319. public function GetDBSubname()
  320. {
  321. return $this->m_sDBSubname;
  322. }
  323. public function GetDBUser()
  324. {
  325. return $this->m_sDBUser;
  326. }
  327. public function GetDBPwd()
  328. {
  329. return $this->m_sDBPwd;
  330. }
  331. public function GetLogGlobal()
  332. {
  333. return $this->m_bLogGlobal;
  334. }
  335. public function GetLogNotification()
  336. {
  337. return $this->m_bLogNotification;
  338. }
  339. public function GetLogIssue()
  340. {
  341. return $this->m_bLogIssue;
  342. }
  343. public function GetLogWebService()
  344. {
  345. return $this->m_bLogWebService;
  346. }
  347. public function GetMinDisplayLimit()
  348. {
  349. return $this->m_iMinDisplayLimit;
  350. }
  351. public function GetMaxDisplayLimit()
  352. {
  353. return $this->m_iMaxDisplayLimit;
  354. }
  355. public function GetStandardReloadInterval()
  356. {
  357. return $this->m_iStandardReloadInterval;
  358. }
  359. public function GetFastReloadInterval()
  360. {
  361. return $this->m_iFastReloadInterval;
  362. }
  363. public function GetSecureConnectionRequired()
  364. {
  365. return $this->m_bSecureConnectionRequired;
  366. }
  367. public function GetHttpsHyperlinks()
  368. {
  369. return $this->m_bHttpsHyperlinks;
  370. }
  371. public function GetDefaultLanguage()
  372. {
  373. return $this->m_sDefaultLanguage;
  374. }
  375. public function GetAllowedLoginTypes()
  376. {
  377. return explode('|', $this->m_sAllowedLoginTypes);
  378. }
  379. public function GetExternalAuthenticationVariable()
  380. {
  381. return $this->m_sExtAuthVariable;
  382. }
  383. public function SetDBHost($sDBHost)
  384. {
  385. $this->m_sDBHost = $sDBHost;
  386. }
  387. public function SetDBName($sDBName)
  388. {
  389. $this->m_sDBName = $sDBName;
  390. }
  391. public function SetDBSubname($sDBSubName)
  392. {
  393. $this->m_sDBSubname = $sDBSubName;
  394. }
  395. public function SetDBUser($sUser)
  396. {
  397. $this->m_sDBUser = $sUser;
  398. }
  399. public function SetDBPwd($sPwd)
  400. {
  401. $this->m_sDBPwd = $sPwd;
  402. }
  403. public function SetLogGlobal($iLogGlobal)
  404. {
  405. $this->m_iLogGlobal = $iLogGlobal;
  406. }
  407. public function SetLogNotification($iLogNotification)
  408. {
  409. $this->m_iLogNotification = $iLogNotification;
  410. }
  411. public function SetLogIssue($iLogIssue)
  412. {
  413. $this->m_iLogIssue = $iLogIssue;
  414. }
  415. public function SetLogWebService($iLogWebService)
  416. {
  417. $this->m_iLogWebService = $iLogWebService;
  418. }
  419. public function SetMinDisplayLimit($iMinDisplayLimit)
  420. {
  421. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  422. }
  423. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  424. {
  425. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  426. }
  427. public function SetStandardReloadInterval($iStandardReloadInterval)
  428. {
  429. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  430. }
  431. public function SetFastReloadInterval($iFastReloadInterval)
  432. {
  433. $this->m_iFastReloadInterval = $iFastReloadInterval;
  434. }
  435. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  436. {
  437. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  438. }
  439. public function SetHttpsHyperlinks($bHttpsHyperlinks)
  440. {
  441. $this->m_bHttpsHyperlinks = $bHttpsHyperlinks;
  442. }
  443. public function SetDefaultLanguage($sLanguageCode)
  444. {
  445. $this->m_sDefaultLanguage = $sLanguageCode;
  446. }
  447. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  448. {
  449. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  450. }
  451. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  452. {
  453. $this->m_sExtAuthVariable = $sExtAuthVariable;
  454. }
  455. public function FileIsWritable()
  456. {
  457. return is_writable($this->m_sFile);
  458. }
  459. /**
  460. * Write the configuration to a file (php format) that can be reloaded later
  461. * By default write to the same file that was specified when constructing the object
  462. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  463. * @return boolean True otherwise throws an Exception
  464. */
  465. public function WriteToFile($sFileName = '')
  466. {
  467. if (empty($sFileName))
  468. {
  469. $sFileName = $this->m_sFile;
  470. }
  471. $hFile = @fopen($sFileName, 'w');
  472. if ($hFile !== false)
  473. {
  474. fwrite($hFile, "<?php\n");
  475. fwrite($hFile, "\n/**\n");
  476. fwrite($hFile, " *\n");
  477. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  478. fwrite($hFile, " *\n");
  479. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  480. fwrite($hFile, " *\n");
  481. fwrite($hFile, " */\n");
  482. fwrite($hFile, "\n");
  483. fwrite($hFile, "\$MySettings = array(\n");
  484. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  485. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  486. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  487. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  488. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  489. fwrite($hFile, "\n");
  490. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  491. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  492. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  493. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  494. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  495. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  496. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  497. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  498. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  499. fwrite($hFile, "\t'https_hyperlinks' => ".($this->m_bHttpsHyperlinks ? 'true' : 'false').",\n");
  500. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  501. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  502. fwrite($hFile, ");\n");
  503. fwrite($hFile, "\n");
  504. fwrite($hFile, "\$MyModuleSettings = array(\n");
  505. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  506. {
  507. fwrite($hFile, "\t'$sModule' => array (\n");
  508. foreach ($aProperties as $sProperty => $value)
  509. {
  510. $sExport = var_export($value, true);
  511. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  512. }
  513. fwrite($hFile, "\t),\n");
  514. }
  515. fwrite($hFile, ");\n");
  516. fwrite($hFile, "\n/**\n");
  517. fwrite($hFile, " *\n");
  518. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  519. fwrite($hFile, " *\n");
  520. fwrite($hFile, " */\n");
  521. fwrite($hFile, "\$MyModules = array(\n");
  522. fwrite($hFile, "\t'application' => array (\n");
  523. foreach($this->m_aAppModules as $sFile)
  524. {
  525. fwrite($hFile, "\t\t'$sFile',\n");
  526. }
  527. fwrite($hFile, "\t),\n");
  528. fwrite($hFile, "\t'business' => array (\n");
  529. foreach($this->m_aDataModels as $sFile)
  530. {
  531. fwrite($hFile, "\t\t'$sFile',\n");
  532. }
  533. fwrite($hFile, "\t),\n");
  534. fwrite($hFile, "\t'addons' => array (\n");
  535. foreach($this->m_aAddons as $sKey => $sFile)
  536. {
  537. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  538. }
  539. fwrite($hFile, "\t),\n");
  540. fwrite($hFile, "\t'dictionaries' => array (\n");
  541. foreach($this->m_aDictionaries as $sFile)
  542. {
  543. fwrite($hFile, "\t\t'$sFile',\n");
  544. }
  545. fwrite($hFile, "\t),\n");
  546. fwrite($hFile, ");\n");
  547. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  548. return fclose($hFile);
  549. }
  550. else
  551. {
  552. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  553. }
  554. }
  555. }
  556. ?>