public static function GetApplicationVersion($oWizard)
 {
     require_once APPROOT . '/setup/moduleinstaller.class.inc.php';
     $oConfig = new Config();
     $aParamValues = array('db_server' => $oWizard->GetParameter('db_server', ''), 'db_user' => $oWizard->GetParameter('db_user', ''), 'db_pwd' => $oWizard->GetParameter('db_pwd', ''), 'db_name' => $oWizard->GetParameter('db_name', ''), 'db_prefix' => $oWizard->GetParameter('db_prefix', ''), 'source_dir' => '');
     $oConfig->UpdateFromParams($aParamValues, null);
     $oProductionEnv = new RunTimeEnvironment();
     return $oProductionEnv->GetApplicationVersion($oConfig);
 }
 protected static function DoCreateConfig($sMode, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion, $sGraphvizPath)
 {
     $aParamValues = array('mode' => $sMode, 'db_server' => $sDBServer, 'db_user' => $sDBUser, 'db_pwd' => $sDBPwd, 'db_name' => $sDBName, 'new_db_name' => $sDBName, 'db_prefix' => $sDBPrefix, 'application_path' => $sUrl, 'language' => $sLanguage, 'graphviz_path' => $sGraphvizPath, 'selected_modules' => implode(',', $aSelectedModules));
     $bPreserveModuleSettings = false;
     if ($sMode == 'upgrade') {
         try {
             $oOldConfig = new Config($sPreviousConfigFile);
             $oConfig = clone $oOldConfig;
             $bPreserveModuleSettings = true;
         } catch (Exception $e) {
             // In case the previous configuration is corrupted... start with a blank new one
             $oConfig = new Config();
         }
     } else {
         $oConfig = new Config();
         // To preserve backward compatibility while upgrading to 2.0.3 (when tracking_level_linked_set_default has been introduced)
         // the default value on upgrade differs from the default value at first install
         $oConfig->Set('tracking_level_linked_set_default', LINKSET_TRACKING_NONE, 'first_install');
     }
     // Migration: force utf8_unicode_ci as the collation to make the global search
     // NON case sensitive
     $oConfig->SetDBCollation('utf8_unicode_ci');
     // Final config update: add the modules
     $oConfig->UpdateFromParams($aParamValues, $sModulesDir, $bPreserveModuleSettings);
     if ($bOldAddon) {
         // Old version of the add-on for backward compatibility with pre-2.0 data models
         $oConfig->SetAddons(array('user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php'));
     }
     $oConfig->Set('source_dir', $sSourceDir);
     // Have it work fine even if the DB has been set in read-only mode for the users
     $iPrevAccessMode = $oConfig->Get('access_mode');
     $oConfig->Set('access_mode', ACCESS_FULL);
     // Record which modules are installed...
     $oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
     $oProductionEnv->InitDataModel($oConfig, true);
     // load data model and connect to the database
     $aAvailableModules = $oProductionEnv->AnalyzeInstallation(MetaModel::GetConfig(), APPROOT . $sModulesDir);
     if (!$oProductionEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModules, $sModulesDir)) {
         throw new Exception("Failed to record the installation information");
     }
     // Restore the previous access mode
     $oConfig->Set('access_mode', $iPrevAccessMode);
     // Make sure the root configuration directory exists
     if (!file_exists(APPCONF)) {
         mkdir(APPCONF);
         chmod(APPCONF, 0770);
         // RWX for owner and group, nothing for others
         SetupPage::log_info("Created configuration directory: " . APPCONF);
     }
     // Write the final configuration file
     $sConfigFile = APPCONF . ($sTargetEnvironment == '' ? 'production' : $sTargetEnvironment) . '/' . ITOP_CONFIG_FILE;
     $sConfigDir = dirname($sConfigFile);
     @mkdir($sConfigDir);
     @chmod($sConfigDir, 0770);
     // RWX for owner and group, nothing for others
     $oConfig->WriteToFile($sConfigFile);
     // try to make the final config file read-only
     @chmod($sConfigFile, 0444);
     // Read-only for owner and group, nothing for others
     // Ready to go !!
     require_once APPROOT . 'core/dict.class.inc.php';
     MetaModel::ResetCache();
 }