public function GetApplicationVersion(Config $oConfig) { $aResult = false; try { require_once APPROOT . '/core/cmdbsource.class.inc.php'; CMDBSource::Init($oConfig->GetDBHost(), $oConfig->GetDBUser(), $oConfig->GetDBPwd(), $oConfig->GetDBName()); CMDBSource::SetCharacterSet($oConfig->GetDBCharacterSet(), $oConfig->GetDBCollation()); $sSQLQuery = "SELECT * FROM " . $oConfig->GetDBSubname() . "priv_module_install"; $aSelectInstall = CMDBSource::QueryToArray($sSQLQuery); } catch (MySQLException $e) { // No database or erroneous information $this->log_error('Can not connect to the database: host: ' . $oConfig->GetDBHost() . ', user:'******', pwd:' . $oConfig->GetDBPwd() . ', db name:' . $oConfig->GetDBName()); $this->log_error('Exception ' . $e->getMessage()); return false; } // Scan the list of installed modules to get the version of the 'ROOT' module which holds the main application version foreach ($aSelectInstall as $aInstall) { $sModuleVersion = $aInstall['version']; if ($sModuleVersion == '') { // Though the version cannot be empty in iTop 2.0, it used to be possible // therefore we have to put something here or the module will not be considered // as being installed $sModuleVersion = '0.0.0'; } if ($aInstall['parent_id'] == 0) { if ($aInstall['name'] == DATAMODEL_MODULE) { $aResult['datamodel_version'] = $sModuleVersion; $aComments = json_decode($aInstall['comment'], true); if (is_array($aComments)) { $aResult = array_merge($aResult, $aComments); } } else { $aResult['product_name'] = $aInstall['name']; $aResult['product_version'] = $sModuleVersion; } } } if (!array_key_exists('datamodel_version', $aResult)) { // Versions prior to 2.0 did not record the version of the datamodel // so assume that the datamodel version is equal to the application version $aResult['datamodel_version'] = $aResult['product_version']; } $this->log_info("GetApplicationVersion returns: product_name: " . $aResult['product_name'] . ', product_version: ' . $aResult['product_version']); return $aResult; }