Comparer les révisions

...

7 Révisions

6 fichiers modifiés avec 134 ajouts et 47 suppressions

Voir le fichier

@ -1,5 +1,13 @@
# Changelog
- 4.1.2.0
- verwendet Assertions für Bedingungsprüfung
- fehlerhaften Methodenaufruf korrigiert
- 4.1.1.0
- Support für OXID 6.5.2
- Logging erweitert
- 4.1.0.0
- Support für OXID 6.4 und 6.5
- Support für OXID < 6.3 entfernt

Voir le fichier

@ -36,8 +36,9 @@
}
},
"require": {
"oxid-esales/oxideshop-ce": "6.8 - 6.12",
"d3/modcfg": "^6"
"oxid-esales/oxideshop-ce": "6.8 - 6.14",
"d3/modcfg": "^6",
"beberlei/assert": "^3.3"
},
"autoload": {
"psr-4": {

Voir le fichier

@ -1,4 +1,5 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
@ -16,6 +17,8 @@
namespace D3\GeoIp\Application\Model;
use Assert\Assert;
use Assert\InvalidArgumentException;
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use D3\ModCfg\Application\Model\d3str;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
@ -242,34 +245,38 @@ class d3geoip extends BaseModel
{
startProfile(__METHOD__);
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'start shop or url switch');
$this->performURLSwitch();
$this->performShopSwitch();
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'end shop or url switch');
if (!$this->_getModConfig()->isActive()
|| false == $this->_getModConfig()->getValue('blChangeLang')) {
|| false == $this->_getModConfig()->getValue('blChangeLang')
) {
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'language change option or module is disabled');
stopProfile(__METHOD__);
return;
}
$oCountry = $this->getUserLocationCountryObject();
if (!$this->isAdmin()
&& Registry::getUtils()->isSearchEngine() === false
&& Registry::getSession()->getId()
&& Registry::getSession()->getVariable('d3isSetLang') === null
&& $oCountry->getId() && $oCountry->getFieldData('d3geoiplang') > -1
) {
$this->_getLog()->log(
d3log::INFO,
try {
$this->canChangeLanguage( $oCountry );
$language = (int) $oCountry->getFieldData('d3geoiplang');
$this->_getModConfig()->d3getLog()->info(
__CLASS__,
__FUNCTION__,
__LINE__,
'set language',
$this->getIP().' => '.$oCountry->getFieldData('d3geoiplang')
$this->getIP().' => '.$language
);
Registry::getLang()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
Registry::getLang()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
Registry::getLang()->setTplLanguage($language);
Registry::getLang()->setBaseLanguage($language);
Registry::getSession()->setVariable('d3isSetLang', true);
Registry::getLogger()->debug('language set', [$language]);
} catch (InvalidArgumentException $e) {
Registry::getLogger()->debug($e->getMessage(), [$oCountry]);
}
stopProfile(__METHOD__);
@ -297,12 +304,9 @@ class d3geoip extends BaseModel
$oCountry = $this->getUserLocationCountryObject();
if (!$this->isAdmin()
&& Registry::getUtils()->isSearchEngine() === false
&& !Registry::getSession()->getVariable('d3isSetCurr')
&& $oCountry->getId()
&& $oCountry->getFieldData('d3geoipcur') > -1
) {
try {
$this->canChangeCurrency( $oCountry );
$this->_getLog()->log(
d3log::INFO,
__CLASS__,
@ -313,6 +317,8 @@ class d3geoip extends BaseModel
);
Registry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
Registry::getSession()->setVariable('d3isSetCurr', true);
} catch (InvalidArgumentException $e) {
Registry::getLogger()->debug($e->getMessage(), [$oCountry]);
}
stopProfile(__METHOD__);
@ -354,6 +360,7 @@ class d3geoip extends BaseModel
public function performShopSwitch()
{
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeShop')) {
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'shop change option or module is disabled');
return;
}
@ -362,17 +369,12 @@ class d3geoip extends BaseModel
$oCountry = $this->getUserLocationCountryObject();
$iNewShop = $oCountry->getFieldData('d3geoipshop');
if (Registry::getRequest()->getRequestEscapedParameter('d3redirect') != 1
&& false == $this->isAdmin()
&& Registry::getUtils()->isSearchEngine() === false
&& $oCountry->getId()
&& Registry::getConfig()->isMall()
&& $iNewShop > -1 &&
(
$iNewShop != Registry::getConfig()->getShopId()
|| strtolower(Registry::getConfig()->getActiveView()->getClassKey()) == 'mallstart'
)
) {
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'check allowed shop change');
try {
$this->canChangeShop( $oCountry, $iNewShop );
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'prepare shop change to '.$iNewShop);
$oNewConf = new Config();
$oNewConf->setShopId($iNewShop);
$oNewConf->init();
@ -410,8 +412,12 @@ class d3geoip extends BaseModel
$this->getIP().' => '.$sUrl
);
$this->_getModConfig()->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'change to shop url', $sUrl);
header("Location: ".$sUrl);
exit();
} catch (InvalidArgumentException $e) {
Registry::getLogger()->debug($e->getMessage(), [$oCountry]);
}
stopProfile(__METHOD__);
@ -442,13 +448,9 @@ class d3geoip extends BaseModel
$oCountry = $this->getUserLocationCountryObject();
if ($this->dontSkipUrlRedirect()
&& false == $this->isAdmin()
&& Registry::getUtils()->isSearchEngine() === false
&& $oCountry->getId()
&& $oCountry->getFieldData('d3geoipurl')
&& strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0
) {
try {
$this->canRedirect( $oCountry );
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
$this->_getLog()->log(
@ -462,6 +464,8 @@ class d3geoip extends BaseModel
header("Location: ".$sNewUrl);
exit();
} catch (InvalidArgumentException $e) {
Registry::getLogger()->debug($e->getMessage(), [$oCountry]);
}
stopProfile(__METHOD__);
@ -529,5 +533,77 @@ class d3geoip extends BaseModel
return $this->oD3Log;
}
/**
* @param Country $oCountry
*
* @throws InvalidArgumentException
*/
protected function canRedirect( Country $oCountry )
{
Assert::that($this->dontSkipUrlRedirect())->true('redirect skip is not provided');
$this->isUserInFrontend();
Assert::that($oCountry->getId())->notBlank('no country loaded');
Assert::that($oCountry->getFieldData( 'd3geoipurl' ))->notBlank('no redirect url set');
}
/**
* @param Country $oCountry
*
* @return bool
*/
/**
* @param Country $oCountry
*
* @throws InvalidArgumentException
*/
protected function canChangeLanguage( Country $oCountry )
{
$this->isUserInFrontend();
Assert::that(Registry::getSession()->getVariable( 'd3isSetLang' ))->null('language already set');
Assert::that($oCountry->getId())->notBlank('no country loaded');
Assert::that($oCountry->getFieldData( 'd3geoiplang' ))->greaterThan(-1, 'no target language set');
}
/**
* @param Country $oCountry
*
* @throws InvalidArgumentException
*/
protected function canChangeCurrency( Country $oCountry )
{
$this->isUserInFrontend();
Assert::that(Registry::getSession()->getVariable( 'd3isSetCurr' ))->null('currency already set');
Assert::that($oCountry->getId())->notBlank('no country loaded');
Assert::that($oCountry->getFieldData( 'd3geoipcur' ))->greaterThan(-1, 'no target currency set');
}
/**
* @param Country $oCountry
* @param $iNewShop
*
* @throws InvalidArgumentException
*/
protected function canChangeShop( Country $oCountry, $iNewShop )
{
Assert::that(Registry::getRequest()->getRequestEscapedParameter( 'd3redirect' ))->notSame('1', 'redirect already performed');
$this->isUserInFrontend();
Assert::that($oCountry->getId())->notBlank('no country loaded');
Assert::that(Registry::getConfig()->isMall())->true('no mall installation');
Assert::that($iNewShop)->greaterThan(-1, 'no target shop id set');
Assert::that(
$iNewShop != Registry::getConfig()->getShopId() ||
strtolower( Registry::getConfig()->getActiveView()->getClassKey() ) == 'mallstart'
)->true('no different shop and no mallstart');
}
/**
* @throws InvalidArgumentException
*/
protected function isUserInFrontend()
{
Assert::that($this->isAdmin())->false('User is in admin');
Assert::that(Registry::getUtils()->isSearchEngine())->false('User is search engine');
}
}

Voir le fichier

@ -43,7 +43,9 @@ class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
if (d3_cfg_mod::get($this->_sModId)->isActive()) {
/** @var $oLocation d3geoip */
$oLocation = oxNew(d3geoip::class);
d3_cfg_mod::get($this->_sModId)->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'start perform language switch');
$oLocation->setCountryLanguage();
d3_cfg_mod::get($this->_sModId)->d3getLog()->info(__CLASS__, __FUNCTION__, __LINE__, 'end perform language switch');
}
parent::init();

Voir le fichier

@ -38,15 +38,15 @@ class d3geoip_update extends d3install_updatebase
{
public $sModKey = 'd3_geoip';
public $sModName = 'GeoIP';
public $sModVersion = '4.0.4.2';
public $sModRevision = '4042';
public $sModVersion = '4.1.2.0';
public $sModRevision = '4120';
public $sBaseConf = '--------------------------------------------------------------------------------
nW2v2==OUkzREVCV0VUMjdObzArYU1aZVRINnhkRWlPM2I0aE5TYU1yVXl3R3g1RFNIdkk0dmlxRWVjQ
zMxbzJqV0xwQ2lHY290K3UxK3A0bW5zZ2IzL2cyMmt6ckQxNjN1V0Q1eXl6K3dBcEpURUQ0WEsvYmd6T
lo4aW9QV3ZHcjF3MnZhMklUY1pabmNQWEk4QTNRQ2FNMDl5b202WTl6b2QwaktNQUpqWG84MEpBSWNVM
1dMaXZ3bTIrL1dTTW5rWHJUdXp4blZ2Y1BXRzd6Z01QVW4ybTN3MmFlQ1YyVnRZUjF5OGZKdEZheFVLT
VJqSU9aQ1FrMDhZcHZsa2Z0ekY5RzVDL0V0TUxSUEtoL29SVGppbWlqRHY5V0tlczNkMmIzVEcraDBiT
XJ5U0QrUFZyUHFnNnNBdnZOa3ZRVUZVOWk=
4I6v2==YXpDb3ovcGlNbStFUXg1UXBUR0h6aXRiS2hZMHorN3d3Q2ZjTmVWcE8yNy9COFRidHFqL0VhW
WZVS2hvY2JlQ29EcTRoaEJJQjJoVXc5M1B3TmFseXEyUHQrUHEveUtGUFdhVW5wWFc3d2xTNGcyeDE3a
DBHbFBicHR1TWxWMkxZQURFMFNnV05ubllTcGRWdkw1SlJNNmk0OVBBT3Y5N0dRb1drWXJSUStsc1Q5Z
Gh0L09EMnhVYW9FUGNGSG5jcktXSXpVeE10Tm9IT2VmQW1VSFZQWmxaMG0ycHNKeks1cUNCWnI4c1Q3M
1F2U3RMY1FsWHRRTGRRL2kzN1pTaWpKWXBlaXBFYVFTN3lOWnpnZVl5blVhWkxNMnBqT1JQT3M2cnJYT
S9kMERSZUFscmR6VW9iZlZVZjhoYzNUdWo=
--------------------------------------------------------------------------------';
public $sRequirements = '';
public $sBaseValue = '';

Voir le fichier

@ -30,7 +30,7 @@ $aModule = [
'en' => '',
],
'thumbnail' => 'picture.png',
'version' => '4.1.0.0',
'version' => '4.1.2.0',
'author' => 'D&sup3; Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',