diff --git a/.gitattributes b/.gitattributes index d8c517b..73b98c1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,6 +11,7 @@ copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php -text copy_this/modules/d3/d3geoip/menu.xml -text copy_this/modules/d3/d3geoip/metadata.php -text copy_this/modules/d3/d3geoip/models/d3geoip.php -text +copy_this/modules/d3/d3geoip/modules/controllers/d3_oxshopcontrol_geoip.php -text copy_this/modules/d3/d3geoip/picture.png -text copy_this/modules/d3/d3geoip/setup/d3geoip_update.php -text copy_this/modules/d3/d3geoip/views/admin/de/d3_geoip_lang.php -text diff --git a/copy_this/.noencode b/copy_this/.noencode index 852e36b..3d94b66 100644 --- a/copy_this/.noencode +++ b/copy_this/.noencode @@ -1 +1 @@ -copyAsIsFiles = modules/d3/d3geoip/components, modules/d3/d3geoip/controllers, modules/d3/d3geoip/models/d3geoip_update.php, modules/d3/d3geoip/views, modules/d3/d3geoip/IntelliSenseHelper.php, modules/d3/d3geoip/metadata.php \ No newline at end of file +copyAsIsFiles = modules/d3/d3geoip/components, modules/d3/d3geoip/controllers, modules/d3/d3geoip/setup, modules/d3/d3geoip/modules/controllers, modules/d3/d3geoip/views, modules/d3/d3geoip/IntelliSenseHelper.php, modules/d3/d3geoip/metadata.php \ No newline at end of file diff --git a/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php b/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php index 6cfd75f..6cbc9d8 100644 --- a/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php +++ b/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php @@ -41,8 +41,25 @@ class d3cmp_geoip extends oxView $oLocation = oxNew('d3geoip'); $oLocation->setCountryCurrency(); $oLocation->setCountryLanguage(); + + if (!isset($oBasket)) { + $oBasket = $this->getSession()->getBasket(); + } + + // call component again, if curr is registered before we changed it + // reason: own component can added after default components only + if ($oLocation->hasNotSetCurrency($oBasket->getBasketCurrency())) { + /** @var oxUBase $oActView */ + $oActView = oxRegistry::getConfig()->getActiveView(); + $aComponents = $oActView->getComponents(); + + /** @var oxcmp_cur $oCurCmp */ + $oCurCmp = $aComponents['oxcmp_cur']; + $oCurCmp->init(); + } + // language isn't registered, we don't need an additional check } parent::init(); } -} \ No newline at end of file +} diff --git a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php index 1f00486..a44c328 100644 --- a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php +++ b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php @@ -160,7 +160,10 @@ class d3_country_geoip extends oxAdminView */ public function getCurList() { - if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) { + if ($this->getModCfgValue('blChangeShop') + && $this->oCountry->getFieldData('d3geoipshop') + && $this->oCountry->getFieldData('d3geoipshop') > 0 // -1 is user choice + ) { $sShopId = $this->oCountry->getFieldData('d3geoipshop'); } else { $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); @@ -186,9 +189,9 @@ class d3_country_geoip extends oxAdminView if ($sCurrencies) { foreach (unserialize($sCurrencies) as $sKey => $sValue) { $aFields = explode('@', $sValue); - $aCurrencies[$sKey]->id = $sKey; - $aCurrencies[$sKey]->name = $aFields[0]; - $aCurrencies[$sKey]->sign = $aFields[4]; + $aCurrencies[$sKey]->id = trim($sKey); + $aCurrencies[$sKey]->name = trim($aFields[0]); + $aCurrencies[$sKey]->sign = trim($aFields[4]); } } @@ -201,7 +204,10 @@ class d3_country_geoip extends oxAdminView */ public function getLangList() { - if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) { + if ($this->getModCfgValue('blChangeShop') + && $this->oCountry->getFieldData('d3geoipshop') + && $this->oCountry->getFieldData('d3geoipshop') > 0 // -1 is user choice + ) { $sShopId = $this->oCountry->getFieldData('d3geoipshop'); } else { $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); @@ -239,12 +245,6 @@ class d3_country_geoip extends oxAdminView $oLang->sort = $aLangParams[$key]['sort']; } - if (isset($iLanguage) && $oLang->id == $iLanguage) { - $oLang->selected = 1; - } else { - $oLang->selected = 0; - } - if ($oLang->active) { $aLanguages[$oLang->id] = $oLang; } diff --git a/copy_this/modules/d3/d3geoip/metadata.php b/copy_this/modules/d3/d3geoip/metadata.php index 7cabca1..b904507 100644 --- a/copy_this/modules/d3/d3geoip/metadata.php +++ b/copy_this/modules/d3/d3geoip/metadata.php @@ -15,11 +15,13 @@ $aModule = array( 'en' => '', ), 'thumbnail' => 'picture.png', - 'version' => '3.0.1.0', + 'version' => '3.0.2.1', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'http://www.oxidmodule.com/', - 'extend' => array(), + 'extend' => array( + 'oxshopcontrol' => 'd3/d3geoip/modules/controllers/d3_oxshopcontrol_geoip', + ), 'files' => array( 'd3cmp_geoip' => 'd3/d3geoip/components/d3cmp_geoip.php', 'd3_cfg_geoipset' => 'd3/d3geoip/controllers/admin/d3_cfg_geoipset.php', diff --git a/copy_this/modules/d3/d3geoip/models/d3geoip.php b/copy_this/modules/d3/d3geoip/models/d3geoip.php index e1a657a..96296cf 100644 --- a/copy_this/modules/d3/d3geoip/models/d3geoip.php +++ b/copy_this/modules/d3/d3geoip/models/d3geoip.php @@ -307,6 +307,22 @@ class d3GeoIP extends oxbase stopProfile(__METHOD__); } + /** + * @param $oCurr + * @return bool + */ + public function hasNotSetCurrency($oCurr) + { + $oCountry = $this->getUserLocationCountryObject(); + if ($oCountry->getFieldData('d3geoipcur') > 0 + && $oCurr->id != $oCountry->getFieldData('d3geoipcur') + ) { + return true; + } + + return false; + } + /** * check module active state and perform switching to user country specific shop (EE only) * diff --git a/copy_this/modules/d3/d3geoip/modules/controllers/d3_oxshopcontrol_geoip.php b/copy_this/modules/d3/d3geoip/modules/controllers/d3_oxshopcontrol_geoip.php new file mode 100644 index 0000000..bf17d26 --- /dev/null +++ b/copy_this/modules/d3/d3geoip/modules/controllers/d3_oxshopcontrol_geoip.php @@ -0,0 +1,58 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_oxshopcontrol_geoip extends d3_oxshopcontrol_geoip_parent +{ + /** + * @param null $sClass + * @param null $sFunction + * @param null $aParams + * @param null $aViewsChain + * @return null + */ + public function start ($sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null) + { + $this->_d3AddGeoIpComponent(); + + parent::start($sClass, $sFunction, $aParams, $aViewsChain); + } + + /** + * check, if developer mode has to be enabled + * + * @return bool + */ + protected function _d3AddGeoIpComponent() + { + startProfile(__METHOD__); + + $aUserComponentNames = oxRegistry::getConfig()->getConfigParam('aUserComponentNames'); + $sGeoIpCmpName = 'd3cmp_geoip'; + $blDontUseCache = 1; + + if (false == is_array($aUserComponentNames)) { + $aUserComponentNames = array(); + } + + if (false == in_array($sGeoIpCmpName, array_keys($aUserComponentNames))) { + $aUserComponentNames[$sGeoIpCmpName] = $blDontUseCache; + oxRegistry::getConfig()->setConfigParam('aUserComponentNames', $aUserComponentNames); + } + + stopProfile(__METHOD__); + } +} diff --git a/copy_this/modules/d3/d3geoip/setup/d3geoip_update.php b/copy_this/modules/d3/d3geoip/setup/d3geoip_update.php index 6dc06bd..8daea5e 100644 --- a/copy_this/modules/d3/d3geoip/setup/d3geoip_update.php +++ b/copy_this/modules/d3/d3geoip/setup/d3geoip_update.php @@ -1,458 +1,477 @@ - - * @link http://www.oxidmodule.com - */ - -class d3geoip_update extends d3install_updatebase -{ - public $sModKey = 'd3_geoip'; - public $sModName = 'GeoIP'; - public $sModVersion = '3.0.1.0'; - public $sModRevision = '67'; - public $sBaseConf = '5FibjlIQlRvbWMzY29mVi85RXFxbkc5bFI3R24rNkd5Y0lEcXJFOGhtaGExRVcyaEF6a281cVhRUXFMU -0d6dnNDbCtLRVdObFh3bnVEdUNRTFJrVlE5VGtsRkF3Tyt4TU1Pd290WDliOTQ2SUE5Skk0eTcxTGdlT -XZna0dhS2ZOekJUSC94ZUd5YmxXZzRXcG5QSWcvZnFJa1l0N1MrdWRZaFU1VG5nUGFwNEF1WTh6azNja -Gs3SmtzQ05SVjROSGdSZ2N0S3Q1TTV1RGlCSU5RZnh1dGVNNVd6bTBzMU1FdHFiNytJQldBRjRTNmx3U -VVlRkhrRzYxYUtpaWNBOUUrLzZ2YjN5SDM1cllVMTIrYUFPRnRYcFpibHVBQytEQVFnNFV0RWpFZXAwd -FE9'; - public $sRequirements = ''; - public $sBaseValue = ''; - - protected $_aUpdateMethods = array( - array('check' => 'checkGeoIpTableExist', - 'do' => 'updateGeoIpTableExist'), - array('check' => 'checkGeoIpItems', - 'do' => 'updateGeoIpItems'), - array('check' => 'checkModCfgItemExist', - 'do' => 'updateModCfgItemExist'), - array('check' => 'checkGeoIpFields', - 'do' => 'fixGeoIpFields'), - array('check' => 'checkIndizes', - 'do' => 'fixIndizes'), - array('check' => 'hasUnregisteredFiles', - 'do' => 'showUnregisteredFiles'), - array('check' => 'checkRegisteredComponent', - 'do' => 'registerComponent'), - array('check' => 'checkModCfgSameRevision', - 'do' => 'updateModCfgSameRevision'), - ); - - // Standardwerte für checkMultiLangTables() und fixRegisterMultiLangTables() - public $aMultiLangTables = array(); - - public $aFields = array( - 'D3GEOIPSHOP' => array( - 'sTableName' => 'oxcountry', - 'sFieldName' => 'D3GEOIPSHOP', - 'sType' => 'VARCHAR(10)', - 'blNull' => false, - 'sDefault' => 'oxbaseshop', - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3GEOIPLANG' => array( - 'sTableName' => 'oxcountry', - 'sFieldName' => 'D3GEOIPLANG', - 'sType' => 'TINYINT(2)', - 'blNull' => false, - 'sDefault' => '-1', - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3GEOIPCUR' => array( - 'sTableName' => 'oxcountry', - 'sFieldName' => 'D3GEOIPCUR', - 'sType' => 'TINYINT(2)', - 'blNull' => false, - 'sDefault' => '-1', - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3GEOIPURL' => array( - 'sTableName' => 'oxcountry', - 'sFieldName' => 'D3GEOIPURL', - 'sType' => 'VARCHAR(255)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3STARTIP' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3STARTIP', - 'sType' => 'VARCHAR(39)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3ENDIP' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3ENDIP', - 'sType' => 'VARCHAR(39)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3STARTIPNUM' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3STARTIPNUM', - 'sType' => 'DECIMAL(38,0)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3ENDIPNUM' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3ENDIPNUM', - 'sType' => 'DECIMAL(38,0)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3ISO' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3ISO', - 'sType' => 'CHAR(2)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - 'D3COUNTRYNAME' => array( - 'sTableName' => 'd3geoip', - 'sFieldName' => 'D3COUNTRYNAME', - 'sType' => 'VARCHAR(50)', - 'blNull' => false, - 'sDefault' => false, - 'sComment' => '', - 'sExtra' => '', - 'blMultilang' => false, - ), - ); - - public $aIndizes = array( - 'IPNUM' => array( - 'sTableName' => 'd3geoip', - 'sType' => 'INDEX', - 'sName' => 'IPNUM', - 'aFields' => array( - 'D3STARTIPNUM' => 'D3STARTIPNUM', - 'D3ENDIPNUM' => 'D3ENDIPNUM', - ), - ), - 'D3ISO' => array( - 'sTableName' => 'd3geoip', - 'sType' => 'INDEX', - 'sName' => 'D3ISO', - 'aFields' => array( - 'D3ISO' => 'D3ISO', - ), - ), - ); - - /** - * @return bool - */ - public function checkGeoIpTableExist() - { - return $this->_checkTableNotExist('d3geoip'); - } - - /** - * @return bool - */ - public function updateGeoIpTableExist() - { - $blRet = false; - if ($this->checkGeoIpTableExist()) { - $blRet = $this->_addTable2('d3geoip', $this->aFields, $this->aIndizes, 'GeoIP', 'MyISAM'); - } - - return $blRet; - } - - /** - * @return bool - */ - public function checkGeoIpItems() - { - /** @var $oShop oxshop */ - $aWhere = array( - 'D3ISO' => 'DE', - ); - - $blRet = $this->_checkTableItemNotExist('d3geoip', $aWhere); - - return $blRet; - } - - /** - * @return bool - */ - public function updateGeoIpItems() - { - return $this->_confirmMessage('D3_GEOIP_UPDATE_ITEMINSTALL'); - } - - /** - * @return bool - */ - public function checkModCfgItemExist() - { - $blRet = false; - foreach ($this->getShopList() as $oShop) { - /** @var $oShop oxshop */ - $aWhere = array( - 'oxmodid' => $this->sModKey, - 'oxnewrevision' => $this->sModRevision, - 'oxshopid' => $oShop->getId(), - ); - - $blRet = $this->_checkTableItemNotExist('d3_cfg_mod', $aWhere); - - if ($blRet) { - return $blRet; - } - } - - return $blRet; - } - - /** - * @return bool - */ - public function updateModCfgItemExist() - { - $blRet = false; - - if ($this->checkModCfgItemExist()) { - foreach ($this->getShopList() as $oShop) { - /** @var $oShop oxshop */ - $aWhere = array( - 'oxmodid' => $this->sModKey, - 'oxshopid' => $oShop->getId(), - 'oxnewrevision' => $this->sModRevision, - ); - - if ($this->_checkTableItemNotExist('d3_cfg_mod', $aWhere)) { - // update don't use this property - unset($aWhere['oxnewrevision']); - - $aInsertFields = array( - array ( - 'fieldname' => 'OXID', - 'content' => "md5('" . $this->sModKey . " " . $oShop->getId() . " de')", - 'force_update' => true, - 'use_quote' => false, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXSHOPID', - 'content' => $oShop->getId(), - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXMODID', - 'content' => $this->sModKey, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXNAME', - 'content' => $this->sModName, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXACTIVE', - 'content' => "0", - 'force_update' => false, - 'use_quote' => false, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXBASECONFIG', - 'content' => $this->sBaseConf, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXSERIAL', - 'content' => "", - 'force_update' => false, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXINSTALLDATE', - 'content' => "NOW()", - 'force_update' => true, - 'use_quote' => false, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXVERSION', - 'content' => $this->sModVersion, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXSHOPVERSION', - 'content' => oxRegistry::getConfig()->getEdition(), - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array ( - 'fieldname' => 'OXREQUIREMENTS', - 'content' => $this->sRequirements, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ), - array( - 'fieldname' => 'OXVALUE', - 'content' => $this->sBaseValue, - 'force_update' => false, - 'use_quote' => true, - 'use_multilang' => false, - ), - array( - 'fieldname' => 'OXNEWREVISION', - 'content' => $this->sModRevision, - 'force_update' => true, - 'use_quote' => true, - 'use_multilang' => false, - ) - ); - $blRet = $this->_updateTableItem2('d3_cfg_mod', $aInsertFields, $aWhere); - - if ($this->getStepByStepMode()) { - break; - } - } - } - } - return $blRet; - } - - /** - * change default value for shop id in EE - * @return bool - */ - public function checkGeoIpFields() - { - /** @var $oShop oxshop */ - $oShop = $this->getShopList()->current(); - $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); - - return $this->checkFields(); - } - - /** - * change default value for shop id in EE - * @return bool - */ - public function fixGeoIpFields() - { - /** @var $oShop oxshop */ - $oShop = $this->getShopList()->current(); - $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); - - return $this->fixFields(); - } - - /** - * @return bool - */ - public function hasUnregisteredFiles() - { - return $this->_hasUnregisteredFiles('d3geoip', array('d3FileRegister')); - } - - /** - * @return bool - */ - public function showUnregisteredFiles() - { - return $this->_showUnregisteredFiles('d3geoip', array('d3FileRegister')); - } - - /** - * @return bool - */ - public function checkRegisteredComponent() - { - $sVarName = 'aUserComponentNames'; - $sModuleId = ''; - /** @var $oShop oxshop */ - foreach ($this->getShopListByActiveModule('d3geoip') as $oShop) { - /** @var array $aUserComponents */ - $aUserComponents = oxRegistry::getConfig()->getShopConfVar($sVarName, $oShop->getId(), $sModuleId); - - if (false == $aUserComponents - || false == $aUserComponents['d3cmp_geoip'] - ) { - return true; - } - } - - return false; - } - - /** - * @return bool - */ - public function registerComponent() - { - $blRet = true; - $sVarName = 'aUserComponentNames'; - $sModuleId = ''; - - /** @var $oShop oxshop */ - foreach ($this->getShopList() as $oShop) { - $aUserComponents = oxRegistry::getConfig()->getShopConfVar($sVarName, $oShop->getId(), $sModuleId); - if (false == $aUserComponents) { - $aUserComponents = array(); - } - - if (false == $aUserComponents['d3cmp_geoip']) { - $blDontUseCache = 1; - $aUserComponents['d3cmp_geoip'] = $blDontUseCache; - $this->fixOxconfigVariable($sVarName, $oShop->getId(), '', $aUserComponents, 'arr'); - } - } - - return $blRet; - } -} + + * @link http://www.oxidmodule.com + */ + +class d3geoip_update extends d3install_updatebase +{ + public $sModKey = 'd3_geoip'; + public $sModName = 'GeoIP'; + public $sModVersion = '3.0.2.1'; + public $sModRevision = '75'; + public $sBaseConf = 'sw2M1p3STcxMXh0eDhyR1A3YUJDMDVDakZUM2FnakVDOWdwRm9SQzFiMzhqUEtNTTFXK2ZmSlhqd1k2a +DJiSi9QSjRTQUhwOXgrMzVOOVRKRWM1c1FUci9OMUtJR2xxQ0JUTzd3V3FaSEFneGRRL3FOOU1sS09ib +FpDSjBrTUJDQTh6R2pScnZpOXphaUtlZUovQ1UzNlN5di9LeXBIYmlTQzRTRlA0czRBRmVibzZOY1R1V +lNZVUE1R3hTa2drOGx0a09HN3JhMkx1OVJvcnN5OHUvbVhqWUVURVhGanBva29GOUY3amNTcXhsTVdRM +W8vRWJtYW9IY0NqdDBlSEtwOFRJMGQ1OElxeG13bDVySGFub1ovYkkrWEtvSm1HY3RMVXlPd0pJU2dmW +Vk9'; + public $sRequirements = ''; + public $sBaseValue = ''; + + protected $_aUpdateMethods = array( + array('check' => 'checkGeoIpTableExist', + 'do' => 'updateGeoIpTableExist'), + array('check' => 'checkGeoIpItems', + 'do' => 'updateGeoIpItems'), + array('check' => 'checkModCfgItemExist', + 'do' => 'updateModCfgItemExist'), + array('check' => 'checkGeoIpFields', + 'do' => 'fixGeoIpFields'), + array('check' => 'checkIndizes', + 'do' => 'fixIndizes'), + array('check' => 'hasUnregisteredFiles', + 'do' => 'showUnregisteredFiles'), + array('check' => 'checkRegisteredComponent', + 'do' => 'unregisterComponent'), + array('check' => 'checkModCfgSameRevision', + 'do' => 'updateModCfgSameRevision'), + ); + + // Standardwerte für checkMultiLangTables() und fixRegisterMultiLangTables() + public $aMultiLangTables = array(); + + public $aFields = array( + 'D3GEOIPSHOP' => array( + 'sTableName' => 'oxcountry', + 'sFieldName' => 'D3GEOIPSHOP', + 'sType' => 'VARCHAR(10)', + 'blNull' => false, + 'sDefault' => 'oxbaseshop', + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3GEOIPLANG' => array( + 'sTableName' => 'oxcountry', + 'sFieldName' => 'D3GEOIPLANG', + 'sType' => 'TINYINT(2)', + 'blNull' => false, + 'sDefault' => '-1', + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3GEOIPCUR' => array( + 'sTableName' => 'oxcountry', + 'sFieldName' => 'D3GEOIPCUR', + 'sType' => 'TINYINT(2)', + 'blNull' => false, + 'sDefault' => '-1', + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3GEOIPURL' => array( + 'sTableName' => 'oxcountry', + 'sFieldName' => 'D3GEOIPURL', + 'sType' => 'VARCHAR(255)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3STARTIP' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3STARTIP', + 'sType' => 'VARCHAR(39)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3ENDIP' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3ENDIP', + 'sType' => 'VARCHAR(39)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3STARTIPNUM' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3STARTIPNUM', + 'sType' => 'DECIMAL(38,0)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3ENDIPNUM' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3ENDIPNUM', + 'sType' => 'DECIMAL(38,0)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3ISO' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3ISO', + 'sType' => 'CHAR(2)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + 'D3COUNTRYNAME' => array( + 'sTableName' => 'd3geoip', + 'sFieldName' => 'D3COUNTRYNAME', + 'sType' => 'VARCHAR(50)', + 'blNull' => false, + 'sDefault' => false, + 'sComment' => '', + 'sExtra' => '', + 'blMultilang' => false, + ), + ); + + public $aIndizes = array( + 'IPNUM' => array( + 'sTableName' => 'd3geoip', + 'sType' => 'INDEX', + 'sName' => 'IPNUM', + 'aFields' => array( + 'D3STARTIPNUM' => 'D3STARTIPNUM', + 'D3ENDIPNUM' => 'D3ENDIPNUM', + ), + ), + 'D3ISO' => array( + 'sTableName' => 'd3geoip', + 'sType' => 'INDEX', + 'sName' => 'D3ISO', + 'aFields' => array( + 'D3ISO' => 'D3ISO', + ), + ), + ); + + /** + * @return bool + */ + public function checkGeoIpTableExist() + { + return $this->_checkTableNotExist('d3geoip'); + } + + /** + * @return bool + */ + public function updateGeoIpTableExist() + { + $blRet = false; + if ($this->checkGeoIpTableExist()) { + $blRet = $this->_addTable2('d3geoip', $this->aFields, $this->aIndizes, 'GeoIP', 'MyISAM'); + } + + return $blRet; + } + + /** + * @return bool + */ + public function checkGeoIpItems() + { + /** @var $oShop oxshop */ + $aWhere = array( + 'D3ISO' => 'DE', + ); + + $blRet = $this->_checkTableItemNotExist('d3geoip', $aWhere); + + return $blRet; + } + + /** + * @return bool + */ + public function updateGeoIpItems() + { + return $this->_confirmMessage('D3_GEOIP_UPDATE_ITEMINSTALL'); + } + + /** + * @return bool + */ + public function checkModCfgItemExist() + { + $blRet = false; + foreach ($this->getShopList() as $oShop) { + /** @var $oShop oxshop */ + $aWhere = array( + 'oxmodid' => $this->sModKey, + 'oxnewrevision' => $this->sModRevision, + 'oxshopid' => $oShop->getId(), + ); + + $blRet = $this->_checkTableItemNotExist('d3_cfg_mod', $aWhere); + + if ($blRet) { + return $blRet; + } + } + + return $blRet; + } + + /** + * @return bool + */ + public function updateModCfgItemExist() + { + $blRet = false; + + if ($this->checkModCfgItemExist()) { + foreach ($this->getShopList() as $oShop) { + /** @var $oShop oxshop */ + $aWhere = array( + 'oxmodid' => $this->sModKey, + 'oxshopid' => $oShop->getId(), + 'oxnewrevision' => $this->sModRevision, + ); + + if ($this->_checkTableItemNotExist('d3_cfg_mod', $aWhere)) { + // update don't use this property + unset($aWhere['oxnewrevision']); + + $aInsertFields = array( + array ( + 'fieldname' => 'OXID', + 'content' => "md5('" . $this->sModKey . " " . $oShop->getId() . " de')", + 'force_update' => true, + 'use_quote' => false, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXSHOPID', + 'content' => $oShop->getId(), + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXMODID', + 'content' => $this->sModKey, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXNAME', + 'content' => $this->sModName, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXACTIVE', + 'content' => "0", + 'force_update' => false, + 'use_quote' => false, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXBASECONFIG', + 'content' => $this->sBaseConf, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXSERIAL', + 'content' => "", + 'force_update' => false, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXINSTALLDATE', + 'content' => "NOW()", + 'force_update' => true, + 'use_quote' => false, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXVERSION', + 'content' => $this->sModVersion, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXSHOPVERSION', + 'content' => oxRegistry::getConfig()->getEdition(), + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array ( + 'fieldname' => 'OXREQUIREMENTS', + 'content' => $this->sRequirements, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ), + array( + 'fieldname' => 'OXVALUE', + 'content' => $this->sBaseValue, + 'force_update' => false, + 'use_quote' => true, + 'use_multilang' => false, + ), + array( + 'fieldname' => 'OXNEWREVISION', + 'content' => $this->sModRevision, + 'force_update' => true, + 'use_quote' => true, + 'use_multilang' => false, + ) + ); + $blRet = $this->_updateTableItem2('d3_cfg_mod', $aInsertFields, $aWhere); + + if ($this->getStepByStepMode()) { + break; + } + } + } + } + return $blRet; + } + + /** + * change default value for shop id in EE + * @return bool + */ + public function checkGeoIpFields() + { + /** @var $oShop oxshop */ + $oShop = $this->getShopList()->current(); + $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); + + return $this->checkFields(); + } + + /** + * change default value for shop id in EE + * @return bool + */ + public function fixGeoIpFields() + { + /** @var $oShop oxshop */ + $oShop = $this->getShopList()->current(); + $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); + + return $this->fixFields(); + } + + /** + * @return bool + */ + public function hasUnregisteredFiles() + { + return $this->_hasUnregisteredFiles('d3geoip', array('d3FileRegister')); + } + + /** + * @return bool + */ + public function showUnregisteredFiles() + { + return $this->_showUnregisteredFiles('d3geoip', array('d3FileRegister')); + } + + /** + * @return bool + */ + public function checkRegisteredComponent() + { + /** @var $oShop oxshop */ + foreach ($this->getShopListByActiveModule('d3geoip') as $oShop) { + $aUserComponents = $this->_d3GetUserComponentsFromDb($oShop); + + if (is_array($aUserComponents) + && in_array('d3cmp_geoip', array_keys($aUserComponents)) + ) { + return true; + } + } + + return false; + } + + /** + * @return bool + */ + public function unregisterComponent() + { + $blRet = true; + $sVarName = 'aUserComponentNames'; + + /** @var $oShop oxshop */ + foreach ($this->getShopList() as $oShop) { + $aUserComponents = $this->_d3GetUserComponentsFromDb($oShop); + + if (is_array($aUserComponents) + && in_array('d3cmp_geoip', array_keys($aUserComponents)) + ) { + unset($aUserComponents['d3cmp_geoip']); + if (false == count($aUserComponents)) { + $aUserComponents = null; + } + $this->fixOxconfigVariable($sVarName, $oShop->getId(), '', $aUserComponents, 'arr'); + } + } + + return $blRet; + } + + /** + * @param oxShop $oShop + * @return array|null + */ + protected function _d3GetUserComponentsFromDb(oxShop $oShop) + { + $sVarName = 'aUserComponentNames'; + $sModuleId = ''; + $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC); + $sSelect = "SELECT oxvartype as type, ".oxRegistry::getConfig()->getDecodeValueQuery(). + " as value FROM `oxconfig` WHERE oxshopid = ".$oDb->quote($oShop->getId()). + " AND oxvarname = ".$oDb->quote($sVarName). + " AND oxmodule = ".$oDb->quote($sModuleId); + + $aResult = $oDb->getAll($sSelect); + $aUserComponents = is_array($aResult) && count($aResult) + ? oxRegistry::getConfig()->decodeValue($aResult[0]['type'], $aResult[0]['value']) + : null; + + return $aUserComponents; + } +} diff --git a/setup+doku/Installation.pdf b/setup+doku/Installation.pdf index ce74526..014640b 100644 Binary files a/setup+doku/Installation.pdf and b/setup+doku/Installation.pdf differ diff --git a/setup+doku/Precheck/d3precheck.php b/setup+doku/Precheck/d3precheck.php index 5e1bcbc..f8b5bae 100644 --- a/setup+doku/Precheck/d3precheck.php +++ b/setup+doku/Precheck/d3precheck.php @@ -43,7 +43,7 @@ class requConfig public $sModId = 'd3_geoip'; - public $sModVersion = '3.0.1.0'; + public $sModVersion = '3.0.2.1'; /********************** check configuration section ************************/ @@ -68,7 +68,7 @@ class requConfig 'hasFromToPhpVersion' => array( 'blExec' => 1, 'aParams' => array( - 'from' => '5.2.0', + 'from' => '5.3.0', 'to' => '5.6.200', ) ), @@ -103,9 +103,9 @@ class requConfig 'hasMinShopVersion' => array( 'blExec' => 1, 'aParams' => array( - 'PE' => '4.7.0', - 'CE' => '4.7.0', - 'EE' => '5.0.0' + 'PE' => '4.8.0', + 'CE' => '4.8.0', + 'EE' => '5.1.0' ), ), @@ -113,9 +113,9 @@ class requConfig 'hasMaxShopVersion' => array( 'blExec' => 1, 'aParams' => array( - 'PE' => '4.9.6', - 'CE' => '4.9.6', - 'EE' => '5.2.6' + 'PE' => '4.9.7', + 'CE' => '4.9.7', + 'EE' => '5.2.7' ), ), @@ -182,7 +182,7 @@ date_default_timezone_set('Europe/Berlin'); */ class requCheck { - public $sVersion = '4.6.2'; + public $sVersion = '4.7.1'; protected $_db = false; @@ -287,22 +287,41 @@ class requCheck $aIgnoreDirItems = array('.', '..'); $aCheckScripts = array(); - /** @var SplFileInfo $oFileInfo */ - foreach (new RecursiveDirectoryIterator($sFolder) as $oFileInfo) { - if (in_array($oFileInfo->getFileName(), $aIgnoreDirItems)) { - continue; - } - if ($oFileInfo->isDir()) { - $aCheckScripts = array_merge($aCheckScripts, $this->_walkThroughDirs($oFileInfo->getRealPath())); - } elseif ($oFileInfo->isFile()) { - if (strtolower($oFileInfo->getFilename()) == $this->_sInFolderFileName) { - $aCheckScripts[] = str_replace('\\', '/', $oFileInfo->getRealPath()); + try { + /** @var SplFileInfo $oFileInfo */ + $oIterator = new RecursiveDirectoryIterator($sFolder); + + foreach ($oIterator as $oFileInfo) { + if (in_array($oFileInfo->getFileName(), $aIgnoreDirItems)) { + continue; + } + if ($oFileInfo->isDir()) { + $aCheckScripts = array_merge($aCheckScripts, $this->_walkThroughDirs($oFileInfo->getRealPath())); + } elseif ($oFileInfo->isFile()) { + if (strtolower($oFileInfo->getFilename()) == $this->_sInFolderFileName) { + $aCheckScripts[] = str_replace('\\', '/', $oFileInfo->getRealPath()); + } } } + } catch (UnexpectedValueException $oEx) { + sprintf($this->oLayout->translate('unableExecuteDirectoryIterator'), $oEx->getMessage()); + $this->addMessage( + sprintf($this->oLayout->translate('unableExecuteDirectoryIterator'), $oEx->getMessage()) + ); } return $aCheckScripts; } + + public function addMessage($sMessage) + { + $this->aMessages[md5($sMessage)] = $sMessage; + } + + public function getMessages() + { + return $this->aMessages; + } /** * @param $aScriptList @@ -378,15 +397,17 @@ class requCheck */ protected function _getContentByCurl($sUrl) { + $iTimeOut = 5; $ch = curl_init(); $sCurl_URL = preg_replace('@^((http|https)://)@', '', $sUrl); + curl_setopt($ch, CURLOPT_URL, $sCurl_URL); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $iTimeOut); + curl_setopt($ch, CURLOPT_TIMEOUT, $iTimeOut); curl_setopt($ch, CURLOPT_POST, 0); $sContent = curl_exec($ch); curl_close($ch); @@ -722,6 +743,7 @@ class requLayout $sTranslRequCheck "$sModName" $sModVersion + @@ -867,6 +899,14 @@ EOT; $sScriptName = $_SERVER['SCRIPT_NAME']; $sTranslShopPhpInfo = $this->translate('showPhpInfo'); $sTranslDependent = $this->translate('dependentoffurther'); + + if (count($this->oBase->getMessages())) { + echo ''; + } if ($this->oBase->blGlobalResult) { echo '

' . $this->translate('globalSuccess') . '' . @@ -1445,6 +1485,8 @@ class requTranslations 'unableDeleteFile' => 'Datei konnte nicht gelöscht werden. Bitte löschen Sie diese '. 'manuell.', 'goodBye' => 'Auf Wiedersehen.', + 'unableExecuteDirectoryIterator' => 'Es können nicht alle Unterverzeichnisse auf weitere Prüfungen '. + 'kontrolliert werden. (%1$s)', ), 'en' => array( 'RequCheck' => 'Requirement check', @@ -1610,6 +1652,7 @@ class requTranslations 'toggleswitch' => 'click for details', 'unableDeleteFile' => 'Unable to delete file. Please delete it manually.', 'goodBye' => 'Good Bye.', + 'unableExecuteDirectoryIterator' => 'Unable to check subdirectories for further checks. (%1$s)', ), ); } diff --git a/setup+doku/changelog.txt b/setup+doku/changelog.txt index 0ddea11..d9f51d3 100644 --- a/setup+doku/changelog.txt +++ b/setup+doku/changelog.txt @@ -1,3 +1,9 @@ +=> 3.0.2.1 +- Sprachumschalter wird sofort bei erstem Shopaufruf umgesetzt + +=> 3.0.2.0 +- Komponente wird dynamisch eingebunden, um bei deaktiviertem Modul keine Exception auszulösen + => 3.0.1.0 - Kompatibilität mit OXID Dynamic Content Cache hergestellt - prüft IP-Syntax bei Eingabe im Adminbereich diff --git a/sources/GeoIP-Installation.docx b/sources/GeoIP-Installation.docx index 9278cbf..d1ccf4e 100644 Binary files a/sources/GeoIP-Installation.docx and b/sources/GeoIP-Installation.docx differ