change component registration to dynamic, module can disabled without errors
This commit is contained in:
parent
6bcc9d5b97
commit
bf3865f089
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
|
||||
copyAsIsFiles = modules/d3/d3geoip/components, modules/d3/d3geoip/controllers, modules/d3/d3geoip/models/d3geoip_update.php, modules/d3/d3geoip/modules/controllers, modules/d3/d3geoip/views, modules/d3/d3geoip/IntelliSenseHelper.php, modules/d3/d3geoip/metadata.php
|
@ -19,7 +19,9 @@ $aModule = array(
|
||||
'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',
|
||||
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
* by copyright law - it is NOT Freeware.
|
||||
*
|
||||
* Any unauthorized use of this software without a valid license
|
||||
* is a violation of the license agreement and will be prosecuted by
|
||||
* civil and criminal law.
|
||||
*
|
||||
* http://www.shopmodule.com
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||
* @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__);
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ FE9';
|
||||
array('check' => 'hasUnregisteredFiles',
|
||||
'do' => 'showUnregisteredFiles'),
|
||||
array('check' => 'checkRegisteredComponent',
|
||||
'do' => 'registerComponent'),
|
||||
'do' => 'unregisterComponent'),
|
||||
array('check' => 'checkModCfgSameRevision',
|
||||
'do' => 'updateModCfgSameRevision'),
|
||||
);
|
||||
@ -413,15 +413,12 @@ FE9';
|
||||
*/
|
||||
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);
|
||||
$aUserComponents = $this->_d3GetUserComponentsFromDb($oShop);
|
||||
|
||||
if (false == $aUserComponents
|
||||
|| false == $aUserComponents['d3cmp_geoip']
|
||||
if (is_array($aUserComponents)
|
||||
&& in_array('d3cmp_geoip', array_keys($aUserComponents))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@ -433,26 +430,48 @@ FE9';
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function registerComponent()
|
||||
public function unregisterComponent()
|
||||
{
|
||||
$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();
|
||||
}
|
||||
$aUserComponents = $this->_d3GetUserComponentsFromDb($oShop);
|
||||
|
||||
if (false == $aUserComponents['d3cmp_geoip']) {
|
||||
$blDontUseCache = 1;
|
||||
$aUserComponents['d3cmp_geoip'] = $blDontUseCache;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user