config.class.inc.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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_ALLOWED_LOGIN_TYPES', 'form|basic|external');
  52. define ('DEFAULT_EXT_AUTH_VARIABLE', '$_SERVER[\'REMOTE_USER\']');
  53. define ('DEFAULT_ENCRYPTION_KEY', '@iT0pEncr1pti0n!'); // We'll use a random value, later...
  54. /**
  55. * Config
  56. * configuration data (this class cannot not be localized, because it is responsible for loading the dictionaries)
  57. *
  58. * @package iTopORM
  59. */
  60. class Config
  61. {
  62. //protected $m_bIsLoaded = false;
  63. protected $m_sFile = '';
  64. protected $m_aAppModules;
  65. protected $m_aDataModels;
  66. protected $m_aWebServiceCategories;
  67. protected $m_aAddons;
  68. protected $m_aDictionaries;
  69. protected $m_aModuleSettings;
  70. // New way to store the settings !
  71. //
  72. protected $m_aSettings = array(
  73. 'app_root_url' => array(
  74. 'type' => 'string',
  75. 'description' => 'Root URL used for navigating within the application, or from an email to the application',
  76. 'default' => '',
  77. 'value' => '',
  78. 'source_of_value' => '',
  79. 'show_in_conf_sample' => true,
  80. ),
  81. 'skip_check_to_write' => array(
  82. 'type' => 'bool',
  83. 'description' => 'Disable data format and integrity checks to boost up data load (insert or update)',
  84. 'default' => false,
  85. 'value' => false,
  86. 'source_of_value' => '',
  87. 'show_in_conf_sample' => false,
  88. ),
  89. 'skip_check_ext_keys' => array(
  90. 'type' => 'bool',
  91. 'description' => 'Disable external key check when checking the value of attributes',
  92. 'default' => false,
  93. 'value' => false,
  94. 'source_of_value' => '',
  95. 'show_in_conf_sample' => false,
  96. ),
  97. 'skip_strong_security' => array(
  98. 'type' => 'bool',
  99. 'description' => 'Disable strong security - TEMPORY: this flag should be removed when we are more confident in the recent change in security',
  100. 'default' => true,
  101. 'value' => true,
  102. 'source_of_value' => '',
  103. 'show_in_conf_sample' => false,
  104. ),
  105. 'graphviz_path' => array(
  106. 'type' => 'string',
  107. 'description' => 'Path to the Graphviz "dot" executable for graphing objects lifecycle',
  108. 'default' => '/usr/bin/dot',
  109. 'value' => '',
  110. 'source_of_value' => '',
  111. 'show_in_conf_sample' => false,
  112. ),
  113. 'session_name' => array(
  114. 'type' => 'string',
  115. 'description' => 'The name of the cookie used to store the PHP session id',
  116. 'default' => 'iTop',
  117. 'value' => '',
  118. 'source_of_value' => '',
  119. 'show_in_conf_sample' => true,
  120. ),
  121. 'max_combo_length' => array(
  122. 'type' => 'integer',
  123. 'description' => 'The maximum number of elements in a drop-down list. If more then an autocomplete will be used',
  124. 'default' => 50,
  125. 'value' => 50,
  126. 'source_of_value' => '',
  127. 'show_in_conf_sample' => false,
  128. ),
  129. 'min_autocomplete_chars' => array(
  130. 'type' => 'integer',
  131. 'description' => 'The minimum number of characters to type in order to trigger the "autocomplete" behavior',
  132. 'default' => 3,
  133. 'value' => 3,
  134. 'source_of_value' => '',
  135. 'show_in_conf_sample' => false,
  136. ),
  137. 'allow_target_creation' => array(
  138. 'type' => 'bool',
  139. 'description' => 'Displays the + button on external keys to create target objects',
  140. 'default' => true,
  141. 'value' => true,
  142. 'source_of_value' => '',
  143. 'show_in_conf_sample' => false,
  144. ),
  145. // Levels that trigger a confirmation in the CSV import/synchro wizard
  146. 'csv_import_min_object_confirmation' => array(
  147. 'type' => 'integer',
  148. 'description' => 'Minimum number of objects to check for the confirmation percentages',
  149. 'default' => 3,
  150. 'value' => 3,
  151. 'source_of_value' => '',
  152. 'show_in_conf_sample' => false,
  153. ),
  154. 'csv_import_errors_percentage' => array(
  155. 'type' => 'integer',
  156. 'description' => 'Percentage of errors that trigger a confirmation in the CSV import',
  157. 'default' => 50,
  158. 'value' => 50,
  159. 'source_of_value' => '',
  160. 'show_in_conf_sample' => false,
  161. ),
  162. 'csv_import_modifications_percentage' => array(
  163. 'type' => 'integer',
  164. 'description' => 'Percentage of modifications that trigger a confirmation in the CSV import',
  165. 'default' => 50,
  166. 'value' => 50,
  167. 'source_of_value' => '',
  168. 'show_in_conf_sample' => false,
  169. ),
  170. 'csv_import_creations_percentage' => array(
  171. 'type' => 'integer',
  172. 'description' => 'Percentage of creations that trigger a confirmation in the CSV import',
  173. 'default' => 50,
  174. 'value' => 50,
  175. 'source_of_value' => '',
  176. 'show_in_conf_sample' => false,
  177. ),
  178. 'access_mode' => array(
  179. 'type' => 'integer',
  180. 'description' => 'Combination of flags (ACCESS_USER_WRITE | ACCESS_ADMIN_WRITE, or ACCESS_FULL)',
  181. 'default' => ACCESS_FULL,
  182. 'value' => ACCESS_FULL,
  183. 'source_of_value' => '',
  184. 'show_in_conf_sample' => true,
  185. ),
  186. 'access_message' => array(
  187. 'type' => 'string',
  188. 'description' => 'Message displayed to the users when there is any access restriction',
  189. 'default' => 'iTop is temporarily frozen, please wait... (the admin team)',
  190. 'value' => '',
  191. 'source_of_value' => '',
  192. 'show_in_conf_sample' => true,
  193. ),
  194. 'online_help' => array(
  195. 'type' => 'string',
  196. 'description' => 'Hyperlink to the online-help web page',
  197. 'default' => 'http://www.combodo.com/itop-help',
  198. 'value' => '',
  199. 'source_of_value' => '',
  200. 'show_in_conf_sample' => true,
  201. ),
  202. 'log_usage' => array(
  203. 'type' => 'bool',
  204. 'description' => 'Log the usage of the application (i.e. the date/time and the user name of each login)',
  205. 'default' => false,
  206. 'value' => false,
  207. 'source_of_value' => '',
  208. 'show_in_conf_sample' => false,
  209. ),
  210. 'synchro_trace' => array(
  211. 'type' => 'string',
  212. 'description' => 'Synchronization details: none, display, save (includes \'display\')',
  213. 'default' => 'none',
  214. 'value' => 'none',
  215. 'source_of_value' => '',
  216. 'show_in_conf_sample' => true,
  217. ),
  218. 'link_set_item_separator' => array(
  219. 'type' => 'string',
  220. 'description' => 'Link set from string: line separator',
  221. 'default' => '|',
  222. 'value' => '|',
  223. 'source_of_value' => '',
  224. 'show_in_conf_sample' => true,
  225. ),
  226. 'link_set_attribute_separator' => array(
  227. 'type' => 'string',
  228. 'description' => 'Link set from string: attribute separator',
  229. 'default' => ';',
  230. 'value' => ';',
  231. 'source_of_value' => '',
  232. 'show_in_conf_sample' => true,
  233. ),
  234. 'link_set_value_separator' => array(
  235. 'type' => 'string',
  236. 'description' => 'Link set from string: value separator (between the attcode and the value itself',
  237. 'default' => ':',
  238. 'value' => ':',
  239. 'source_of_value' => '',
  240. 'show_in_conf_sample' => true,
  241. ),
  242. 'link_set_attribute_qualifier' => array(
  243. 'type' => 'string',
  244. 'description' => 'Link set from string: attribute qualifier (encloses both the attcode and the value)',
  245. 'default' => "'",
  246. 'value' => "'",
  247. 'source_of_value' => '',
  248. 'show_in_conf_sample' => true,
  249. ),
  250. 'cron_max_execution_time' => array(
  251. 'type' => 'integer',
  252. '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',
  253. 'default' => 600,
  254. 'value' => 600,
  255. 'source_of_value' => '',
  256. 'show_in_conf_sample' => true,
  257. ),
  258. 'cron_sleep' => array(
  259. 'type' => 'integer',
  260. 'description' => 'Duration (seconds) before cron.php checks again if something must be done',
  261. 'default' => 2,
  262. 'value' => 2,
  263. 'source_of_value' => '',
  264. 'show_in_conf_sample' => false,
  265. ),
  266. 'email_asynchronous' => array(
  267. 'type' => 'bool',
  268. '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',
  269. 'default' => false,
  270. 'value' => false,
  271. 'source_of_value' => '',
  272. 'show_in_conf_sample' => true,
  273. ),
  274. 'apc_cache.enabled' => array(
  275. 'type' => 'bool',
  276. 'description' => 'If set, the APC cache is allowed (the PHP extension must also be active)',
  277. 'default' => true,
  278. 'value' => true,
  279. 'source_of_value' => '',
  280. 'show_in_conf_sample' => true,
  281. ),
  282. 'apc_cache.query_ttl' => array(
  283. 'type' => 'integer',
  284. 'description' => 'Time to live set in APC for the prepared queries (seconds - 0 means no timeout)',
  285. 'default' => 3600,
  286. 'value' => 3600,
  287. 'source_of_value' => '',
  288. 'show_in_conf_sample' => true,
  289. ),
  290. 'timezone' => array(
  291. 'type' => 'string',
  292. 'description' => 'Timezone (reference: http://php.net/manual/en/timezones.php). If empty, it will be left unchanged and MUST be explicitely configured in PHP',
  293. // examples... not used (nor 'description')
  294. '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'),
  295. 'default' => 'Europe/Paris',
  296. 'value' => 'Europe/Paris',
  297. 'source_of_value' => '',
  298. 'show_in_conf_sample' => true,
  299. ),
  300. 'cas_include_path' => array(
  301. 'type' => 'string',
  302. 'description' => 'The path where to find the phpCAS library',
  303. // examples... not used (nor 'description')
  304. 'default' => '/usr/share/php',
  305. 'value' => '/usr/share/php',
  306. 'source_of_value' => '',
  307. 'show_in_conf_sample' => true,
  308. ),
  309. 'cas_version' => array(
  310. 'type' => 'string',
  311. 'description' => 'The CAS protocol version to use',
  312. // examples... not used (nor 'description')
  313. 'default' => '2.0',
  314. 'value' => '',
  315. 'source_of_value' => '',
  316. 'show_in_conf_sample' => true,
  317. ),
  318. 'cas_host' => array(
  319. 'type' => 'string',
  320. 'description' => 'The name of the CAS host',
  321. // examples... not used (nor 'description')
  322. 'default' => '',
  323. 'value' => '',
  324. 'source_of_value' => '',
  325. 'show_in_conf_sample' => true,
  326. ),
  327. 'cas_port' => array(
  328. 'type' => 'integer',
  329. 'description' => 'The port used by the CAS server',
  330. // examples... not used (nor 'description')
  331. 'default' => 443,
  332. 'value' => 443,
  333. 'source_of_value' => '',
  334. 'show_in_conf_sample' => true,
  335. ),
  336. 'cas_context' => array(
  337. 'type' => 'string',
  338. 'description' => 'The CAS context',
  339. // examples... not used (nor 'description')
  340. 'default' => '',
  341. 'value' => '',
  342. 'source_of_value' => '',
  343. 'show_in_conf_sample' => true,
  344. ),
  345. 'cas_server_ca_cert_path' => array(
  346. 'type' => 'string',
  347. 'description' => 'The path where to find the certificate of the CA for validating the certificate of the CAS server',
  348. // examples... not used (nor 'description')
  349. 'default' => '',
  350. 'value' => '',
  351. 'source_of_value' => '',
  352. 'show_in_conf_sample' => true,
  353. ),
  354. 'cas_logout_redirect_service' => array(
  355. 'type' => 'string',
  356. 'description' => 'The redirect service (URL) to use when logging-out with CAS',
  357. // examples... not used (nor 'description')
  358. 'default' => '',
  359. 'value' => '',
  360. 'source_of_value' => '',
  361. 'show_in_conf_sample' => true,
  362. ),
  363. 'cas_memberof' => array(
  364. 'type' => 'string',
  365. 'description' => 'A comma separated list of group names that the user must be member of (works only with SAML)',
  366. // examples... not used (nor 'description')
  367. 'default' => '',
  368. 'value' => '',
  369. 'source_of_value' => '',
  370. 'show_in_conf_sample' => true,
  371. ),
  372. 'cas_debug' => array(
  373. 'type' => 'bool',
  374. 'description' => 'Activate the CAS debug',
  375. // examples... not used (nor 'description')
  376. 'default' => false,
  377. 'value' => false,
  378. 'source_of_value' => '',
  379. 'show_in_conf_sample' => true,
  380. ),
  381. );
  382. public function IsProperty($sPropCode)
  383. {
  384. return (array_key_exists($sPropCode, $this->m_aSettings));
  385. }
  386. public function Set($sPropCode, $value, $sSourceDesc = 'unknown')
  387. {
  388. $sType = $this->m_aSettings[$sPropCode]['type'];
  389. switch($sType)
  390. {
  391. case 'bool':
  392. $value = (bool) $value;
  393. break;
  394. case 'string':
  395. $value = (string) $value;
  396. break;
  397. case 'integer':
  398. $value = (integer) $value;
  399. break;
  400. case 'float':
  401. $value = (float) $value;
  402. break;
  403. default:
  404. throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
  405. }
  406. $this->m_aSettings[$sPropCode]['value'] = $value;
  407. $this->m_aSettings[$sPropCode]['source_of_value'] = $sSourceDesc;
  408. }
  409. public function Get($sPropCode)
  410. {
  411. return $this->m_aSettings[$sPropCode]['value'];
  412. }
  413. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  414. protected $m_sDBHost;
  415. protected $m_sDBUser;
  416. protected $m_sDBPwd;
  417. protected $m_sDBName;
  418. protected $m_sDBSubname;
  419. protected $m_sDBCharacterSet;
  420. protected $m_sDBCollation;
  421. /**
  422. * Event log options (see LOG_... definition)
  423. */
  424. // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
  425. protected $m_bLogGlobal;
  426. protected $m_bLogNotification;
  427. protected $m_bLogIssue;
  428. protected $m_bLogWebService;
  429. protected $m_bLogKpiDuration; // private setting
  430. protected $m_bLogKpiMemory; // private setting
  431. protected $m_bDebugQueries; // private setting
  432. protected $m_bQueryCacheEnabled; // private setting
  433. /**
  434. * @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
  435. */
  436. protected $m_iMinDisplayLimit;
  437. /**
  438. * @var integer Max number of elements before truncating the display
  439. */
  440. protected $m_iMaxDisplayLimit;
  441. /**
  442. * @var integer Number of seconds between two reloads of the display (standard)
  443. */
  444. protected $m_iStandardReloadInterval;
  445. /**
  446. * @var integer Number of seconds between two reloads of the display (fast)
  447. */
  448. protected $m_iFastReloadInterval;
  449. /**
  450. * @var boolean Whether or not a secure connection is required for using the application.
  451. * If set, any attempt to connect to an iTop page with http:// will be redirected
  452. * to https://
  453. */
  454. protected $m_bSecureConnectionRequired;
  455. /**
  456. * @var string Langage code, default if the user language is undefined
  457. */
  458. protected $m_sDefaultLanguage;
  459. /**
  460. * @var string Type of login process allowed: form|basic|url|external
  461. */
  462. protected $m_sAllowedLoginTypes;
  463. /**
  464. * @var string Name of the PHP variable in which external authentication information is passed by the web server
  465. */
  466. protected $m_sExtAuthVariable;
  467. /**
  468. * @var string Encryption key used for all attributes of type "encrypted string". Can be set to a random value
  469. * unless you want to import a database from another iTop instance, in which case you must use
  470. * the same encryption key in order to properly decode the encrypted fields
  471. */
  472. protected $m_sEncryptionKey;
  473. /**
  474. * @var array Additional character sets to be supported by the interactive CSV import
  475. * 'iconv_code' => 'display name'
  476. */
  477. protected $m_aCharsets;
  478. public function __construct($sConfigFile, $bLoadConfig = true)
  479. {
  480. $this->m_sFile = $sConfigFile;
  481. $this->m_aAppModules = array(
  482. // Some default modules, always present can be move to an official iTop Module later if needed
  483. 'application/transaction.class.inc.php',
  484. 'application/menunode.class.inc.php',
  485. 'application/user.preferences.class.inc.php',
  486. 'application/audit.rule.class.inc.php',
  487. // Romain - That's dirty, because those classes are in fact part of the core
  488. // but I needed those classes to be derived from cmdbAbstractObject
  489. // (to be managed via the GUI) and this class in not really known from
  490. // the core, PLUS I needed the includes to be there also for the setup
  491. // to create the tables.
  492. 'core/event.class.inc.php',
  493. 'core/action.class.inc.php',
  494. 'core/trigger.class.inc.php',
  495. 'synchro/synchrodatasource.class.inc.php',
  496. );
  497. $this->m_aDataModels = array();
  498. $this->m_aWebServiceCategories = array(
  499. 'webservices/webservices.basic.php',
  500. );
  501. $this->m_aAddons = array(
  502. // Default AddOn, always present can be moved to an official iTop Module later if needed
  503. 'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
  504. );
  505. $this->m_aDictionaries = array(
  506. // Default dictionaries, always present can be moved to an official iTop Module later if needed
  507. 'dictionaries/dictionary.itop.core.php',
  508. 'dictionaries/dictionary.itop.ui.php', // Support for English
  509. 'dictionaries/fr.dictionary.itop.ui.php', // Support for French
  510. 'dictionaries/fr.dictionary.itop.core.php', // Support for French
  511. 'dictionaries/es_cr.dictionary.itop.ui.php', // Support for Spanish (from Costa Rica)
  512. 'dictionaries/es_cr.dictionary.itop.core.php', // Support for Spanish (from Costa Rica)
  513. 'dictionaries/de.dictionary.itop.ui.php', // Support for German
  514. 'dictionaries/de.dictionary.itop.core.php', // Support for German
  515. 'dictionaries/pt_br.dictionary.itop.ui.php', // Support for Brazilian Portuguese
  516. 'dictionaries/pt_br.dictionary.itop.core.php', // Support for Brazilian Portuguese
  517. 'dictionaries/ru.dictionary.itop.ui.php', // Support for Russian
  518. 'dictionaries/ru.dictionary.itop.core.php', // Support for Russian
  519. 'dictionaries/tr.dictionary.itop.ui.php', // Support for Turkish
  520. 'dictionaries/tr.dictionary.itop.core.php', // Support for Turkish
  521. 'dictionaries/zh.dictionary.itop.ui.php', // Support for Chinese
  522. 'dictionaries/zh.dictionary.itop.core.php', // Support for Chinese
  523. 'dictionaries/it.dictionary.itop.ui.php', // Support for Italian
  524. 'dictionaries/it.dictionary.itop.core.php', // Support for Italian
  525. 'dictionaries/hu.dictionary.itop.ui.php', // Support for Hungarian
  526. 'dictionaries/hu.dictionary.itop.core.php', // Support for Hungarian
  527. );
  528. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  529. {
  530. $this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
  531. }
  532. $this->m_sDBHost = '';
  533. $this->m_sDBUser = '';
  534. $this->m_sDBPwd = '';
  535. $this->m_sDBName = '';
  536. $this->m_sDBSubname = '';
  537. $this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
  538. $this->m_sDBCollation = DEFAULT_COLLATION;
  539. $this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
  540. $this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
  541. $this->m_bLogIssue = DEFAULT_LOG_ISSUE;
  542. $this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
  543. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  544. $this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
  545. $this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
  546. $this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
  547. $this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
  548. $this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
  549. $this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
  550. $this->m_sDefaultLanguage = 'EN US';
  551. $this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
  552. $this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
  553. $this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
  554. $this->m_aCharsets = array();
  555. $this->m_aModuleSettings = array();
  556. if ($bLoadConfig)
  557. {
  558. $this->Load($sConfigFile);
  559. $this->Verify();
  560. }
  561. // Application root url: set a default value, then normalize it
  562. $sAppRootUrl = trim($this->Get('app_root_url'));
  563. if (strlen($sAppRootUrl) == 0)
  564. {
  565. $sAppRootUrl = utils::GetDefaultUrlAppRoot();
  566. }
  567. if (substr($sAppRootUrl, -1, 1) != '/')
  568. {
  569. $sAppRootUrl .= '/';
  570. }
  571. $this->Set('app_root_url', $sAppRootUrl);
  572. }
  573. protected function CheckFile($sPurpose, $sFileName)
  574. {
  575. if (!file_exists($sFileName))
  576. {
  577. throw new ConfigException("Could not find $sPurpose file", array('file' => $sFileName));
  578. }
  579. }
  580. protected function Load($sConfigFile)
  581. {
  582. $this->CheckFile('configuration', $sConfigFile);
  583. $sConfigCode = trim(file_get_contents($sConfigFile));
  584. // This does not work on several lines
  585. // preg_match('/^<\\?php(.*)\\?'.'>$/', $sConfigCode, $aMatches)...
  586. // So, I've implemented a solution suggested in the PHP doc (search for phpWrapper)
  587. try
  588. {
  589. ob_start();
  590. eval('?'.'>'.trim($sConfigCode));
  591. $sNoise = trim(ob_get_contents());
  592. ob_end_clean();
  593. }
  594. catch (Exception $e)
  595. {
  596. // well, never reach in case of parsing error :-(
  597. // will be improved in PHP 6 ?
  598. throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
  599. }
  600. if (strlen($sNoise) > 0)
  601. {
  602. // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
  603. throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => '<tt>'.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').'</tt>'));
  604. }
  605. if (!isset($MySettings) || !is_array($MySettings))
  606. {
  607. throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
  608. }
  609. if (!isset($MyModules) || !is_array($MyModules))
  610. {
  611. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules'));
  612. }
  613. if (!array_key_exists('application', $MyModules))
  614. {
  615. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'application\']'));
  616. }
  617. if (!array_key_exists('business', $MyModules))
  618. {
  619. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'business\']'));
  620. }
  621. if (!array_key_exists('addons', $MyModules))
  622. {
  623. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
  624. }
  625. if (!array_key_exists('user rights', $MyModules['addons']))
  626. {
  627. // Add one, by default
  628. $MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
  629. }
  630. if (!array_key_exists('dictionaries', $MyModules))
  631. {
  632. throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
  633. }
  634. $this->m_aAppModules = $MyModules['application'];
  635. $this->m_aDataModels = $MyModules['business'];
  636. if (isset($MyModules['webservices']))
  637. {
  638. $this->m_aWebServiceCategories = $MyModules['webservices'];
  639. }
  640. $this->m_aAddons = $MyModules['addons'];
  641. $this->m_aDictionaries = $MyModules['dictionaries'];
  642. foreach($MySettings as $sPropCode => $rawvalue)
  643. {
  644. if ($this->IsProperty($sPropCode))
  645. {
  646. $value = trim($rawvalue);
  647. $this->Set($sPropCode, $value, $sConfigFile);
  648. }
  649. }
  650. $this->m_sDBHost = trim($MySettings['db_host']);
  651. $this->m_sDBUser = trim($MySettings['db_user']);
  652. $this->m_sDBPwd = trim($MySettings['db_pwd']);
  653. $this->m_sDBName = trim($MySettings['db_name']);
  654. $this->m_sDBSubname = trim($MySettings['db_subname']);
  655. $this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
  656. $this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
  657. $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
  658. $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
  659. $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
  660. $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
  661. $this->m_bLogKPIDuration = isset($MySettings['log_kpi_duration']) ? (bool) trim($MySettings['log_kpi_duration']) : DEFAULT_LOG_KPI_DURATION;
  662. $this->m_bLogKPIMemory = isset($MySettings['log_kpi_memory']) ? (bool) trim($MySettings['log_kpi_memory']) : DEFAULT_LOG_KPI_MEMORY;
  663. $this->m_bDebugQueries = isset($MySettings['debug_queries']) ? (bool) trim($MySettings['debug_queries']) : DEFAULT_DEBUG_QUERIES;
  664. $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
  665. $this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
  666. $this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
  667. $this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
  668. $this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
  669. $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
  670. $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
  671. $this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
  672. $this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
  673. $this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
  674. $this->m_sEncryptionKey = isset($MySettings['encryption_key']) ? trim($MySettings['encryption_key']) : DEFAULT_ENCRYPTION_KEY;
  675. $this->m_aCharsets = isset($MySettings['csv_import_charsets']) ? $MySettings['csv_import_charsets'] : array();
  676. }
  677. protected function Verify()
  678. {
  679. // Files are verified later on, just before using them -see MetaModel::Plugin()
  680. // (we have their final path at that point)
  681. }
  682. public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
  683. {
  684. if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
  685. {
  686. return $this->m_aModuleSettings[$sModule][$sProperty];
  687. }
  688. return $defaultvalue;
  689. }
  690. public function SetModuleSetting($sModule, $sProperty, $value)
  691. {
  692. $this->m_aModuleSettings[$sModule][$sProperty] = $value;
  693. }
  694. public function GetAppModules()
  695. {
  696. return $this->m_aAppModules;
  697. }
  698. public function SetAppModules($aAppModules)
  699. {
  700. $this->m_aAppModules = $aAppModules;
  701. }
  702. public function GetDataModels()
  703. {
  704. return $this->m_aDataModels;
  705. }
  706. public function SetDataModels($aDataModels)
  707. {
  708. $this->m_aDataModels = $aDataModels;
  709. }
  710. public function GetWebServiceCategories()
  711. {
  712. return $this->m_aWebServiceCategories;
  713. }
  714. public function SetWebServiceCategories($aWebServiceCategories)
  715. {
  716. $this->m_aWebServiceCategories = $aWebServiceCategories;
  717. }
  718. public function GetAddons()
  719. {
  720. return $this->m_aAddons;
  721. }
  722. public function SetAddons($aAddons)
  723. {
  724. $this->m_aAddons = $aAddons;
  725. }
  726. public function GetDictionaries()
  727. {
  728. return $this->m_aDictionaries;
  729. }
  730. public function SetDictionaries($aDictionaries)
  731. {
  732. $this->m_aDictionaries = $aDictionaries;
  733. }
  734. public function GetDBHost()
  735. {
  736. return $this->m_sDBHost;
  737. }
  738. public function GetDBName()
  739. {
  740. return $this->m_sDBName;
  741. }
  742. public function GetDBSubname()
  743. {
  744. return $this->m_sDBSubname;
  745. }
  746. public function GetDBCharacterSet()
  747. {
  748. return $this->m_sDBCharacterSet;
  749. }
  750. public function GetDBCollation()
  751. {
  752. return $this->m_sDBCollation;
  753. }
  754. public function GetDBUser()
  755. {
  756. return $this->m_sDBUser;
  757. }
  758. public function GetDBPwd()
  759. {
  760. return $this->m_sDBPwd;
  761. }
  762. public function GetLogGlobal()
  763. {
  764. return $this->m_bLogGlobal;
  765. }
  766. public function GetLogNotification()
  767. {
  768. return $this->m_bLogNotification;
  769. }
  770. public function GetLogIssue()
  771. {
  772. return $this->m_bLogIssue;
  773. }
  774. public function GetLogWebService()
  775. {
  776. return $this->m_bLogWebService;
  777. }
  778. public function GetLogKPIDuration()
  779. {
  780. return $this->m_bLogKPIDuration;
  781. }
  782. public function GetLogKPIMemory()
  783. {
  784. return $this->m_bLogKPIMemory;
  785. }
  786. public function GetDebugQueries()
  787. {
  788. return $this->m_bDebugQueries;
  789. }
  790. public function GetQueryCacheEnabled()
  791. {
  792. return $this->m_bQueryCacheEnabled;
  793. }
  794. public function GetMinDisplayLimit()
  795. {
  796. return $this->m_iMinDisplayLimit;
  797. }
  798. public function GetMaxDisplayLimit()
  799. {
  800. return $this->m_iMaxDisplayLimit;
  801. }
  802. public function GetStandardReloadInterval()
  803. {
  804. return $this->m_iStandardReloadInterval;
  805. }
  806. public function GetFastReloadInterval()
  807. {
  808. return $this->m_iFastReloadInterval;
  809. }
  810. public function GetSecureConnectionRequired()
  811. {
  812. return $this->m_bSecureConnectionRequired;
  813. }
  814. public function GetDefaultLanguage()
  815. {
  816. return $this->m_sDefaultLanguage;
  817. }
  818. public function GetEncryptionKey()
  819. {
  820. return $this->m_sEncryptionKey;
  821. }
  822. public function GetAllowedLoginTypes()
  823. {
  824. return explode('|', $this->m_sAllowedLoginTypes);
  825. }
  826. public function GetExternalAuthenticationVariable()
  827. {
  828. return $this->m_sExtAuthVariable;
  829. }
  830. public function GetCSVImportCharsets()
  831. {
  832. return $this->m_aCharsets;
  833. }
  834. public function SetDBHost($sDBHost)
  835. {
  836. $this->m_sDBHost = $sDBHost;
  837. }
  838. public function SetDBName($sDBName)
  839. {
  840. $this->m_sDBName = $sDBName;
  841. }
  842. public function SetDBSubname($sDBSubName)
  843. {
  844. $this->m_sDBSubname = $sDBSubName;
  845. }
  846. public function SetDBCharacterSet($sDBCharacterSet)
  847. {
  848. $this->m_sDBCharacterSet = $sDBCharacterSet;
  849. }
  850. public function SetDBCollation($sDBCollation)
  851. {
  852. $this->m_sDBCollation = $sDBCollation;
  853. }
  854. public function SetDBUser($sUser)
  855. {
  856. $this->m_sDBUser = $sUser;
  857. }
  858. public function SetDBPwd($sPwd)
  859. {
  860. $this->m_sDBPwd = $sPwd;
  861. }
  862. public function SetLogGlobal($iLogGlobal)
  863. {
  864. $this->m_iLogGlobal = $iLogGlobal;
  865. }
  866. public function SetLogNotification($iLogNotification)
  867. {
  868. $this->m_iLogNotification = $iLogNotification;
  869. }
  870. public function SetLogIssue($iLogIssue)
  871. {
  872. $this->m_iLogIssue = $iLogIssue;
  873. }
  874. public function SetLogWebService($iLogWebService)
  875. {
  876. $this->m_iLogWebService = $iLogWebService;
  877. }
  878. public function SetMinDisplayLimit($iMinDisplayLimit)
  879. {
  880. $this->m_iMinDisplayLimit = $iMinDisplayLimit;
  881. }
  882. public function SetMaxDisplayLimit($iMaxDisplayLimit)
  883. {
  884. $this->m_iMaxDisplayLimit = $iMaxDisplayLimit;
  885. }
  886. public function SetStandardReloadInterval($iStandardReloadInterval)
  887. {
  888. $this->m_iStandardReloadInterval = $iStandardReloadInterval;
  889. }
  890. public function SetFastReloadInterval($iFastReloadInterval)
  891. {
  892. $this->m_iFastReloadInterval = $iFastReloadInterval;
  893. }
  894. public function SetSecureConnectionRequired($bSecureConnectionRequired)
  895. {
  896. $this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
  897. }
  898. public function SetDefaultLanguage($sLanguageCode)
  899. {
  900. $this->m_sDefaultLanguage = $sLanguageCode;
  901. }
  902. public function SetAllowedLoginTypes($aAllowedLoginTypes)
  903. {
  904. $this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
  905. }
  906. public function SetExternalAuthenticationVariable($sExtAuthVariable)
  907. {
  908. $this->m_sExtAuthVariable = $sExtAuthVariable;
  909. }
  910. public function SetEncryptionKey($sKey)
  911. {
  912. $this->m_sEncryptionKey = $sKey;
  913. }
  914. public function SetCSVImportCharsets($aCharsets)
  915. {
  916. $this->m_aCharsets = $aCharsets;
  917. }
  918. public function AddCSVImportCharset($sIconvCode, $sDisplayName)
  919. {
  920. $this->m_aCharsets[$sIconvCode] = $sDisplayName;
  921. }
  922. public function FileIsWritable()
  923. {
  924. return is_writable($this->m_sFile);
  925. }
  926. public function GetLoadedFile()
  927. {
  928. return $this->m_sFile;
  929. }
  930. /**
  931. * Render the configuration as an associative array
  932. * @return boolean True otherwise throws an Exception
  933. */
  934. public function ToArray()
  935. {
  936. $aSettings = array();
  937. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  938. {
  939. $aSettings[$sPropCode] = $aSettingInfo['value'];
  940. }
  941. $aSettings['db_host'] = $this->m_sDBHost;
  942. $aSettings['db_user'] = $this->m_sDBUser;
  943. $aSettings['db_pwd'] = $this->m_sDBPwd;
  944. $aSettings['db_name'] = $this->m_sDBName;
  945. $aSettings['db_subname'] = $this->m_sDBSubname;
  946. $aSettings['db_character_set'] = $this->m_sDBCharacterSet;
  947. $aSettings['db_collation'] = $this->m_sDBCollation;
  948. $aSettings['log_global'] = $this->m_bLogGlobal;
  949. $aSettings['log_notification'] = $this->m_bLogNotification;
  950. $aSettings['log_issue'] = $this->m_bLogIssue;
  951. $aSettings['log_web_service'] = $this->m_bLogWebService;
  952. $aSettings['min_display_limit'] = $this->m_iMinDisplayLimit;
  953. $aSettings['max_display_limit'] = $this->m_iMaxDisplayLimit;
  954. $aSettings['standard_reload_interval'] = $this->m_iStandardReloadInterval;
  955. $aSettings['fast_reload_interval'] = $this->m_iFastReloadInterval;
  956. $aSettings['secure_connection_required'] = $this->m_bSecureConnectionRequired;
  957. $aSettings['default_language'] = $this->m_sDefaultLanguage;
  958. $aSettings['allowed_login_types'] = $this->m_sAllowedLoginTypes;
  959. $aSettings['encryption_key'] = $this->m_sEncryptionKey;
  960. $aSettings['csv_import_charsets'] = $this->m_aCharsets;
  961. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  962. {
  963. foreach ($aProperties as $sProperty => $value)
  964. {
  965. $aSettings['module_settings'][$sModule][$sProperty] = $value;
  966. }
  967. }
  968. foreach($this->m_aAppModules as $sFile)
  969. {
  970. $aSettings['application_list'][] = $sFile;
  971. }
  972. foreach($this->m_aDataModels as $sFile)
  973. {
  974. $aSettings['datamodel_list'][] = $sFile;
  975. }
  976. foreach($this->m_aWebServiceCategories as $sFile)
  977. {
  978. $aSettings['webservice_list'][] = $sFile;
  979. }
  980. foreach($this->m_aAddons as $sKey => $sFile)
  981. {
  982. $aSettings['addon_list'][] = $sFile;
  983. }
  984. foreach($this->m_aDictionaries as $sFile)
  985. {
  986. $aSettings['dictionary_list'][] = $sFile;
  987. }
  988. return $aSettings;
  989. }
  990. /**
  991. * Write the configuration to a file (php format) that can be reloaded later
  992. * By default write to the same file that was specified when constructing the object
  993. * @param $sFileName string Name of the file to write to (emtpy to write to the same file)
  994. * @return boolean True otherwise throws an Exception
  995. */
  996. public function WriteToFile($sFileName = '')
  997. {
  998. if (empty($sFileName))
  999. {
  1000. $sFileName = $this->m_sFile;
  1001. }
  1002. $hFile = @fopen($sFileName, 'w');
  1003. if ($hFile !== false)
  1004. {
  1005. fwrite($hFile, "<?php\n");
  1006. fwrite($hFile, "\n/**\n");
  1007. fwrite($hFile, " *\n");
  1008. fwrite($hFile, " * phpMyORM configuration file, generated by the iTop configuration wizard\n");
  1009. fwrite($hFile, " *\n");
  1010. fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
  1011. fwrite($hFile, " *\n");
  1012. fwrite($hFile, " */\n");
  1013. fwrite($hFile, "\n");
  1014. fwrite($hFile, "\$MySettings = array(\n");
  1015. foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
  1016. {
  1017. if ($aSettingInfo['show_in_conf_sample'])
  1018. {
  1019. $sType = $this->m_aSettings[$sPropCode]['type'];
  1020. switch($sType)
  1021. {
  1022. case 'bool':
  1023. $sSeenAs = $aSettingInfo['value'] ? '1' : '0';
  1024. break;
  1025. default:
  1026. $sSeenAs = "'".addslashes($aSettingInfo['value'])."'";
  1027. }
  1028. fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
  1029. }
  1030. }
  1031. fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
  1032. fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
  1033. fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
  1034. fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
  1035. fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
  1036. fwrite($hFile, "\t'db_character_set' => '{$this->m_sDBCharacterSet}',\n");
  1037. fwrite($hFile, "\t'db_collation' => '{$this->m_sDBCollation}',\n");
  1038. fwrite($hFile, "\n");
  1039. fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
  1040. fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
  1041. fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
  1042. fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
  1043. fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
  1044. fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
  1045. fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
  1046. fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
  1047. fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
  1048. fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
  1049. fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
  1050. fwrite($hFile, "\t'encryption_key' => '{$this->m_sEncryptionKey}',\n");
  1051. $sExport = var_export($this->m_aCharsets, true);
  1052. fwrite($hFile, "\t'csv_import_charsets' => $sExport,\n");
  1053. fwrite($hFile, ");\n");
  1054. fwrite($hFile, "\n");
  1055. fwrite($hFile, "\$MyModuleSettings = array(\n");
  1056. foreach ($this->m_aModuleSettings as $sModule => $aProperties)
  1057. {
  1058. fwrite($hFile, "\t'$sModule' => array (\n");
  1059. foreach ($aProperties as $sProperty => $value)
  1060. {
  1061. $sExport = var_export($value, true);
  1062. fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
  1063. }
  1064. fwrite($hFile, "\t),\n");
  1065. }
  1066. fwrite($hFile, ");\n");
  1067. fwrite($hFile, "\n/**\n");
  1068. fwrite($hFile, " *\n");
  1069. fwrite($hFile, " * Data model modules to be loaded. Names should be specified as absolute paths\n");
  1070. fwrite($hFile, " *\n");
  1071. fwrite($hFile, " */\n");
  1072. fwrite($hFile, "\$MyModules = array(\n");
  1073. fwrite($hFile, "\t'application' => array (\n");
  1074. foreach($this->m_aAppModules as $sFile)
  1075. {
  1076. fwrite($hFile, "\t\t'$sFile',\n");
  1077. }
  1078. fwrite($hFile, "\t),\n");
  1079. fwrite($hFile, "\t'business' => array (\n");
  1080. foreach($this->m_aDataModels as $sFile)
  1081. {
  1082. fwrite($hFile, "\t\t'$sFile',\n");
  1083. }
  1084. fwrite($hFile, "\t),\n");
  1085. fwrite($hFile, "\t'webservices' => array (\n");
  1086. foreach($this->m_aWebServiceCategories as $sFile)
  1087. {
  1088. fwrite($hFile, "\t\t'$sFile',\n");
  1089. }
  1090. fwrite($hFile, "\t),\n");
  1091. fwrite($hFile, "\t'addons' => array (\n");
  1092. foreach($this->m_aAddons as $sKey => $sFile)
  1093. {
  1094. fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
  1095. }
  1096. fwrite($hFile, "\t),\n");
  1097. fwrite($hFile, "\t'dictionaries' => array (\n");
  1098. foreach($this->m_aDictionaries as $sFile)
  1099. {
  1100. fwrite($hFile, "\t\t'$sFile',\n");
  1101. }
  1102. fwrite($hFile, "\t),\n");
  1103. fwrite($hFile, ");\n");
  1104. fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
  1105. return fclose($hFile);
  1106. }
  1107. else
  1108. {
  1109. throw new ConfigException("Could not write to configuration file", array('file' => $sFileName));
  1110. }
  1111. }
  1112. }
  1113. ?>