* @link http://www.oxidmodule.com */ namespace D3\ModCfg\setup; use D3\ModCfg\Application\Model\d3filesystem; use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; use D3\ModCfg\Application\Model\Install\d3install; use Doctrine\DBAL\DBALException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\StandardException; use OxidEsales\Eshop\Core\Exception\SystemComponentException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Request; class Events { public static $_ConfirmParamName = 'd3confirm'; /** * @throws DatabaseConnectionException * @throws StandardException * @throws SystemComponentException * @throws DBALException * @throws DatabaseErrorException * @throws d3ShopCompatibilityAdapterException */ public static function onActivate() { /** @var Request $request */ $request = Registry::get(Request::class); if ( ( $request->getRequestEscapedParameter('cl') === 'module_config' && $request->getRequestEscapedParameter('fnc') === 'save' ) ) { return; } d3install::checkUpdateStart(); } public static function onDeactivate() { /** @var Request $request */ $request = Registry::get(Request::class); if (defined('OXID_PHP_UNIT') || (bool) $request->getRequestEscapedParameter(self::$_ConfirmParamName) == true || php_sapi_name() === 'cli' || ( $request->getRequestEscapedParameter('cl') === 'module_config' && $request->getRequestEscapedParameter('fnc') === 'save' ) ) { return; } $sConfirmUrl = self::getConfirmUrl(); $sCancelUrl = self::getCancelUrl(); echo " "; die(); } /** * @return string */ public static function getCurrentUrl() { /** @var d3filesystem $oFS */ $oFS = oxNew(d3filesystem::class); return $oFS->getCurrentUrl(); } /** * @return string */ public static function getConfirmUrl() { return self::getCurrentUrl().'&'.self::$_ConfirmParamName.'=true'; } /** * @return string */ public static function getCancelUrl() { $aUrl = parse_url(self::getCurrentUrl()); parse_str($aUrl['query'], $aParams); $aParamsKeys = array_keys($aParams); $aLowerKeys = array_map('strtolower', $aParamsKeys); $iKey = array_search('fnc', $aLowerKeys); $sSearch = $aParamsKeys[$iKey]."=".$aParams[$aParamsKeys[$iKey]]; $aUrl['query'] = str_replace($sSearch, '', $aUrl['query']); $sPort = $aUrl['port']?':'.$aUrl['port']:''; $sCurrUrl = $aUrl['scheme'].'://'.$aUrl['host'].$sPort.$aUrl['path'].'?'.$aUrl['query']; return $sCurrUrl; } }