Browse Source

- Fixed the detection of relative path in the config file to make it compatible with *nix

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@963 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 years ago
parent
commit
15e00d9739
3 changed files with 34 additions and 29 deletions
  1. 18 18
      core/config.class.inc.php
  2. 14 9
      core/metamodel.class.php
  3. 2 2
      setup/index.php

+ 18 - 18
core/config.class.inc.php

@@ -267,36 +267,36 @@ class Config
 		$this->m_sFile = $sConfigFile;
 		$this->m_sFile = $sConfigFile;
 		$this->m_aAppModules = array(
 		$this->m_aAppModules = array(
 			// Some default modules, always present can be move to an official iTop Module later if needed
 			// Some default modules, always present can be move to an official iTop Module later if needed
-			'/application/transaction.class.inc.php',
-			'/application/menunode.class.inc.php',
-			'/application/user.preferences.class.inc.php',
-			'/application/audit.rule.class.inc.php',
+			'application/transaction.class.inc.php',
+			'application/menunode.class.inc.php',
+			'application/user.preferences.class.inc.php',
+			'application/audit.rule.class.inc.php',
 // Romain - That's dirty, because those 3 classes are in fact part of the core
 // Romain - That's dirty, because those 3 classes are in fact part of the core
 //          but I needed those classes to be derived from cmdbAbstractObject
 //          but I needed those classes to be derived from cmdbAbstractObject
 //          (to be managed via the GUI) and this class in not really known from
 //          (to be managed via the GUI) and this class in not really known from
 //          the core, PLUS I needed the includes to be there also for the setup
 //          the core, PLUS I needed the includes to be there also for the setup
 //          to create the tables.
 //          to create the tables.
-			'/core/event.class.inc.php',
-			'/core/action.class.inc.php',
-			'/core/trigger.class.inc.php',
+			'core/event.class.inc.php',
+			'core/action.class.inc.php',
+			'core/trigger.class.inc.php',
 		);
 		);
 		$this->m_aDataModels = array();
 		$this->m_aDataModels = array();
 		$this->m_aAddons = array(
 		$this->m_aAddons = array(
 			// Default AddOn, always present can be moved to an official iTop Module later if needed
 			// Default AddOn, always present can be moved to an official iTop Module later if needed
-			'user rights' => '/addons/userrights/userrightsprofile.class.inc.php',
+			'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
 		);
 		);
 		$this->m_aDictionaries = array(
 		$this->m_aDictionaries = array(
 			// Default dictionaries, always present can be moved to an official iTop Module later if needed
 			// Default dictionaries, always present can be moved to an official iTop Module later if needed
-			'/dictionaries/dictionary.itop.core.php',
-			'/dictionaries/dictionary.itop.ui.php',		// Support for English
-			'/dictionaries/fr.dictionary.itop.ui.php',	// Support for French
-			'/dictionaries/fr.dictionary.itop.core.php',	// Support for French
-			'/dictionaries/es_cr.dictionary.itop.ui.php',	// Support for Spanish (from Costa Rica)
-			'/dictionaries/es_cr.dictionary.itop.core.php',	// Support for Spanish (from Costa Rica)
-			'/dictionaries/de.dictionary.itop.ui.php',	// Support for German
-			'/dictionaries/de.dictionary.itop.core.php',	// Support for German
-			'/dictionaries/pt_br.dictionary.itop.ui.php',	// Support for Brazilian Portuguese
-			'/dictionaries/pt_br.dictionary.itop.core.php',	// Support for Brazilian Portuguese
+			'dictionaries/dictionary.itop.core.php',
+			'dictionaries/dictionary.itop.ui.php',		// Support for English
+			'dictionaries/fr.dictionary.itop.ui.php',	// Support for French
+			'dictionaries/fr.dictionary.itop.core.php',	// Support for French
+			'dictionaries/es_cr.dictionary.itop.ui.php',	// Support for Spanish (from Costa Rica)
+			'dictionaries/es_cr.dictionary.itop.core.php',	// Support for Spanish (from Costa Rica)
+			'dictionaries/de.dictionary.itop.ui.php',	// Support for German
+			'dictionaries/de.dictionary.itop.core.php',	// Support for German
+			'dictionaries/pt_br.dictionary.itop.ui.php',	// Support for Brazilian Portuguese
+			'dictionaries/pt_br.dictionary.itop.core.php',	// Support for Brazilian Portuguese
 		);
 		);
 
 
 		foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
 		foreach($this->m_aSettings as $sPropCode => $aSettingInfo)

+ 14 - 9
core/metamodel.class.php

@@ -3348,16 +3348,21 @@ abstract class MetaModel
 
 
 	protected static function Plugin($sConfigFile, $sModuleType, $sToInclude)
 	protected static function Plugin($sConfigFile, $sModuleType, $sToInclude)
 	{
 	{
-		if (substr($sToInclude, 0, 3) == '../')
+		$sFirstChar = substr($sToInclude, 0, 1);
+		$sSecondChar = substr($sToInclude, 1, 1);
+		if (($sFirstChar != '/') && ($sFirstChar != '\\') && ($sSecondChar != ':'))
 		{
 		{
-			// Preserve compatibility with config files written before 1.0.1
-			// Replace '../' by '<root>/'
-			$sFile = APPROOT.'/'.substr($sToInclude, 3);
-		}
-		elseif (substr($sToInclude, 0, 1) == '/')
-		{
-			// Preferred...
-			$sFile = APPROOT.$sToInclude;
+			// It is a relative path, prepend APPROOT
+			if (substr($sToInclude, 0, 3) == '../')
+			{
+				// Preserve compatibility with config files written before 1.0.1
+				// Replace '../' by '<root>/'
+				$sFile = APPROOT.'/'.substr($sToInclude, 3);
+			}
+			else
+			{
+				$sFile = APPROOT.'/'.$sToInclude;			
+			}
 		}
 		}
 		else
 		else
 		{
 		{

+ 2 - 2
setup/index.php

@@ -531,7 +531,7 @@ function CreateAdminAccount(SetupWebPage $oP, Config $oConfig, $sAdminUser, $sAd
 
 
 function ListModuleFiles($sRelDir, SetupWebPage $oP)
 function ListModuleFiles($sRelDir, SetupWebPage $oP)
 {
 {
-	$sDirectory = APPROOT.$sRelDir;
+	$sDirectory = APPROOT.'/'.$sRelDir;
 	//echo "<p>$sDirectory</p>\n";
 	//echo "<p>$sDirectory</p>\n";
 	if ($hDir = opendir($sDirectory))
 	if ($hDir = opendir($sDirectory))
 	{
 	{
@@ -654,7 +654,7 @@ function AddParamsToForm(SetupWebpage $oP, $aParamValues, $aExcludeParams = arra
 function GetAvailableModules(SetupWebpage $oP)
 function GetAvailableModules(SetupWebpage $oP)
 {
 {
 	clearstatcache();
 	clearstatcache();
-	ListModuleFiles('/modules', $oP);
+	ListModuleFiles('modules', $oP);
 	return $oP->GetModules();
 	return $oP->GetModules();
 }
 }