diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b518e3e Binary files /dev/null and b/.gitattributes differ diff --git a/CHANGELOG.md b/CHANGELOG.md index a37bf01..d9690d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. --- +## 3.0.0.0 (2020-11-11) +### Changed +- Modul verwendbar in OXID 6.2, deprecated Code bestmöglich entfernt +- Anzeige von Anfragemails entfernt, da dazugehöriges Modul nicht weiter entwickelt wird + +--- + ## 2.0.1.0 (2019-10-21) ### Changed - Mails können auch Dreingabeartikel regenerieren und darstellen diff --git a/README.md b/README.md index 593147d..e4a8e6b 100644 Binary files a/README.md and b/README.md differ diff --git a/composer.json b/composer.json index f5f9125..ecc56fc 100644 --- a/composer.json +++ b/composer.json @@ -1,41 +1,43 @@ -{ - "name": "d3/devhelper", - "description": "Manipulate shop standard processes for easier development", - "type": "oxideshop-module", - "keywords": [ - "oxid", - "modules", - "eShop", - "d3", - "devhelper", - "developer", - "development", - "tools" - ], - "authors": [ - { - "name": "D3 Data Development (Inh. Thomas Dartsch)", - "email": "info@shopmodule.com", - "homepage": "http://www.d3data.de" - } - ], - "homepage": "https://www.oxidmodule.com/", - "license": [ - "proprietary" - ], - "extra": { - "oxideshop": { - "source-directory": "/src", - "target-directory": "d3/devhelper" - } - }, - "require": { - "php": ">=5.6", - "oxid-esales/oxideshop-metapackage-ce": "~6.0.0 || ~6.1.0" - }, - "autoload": { - "psr-4": { - "D3\\Devhelper\\": "../../../source/modules/d3/devhelper" - } - } -} +{ + "name": "d3/devhelper", + "description": "Manipulate shop standard processes for easier development", + "type": "oxideshop-module", + "keywords": [ + "oxid", + "modules", + "eShop", + "d3", + "devhelper", + "developer", + "development", + "tools", + "template", + "e-mail", + "thankyou" + ], + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "https://www.d3data.de" + } + ], + "homepage": "https://www.oxidmodule.com/", + "license": [ + "proprietary" + ], + "extra": { + "oxideshop": { + "source-directory": "/src", + "target-directory": "d3/devhelper" + } + }, + "require": { + "oxid-esales/oxideshop-ce": "6.5 - 6.5" + }, + "autoload": { + "psr-4": { + "D3\\Devhelper\\": "../../../source/modules/d3/devhelper" + } + } +} diff --git a/src/Application/Controller/d3dev.php b/src/Application/Controller/d3dev.php index 4a6dd42..4f1a120 100644 --- a/src/Application/Controller/d3dev.php +++ b/src/Application/Controller/d3dev.php @@ -4,6 +4,7 @@ namespace D3\Devhelper\Application\Controller; use D3\Devhelper\Modules\Application\Controller as ModuleController; use D3\Devhelper\Modules\Core as ModuleCore; +use Exception; use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Application\Controller\ThankYouController; use OxidEsales\Eshop\Application\Model\User; @@ -12,7 +13,6 @@ use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\UserException; use OxidEsales\Eshop\Core\Registry; -use OxidEsales\Eshop\Core\Request; /** * This Software is the property of Data Development and is protected @@ -41,8 +41,8 @@ class d3dev extends FrontendController protected function _authenticate () { try { - $sUser = Registry::get(Request::class)->getRequestEscapedParameter('usr'); - $sPassword = Registry::get(Request::class)->getRequestEscapedParameter('pwd'); + $sUser = Registry::getRequest()->getRequestEscapedParameter('usr'); + $sPassword = Registry::getRequest()->getRequestEscapedParameter('pwd'); if ( !$sUser || !$sPassword ) { $sUser = $_SERVER[ 'PHP_AUTH_USER' ]; @@ -67,13 +67,10 @@ class d3dev extends FrontendController } $oUser = oxNew( User::class ); if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) { - /** @var UserException $oEx */ - $oEx = oxNew( UserException::class, 'EXCEPTION_USER_NOVALIDLOGIN' ); - - throw $oEx; + throw oxNew( UserException::class, 'EXCEPTION_USER_NOVALIDLOGIN' ); } } - catch ( \Exception $oEx ) { + catch ( Exception $oEx ) { $oShop = Registry::getConfig()->getActiveShop(); header( 'WWW-Authenticate: Basic realm="' . $oShop->getFieldData('oxname') . '"' ); header( 'HTTP/1.0 401 Unauthorized' ); @@ -90,12 +87,12 @@ class d3dev extends FrontendController header('Content-type: text/html; charset='.Registry::getLang()->translateString('charset')); if (Registry::getConfig()->getActiveShop()->isProductiveMode() - || false == Registry::getConfig()->getConfigParam('blD3DevShowOrderMailsInBrowser') + || false == Registry::getConfig()->getConfigParam(ModuleCore\d3_dev_conf::OPTION_SHOWMAILSINBROWSER) ) { Registry::getUtils()->redirect(Registry::getConfig()->getShopUrl().'index.php?cl=start'); } - $sTpl = Registry::get(Request::class)->getRequestEscapedParameter('type'); + $sTpl = Registry::getRequest()->getRequestEscapedParameter('type'); /** @var ModuleController\d3_dev_thankyou $oThankyou */ $oThankyou = oxNew(ThankYouController::class); @@ -106,27 +103,4 @@ class d3dev extends FrontendController echo $oEmail->d3GetOrderMailContent($oOrder, $sTpl); die(); } - - /** - * @throws DatabaseConnectionException - */ - public function showInquiryMailContent() - { - if (Registry::getConfig()->getActiveShop()->isProductiveMode() - || false == Registry::getConfig()->getConfigParam('blD3DevShowOrderMailsInBrowser') - ) { - Registry::getUtils()->redirect(Registry::getConfig()->getShopUrl().'index.php?cl=start'); - } - - $sTpl = Registry::get(Request::class)->getRequestEscapedParameter('type'); - - /** @var ModuleController\d3_dev_thankyou $oThankyou */ - $oThankyou = oxNew(ThankYouController::class); - $oOrder = $oThankyou->d3GetLastInquiry(); - - /** @var ModuleCore\d3_dev_oxemail $oEmail */ - $oEmail = oxNew(Email::class); - echo $oEmail->d3GetInquiryMailContent($oOrder, $sTpl); - die(); - } } diff --git a/src/IntelliSenseHelper.php b/src/IntelliSenseHelper.php index bf3cdc3..38ff8e0 100644 --- a/src/IntelliSenseHelper.php +++ b/src/IntelliSenseHelper.php @@ -16,27 +16,33 @@ namespace D3\Devhelper\Modules\Application\Controller { - class d3_dev_thankyou_parent extends \OxidEsales\Eshop\Application\Controller\ThankYouController {} + use OxidEsales\Eshop\Application\Controller\ThankYouController; + + class d3_dev_thankyou_parent extends ThankYouController {} } namespace D3\Devhelper\Modules\Application\Model { - class d3_dev_oxorder_parent extends \OxidEsales\Eshop\Application\Model\Order {} + use OxidEsales\Eshop\Application\Controller\OrderController; + use OxidEsales\Eshop\Application\Model\Basket; + use OxidEsales\Eshop\Application\Model\BasketItem; + use OxidEsales\Eshop\Application\Model\Order; + use OxidEsales\Eshop\Application\Model\OrderArticle; - class d3_dev_d3inquiry_parent extends d3inquiry {} + class d3_dev_oxorder_parent extends Order {} - class d3_dev_d3inquiryarticle_parent extends d3inquiryarticle {} + class d3_dev_oxorderarticle_parent extends OrderArticle {} - class d3_dev_oxorderarticle_parent extends \OxidEsales\Eshop\Application\Model\OrderArticle {} + class d3_dev_oxbasket_parent extends Basket {} - class d3_dev_oxbasket_parent extends \OxidEsales\Eshop\Application\Model\Basket {} + class d3_dev_oxbasketitem_parent extends BasketItem {} - class d3_dev_oxbasketitem_parent extends \OxidEsales\Eshop\Application\Model\BasketItem {} - - class d3_dev_order_parent extends \OxidEsales\Eshop\Application\Controller\OrderController {} + class d3_dev_order_parent extends OrderController {} } namespace D3\Devhelper\Modules\Core { - class d3_dev_oxemail_parent extends \OxidEsales\Eshop\Core\Email {} + use OxidEsales\Eshop\Core\Email; + + class d3_dev_oxemail_parent extends Email {} } \ No newline at end of file diff --git a/src/Modules/Application/Controller/d3_dev_thankyou.php b/src/Modules/Application/Controller/d3_dev_thankyou.php index 22dc800..271c22d 100644 --- a/src/Modules/Application/Controller/d3_dev_thankyou.php +++ b/src/Modules/Application/Controller/d3_dev_thankyou.php @@ -3,15 +3,16 @@ namespace D3\Devhelper\Modules\Application\Controller; // .../?cl=thankyou[&d3orderid=23] -use D3\Devhelper\Modules\Application\Model\d3_dev_d3inquiry; use D3\Devhelper\Modules\Application\Model\d3_dev_oxorder; +use D3\Devhelper\Modules\Core\d3_dev_conf; +use Exception; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\UserException; use OxidEsales\Eshop\Core\Registry; -use OxidEsales\Eshop\Core\Request; +use oxOrder; /** * This Software is the property of Data Development and is protected @@ -40,29 +41,54 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent parent::init(); - if (Registry::get(Request::class)->getRequestEscapedParameter("d3dev") + if (Registry::getRequest()->getRequestEscapedParameter("d3dev") && false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode() - && Registry::getConfig()->getConfigParam('blD3DevAvoidDelBasket') + && Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_PREVENTDELBASKET) ) { Registry::getSession()->setVariable( 'sess_challenge', $sSessChallenge ); } - if (Registry::get(Request::class)->getRequestEscapedParameter("d3dev") - && false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode() - && Registry::getConfig()->getConfigParam('blD3DevShowThankyou') - ) { + if ($this->d3DevCanShowThankyou()) { $this->_d3authenticate(); $oOrder = $this->d3GetLastOrder(); - $oBasket = $oOrder->d3DevGetOrderBasket(); - $this->_oBasket = $oBasket; + $this->_oBasket = $oOrder->d3DevGetOrderBasket(); } } + /** + * @return bool + */ + public function d3DevCanShowThankyou() + { + return Registry::getRequest()->getRequestEscapedParameter("d3dev") + && false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode() + && Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_SHOWTHANKYOU); + } + + /** + * @return string + */ + public function render() + { + $currentClass = ''; + if ($this->d3DevCanShowThankyou()) { + $currentClass = $this->getViewConfig()->getViewConfigParam('cl'); + } + + $ret = parent::render(); + + if ($this->d3DevCanShowThankyou()) { + $this->getViewConfig()->setViewConfigParam('cl', $currentClass); + } + + return $ret; + } + protected function _d3authenticate () { try { - $sUser = Registry::get(Request::class)->getRequestEscapedParameter( 'usr'); - $sPassword = Registry::get(Request::class)->getRequestEscapedParameter('pwd'); + $sUser = Registry::getRequest()->getRequestEscapedParameter( 'usr'); + $sPassword = Registry::getRequest()->getRequestEscapedParameter('pwd'); if ( !$sUser || !$sPassword ) { $sUser = $_SERVER[ 'PHP_AUTH_USER' ]; @@ -93,7 +119,7 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent throw $oEx; } } - catch ( \Exception $oEx ) { + catch ( Exception $oEx ) { $oShop = Registry::getConfig()->getActiveShop(); header( 'WWW-Authenticate: Basic realm="{' . $oShop->getFieldData('oxname') . '"' ); header( 'HTTP/1.0 401 Unauthorized' ); @@ -102,7 +128,7 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent } /** - * @return bool|d3_dev_oxorder|\oxOrder + * @return bool|d3_dev_oxorder|oxOrder * @throws DatabaseConnectionException * @throws DatabaseErrorException */ @@ -111,12 +137,18 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent $oOrder = parent::getOrder(); if ((false == $oOrder || !$oOrder->getFieldData('oxordernr')) - && Registry::get(Request::class)->getRequestEscapedParameter("d3dev") - && false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode() - && Registry::getConfig()->getConfigParam('blD3DevShowThankyou') + && $this->d3DevCanShowThankyou() ) { - $this->_oOrder = $this->d3GetLastOrder(); - $oOrder = $this->_oOrder; + try { + $this->_oOrder = $this->d3GetLastOrder(); + $oOrder = $this->_oOrder; + + if (!$oOrder || !$oOrder->getFieldData('oxordernr')) { + throw oxNew(\RuntimeException::class, 'unknown order'); + } + } catch (Exception $e) { + die($e->getMessage()); + } } return $oOrder; @@ -139,21 +171,4 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent return $oOrder; } - - /** - * @return bool|d3_dev_d3inquiry - * @throws DatabaseConnectionException - */ - public function d3GetLastInquiry() - { - if (Registry::getConfig()->getActiveShop()->isProductiveMode()) { - return false; - } - - /** @var d3_dev_d3inquiry $oInquiry */ - $oInquiry = oxNew('d3inquiry'); - $oInquiry->d3getLastInquiry(); - - return $oInquiry; - } } diff --git a/src/Modules/Application/Model/d3_dev_d3inquiry.php b/src/Modules/Application/Model/d3_dev_d3inquiry.php deleted file mode 100644 index 3062ff1..0000000 --- a/src/Modules/Application/Model/d3_dev_d3inquiry.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @link http://www.oxidmodule.com - */ - -class d3_dev_d3inquiry extends d3_dev_d3inquiry_parent -{ - protected $_oOrderBasket = null; - - /** - * @return d3_dev_oxbasket - * @throws DatabaseConnectionException - * @throws DatabaseErrorException - */ - public function d3DevGetOrderBasket() - { - /** @var Basket $oBasket */ - $this->_getInquiryBasket(); - - // unsetting bundles - $oOrderArticles = $this->getInquiryArticles(); - foreach ($oOrderArticles as $sItemId => $oItem) { - if ($oItem->isBundle()) { - $oOrderArticles->offsetUnset($sItemId); - } - } - - // add this order articles to basket and recalculate basket - $oBasket = $this->_addInquiryArticlesToBasket($this->getInquiryUser(), $oOrderArticles); - // recalculating basket - $oBasket->calculateBasket(true); - $oBasket->d3ClearBasketItemArticles(); - - return $oBasket; - } - - /** - * @return string - * @throws DatabaseConnectionException - */ - public function d3getLastInquiryId() - { - $inquiryNr = (int) Registry::get(Request::class)->getRequestEscapedParameter('d3inquirynr'); - $sWhere = 1; - if ($inquiryNr) { - $sWhere = ' oxinquirynr = ' . $inquiryNr; - } - - $sSelect = "SELECT oxid FROM ".getViewName('d3inquiry')." WHERE ".$sWhere." ORDER BY oxinquirydate DESC LIMIT 1"; - - return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($sSelect); - } - - /** - * @throws DatabaseConnectionException - */ - public function d3getLastInquiry() - { - $this->load($this->d3getLastInquiryId()); - //$this->_d3AddVouchers(); - } - - /** - * @return Basket - * @throws DatabaseConnectionException - * @throws DatabaseErrorException - */ - public function getBasket() - { - $oBasket = parent::getBasket(); - - if (false == $oBasket && Registry::getConfig()->getActiveView()->getClassKey() == 'd3dev') { - $oBasket = $this->d3DevGetOrderBasket(); - } - - return $oBasket; - } - - /** - * @throws DatabaseConnectionException - * @throws DatabaseErrorException - */ - protected function _d3AddVouchers() - { - $sSelect = "SELECT oxid FROM oxvouchers WHERE oxorderid = ". DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->quote($this->getId()).";"; - - $aResult = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll($sSelect); - - foreach ($aResult as $aFields) { - $oVoucher = oxNew('oxvoucher'); - $oVoucher->load($aFields['oxid']); - $this->_aVoucherList[$oVoucher->getId()] = $oVoucher; - } - } - - /** - * Returns basket object filled up with discount, delivery, wrapping and all other info - * - * @param bool $blStockCheck perform stock check or not (default true) - * - * @return Basket - * @throws DatabaseConnectionException - * @throws DatabaseErrorException - */ - protected function _getInquiryBasket($blStockCheck = true) - { - /** @var Basket _oOrderBasket */ - $this->_oOrderBasket = oxNew(Basket::class); - $this->_oOrderBasket->enableSaveToDataBase(false); - - //setting recalculation mode - $this->_oOrderBasket->setCalculationModeNetto($this->isNettoMode()); - - // setting stock check mode - $this->_oOrderBasket->setStockCheckMode($blStockCheck); - - // setting virtual basket user - $this->_oOrderBasket->setBasketUser($this->getInquiryUser()); - - // transferring order id - $this->_oOrderBasket->setInquiryId($this->getId()); - - // setting basket currency order uses - $aCurrencies = Registry::getConfig()->getCurrencyArray(); - foreach ($aCurrencies as $oCur) { - if ($oCur->name == $this->getFieldData('oxcurrency')) { - $oBasketCur = $oCur; - break; - } - } - - // setting currency - $this->_oOrderBasket->setBasketCurrency($oBasketCur); - - // set basket card id and message - $this->_oOrderBasket->setCardId($this->getFieldData('oxcardid')); - $this->_oOrderBasket->setCardMessage($this->getFieldData('oxcardtext')); - - if ($this->_blReloadDiscount) { - $oDb = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); - // disabling availability check - $this->_oOrderBasket->setSkipVouchersChecking(true); - - // add previously used vouchers - $sQ = 'select oxid from oxvouchers where oxorderid = ' . $oDb->quote($this->getId()); - $aVouchers = $oDb->getAll($sQ); - foreach ($aVouchers as $aVoucher) { - $this->_oOrderBasket->addVoucher($aVoucher['oxid']); - } - } else { - $this->_oOrderBasket->setDiscountCalcMode(false); - $this->_oOrderBasket->setVoucherDiscount($this->getFieldData('oxvoucherdiscount')); - $this->_oOrderBasket->setTotalDiscount($this->getFieldData('oxdiscount')); - } - - return $this->_oOrderBasket; - } -} diff --git a/src/Modules/Application/Model/d3_dev_d3inquiryarticle.php b/src/Modules/Application/Model/d3_dev_d3inquiryarticle.php deleted file mode 100644 index b12f9e7..0000000 --- a/src/Modules/Application/Model/d3_dev_d3inquiryarticle.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @link http://www.oxidmodule.com - */ - -namespace D3\Devhelper\Modules\Application\Model; - -use OxidEsales\Eshop\Application\Model\ArticleList; - -class d3_dev_d3inquiryarticle extends d3_dev_d3inquiryarticle_parent -{ - /** - * @return null|ArticleList - */ - public function getCustomerAlsoBoughtThisProducts() - { - $oArticle = $this->getArticle(); - - return $oArticle->getCustomerAlsoBoughtThisProducts(); - } - - /** - * Returns true if ordered product is bundle - * - * @return bool - */ - public function isBundle() - { - return ( bool ) $this->getFieldData('oxisbundle'); - } -} diff --git a/src/Modules/Application/Model/d3_dev_oxbasket.php b/src/Modules/Application/Model/d3_dev_oxbasket.php index 7d57d72..1aa38d2 100644 --- a/src/Modules/Application/Model/d3_dev_oxbasket.php +++ b/src/Modules/Application/Model/d3_dev_oxbasket.php @@ -17,16 +17,19 @@ namespace D3\Devhelper\Modules\Application\Model; +use D3\Devhelper\Modules\Core\d3_dev_conf; +use oxArticleInputException; use OxidEsales\Eshop\Application\Model\BasketItem; use OxidEsales\Eshop\Application\Model\OrderArticle; use OxidEsales\Eshop\Core\Registry; +use oxNoArticleException; class d3_dev_oxbasket extends d3_dev_oxbasket_parent { public function deleteBasket() { if (Registry::getConfig()->getActiveShop()->isProductiveMode() - || false == Registry::getConfig()->getConfigParam('blD3DevAvoidDelBasket') + || false == Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_PREVENTDELBASKET) ) { parent::deleteBasket(); } @@ -67,14 +70,14 @@ class d3_dev_oxbasket extends d3_dev_oxbasket_parent /** * @param OrderArticle $oOrderArticle * - * @return |null - * @throws \oxArticleInputException - * @throws \oxNoArticleException + * @return d3_dev_oxbasketitem|null + * @throws oxArticleInputException + * @throws oxNoArticleException */ public function d3addOrderArticleToBasket($oOrderArticle) { // adding only if amount > 0 - if ($oOrderArticle->oxorderarticles__oxamount->value > 0) { + if ($oOrderArticle->getFieldData('oxamount') > 0) { $this->_isForOrderRecalculation = true; $sItemId = $oOrderArticle->getId(); @@ -83,7 +86,7 @@ class d3_dev_oxbasket extends d3_dev_oxbasket_parent $oBasketItem = oxNew( BasketItem::class); $oBasketItem->initFromOrderArticle($oOrderArticle); $oBasketItem->d3ConvertToArticleObject(); - $oBasketItem->setWrapping($oOrderArticle->oxorderarticles__oxwrapid->value); + $oBasketItem->setWrapping($oOrderArticle->getFieldData('oxwrapid')); $oBasketItem->setBundle($oOrderArticle->isBundle()); $this->_aBasketContents[$sItemId] = $oBasketItem; diff --git a/src/Modules/Application/Model/d3_dev_oxbasketitem.php b/src/Modules/Application/Model/d3_dev_oxbasketitem.php index e8f0ef4..f665e69 100644 --- a/src/Modules/Application/Model/d3_dev_oxbasketitem.php +++ b/src/Modules/Application/Model/d3_dev_oxbasketitem.php @@ -16,11 +16,13 @@ namespace D3\Devhelper\Modules\Application\Model; +use oxArticleInputException; use OxidEsales\Eshop\Application\Model\Article; use OxidEsales\Eshop\Application\Model\OrderArticle; use OxidEsales\Eshop\Core\Exception\ArticleException; use OxidEsales\Eshop\Core\Exception\ArticleInputException; use OxidEsales\Eshop\Core\Exception\NoArticleException; +use oxNoArticleException; class d3_dev_oxbasketitem extends d3_dev_oxbasketitem_parent { @@ -48,8 +50,8 @@ class d3_dev_oxbasketitem extends d3_dev_oxbasketitem_parent } /** - * @throws \oxArticleInputException - * @throws \oxNoArticleException + * @throws oxArticleInputException + * @throws oxNoArticleException */ public function d3ConvertToArticleObject() { diff --git a/src/Modules/Application/Model/d3_dev_oxorder.php b/src/Modules/Application/Model/d3_dev_oxorder.php index 514b8ec..20eabf5 100644 --- a/src/Modules/Application/Model/d3_dev_oxorder.php +++ b/src/Modules/Application/Model/d3_dev_oxorder.php @@ -17,13 +17,16 @@ namespace D3\Devhelper\Modules\Application\Model; +use oxarticleinputexception; +use OxidEsales\Eshop\Application\Model\Basket; +use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Voucher; use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Model\ListModel; use OxidEsales\Eshop\Core\Registry; -use OxidEsales\Eshop\Core\Request; +use oxnoarticleexception; class d3_dev_oxorder extends d3_dev_oxorder_parent { @@ -53,15 +56,16 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent */ public function d3getLastOrderId() { - $orderNr = (int) Registry::get(Request::class)->getRequestEscapedParameter('d3ordernr'); + $orderNr = (int) Registry::getRequest()->getRequestEscapedParameter('d3ordernr'); $sWhere = 1; if ($orderNr) { - $sWhere = ' oxordernr = ' . DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->quote($orderNr); + $sWhere = ' oxordernr = ? '; } + $parameters = [$orderNr]; - $sSelect = "SELECT oxid FROM ".getViewName('oxorder')." WHERE ".$sWhere." ORDER BY oxorderdate DESC LIMIT 1"; + $sSelect = "SELECT oxid FROM ".oxNew(Order::class)->getViewName()." WHERE ".$sWhere." ORDER BY oxorderdate DESC LIMIT 1"; - return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($sSelect); + return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($sSelect, $parameters); } /** @@ -75,7 +79,7 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent } /** - * @return d3_dev_oxbasket|\OxidEsales\Eshop\Application\Model\Basket + * @return d3_dev_oxbasket|Basket */ public function getBasket() { @@ -94,9 +98,12 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent */ protected function _d3AddVouchers() { - $sSelect = "SELECT oxid FROM oxvouchers WHERE oxorderid = ".DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->quote($this->getId()).";"; + $sSelect = "SELECT oxid FROM ".oxNew(Voucher::class)->getViewName()." WHERE oxorderid = ?"; - $aResult = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll($sSelect); + $aResult = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll( + $sSelect, + [$this->getId()] + ); foreach ($aResult as $aFields) { $oVoucher = oxNew(Voucher::class); @@ -110,6 +117,8 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent * * @param d3_dev_oxbasket $oBasket basket object * @param ListModel $aOrderArticles order articles + * @throws oxArticleInputException + * @throws oxNoArticleException */ protected function _d3AddOrderArticlesToBasket($oBasket, $aOrderArticles) { diff --git a/src/Modules/Application/Model/d3_dev_oxorderarticle.php b/src/Modules/Application/Model/d3_dev_oxorderarticle.php index 1996acb..6e308a8 100644 --- a/src/Modules/Application/Model/d3_dev_oxorderarticle.php +++ b/src/Modules/Application/Model/d3_dev_oxorderarticle.php @@ -27,6 +27,9 @@ class d3_dev_oxorderarticle extends d3_dev_oxorderarticle_parent { $oArticle = $this->getArticle(); - return $oArticle->getCustomerAlsoBoughtThisProducts(); + /** @var ArticleList $artList */ + $artList = $oArticle->getCustomerAlsoBoughtThisProducts(); + + return $artList; } } diff --git a/src/Modules/Core/d3_dev_conf.php b/src/Modules/Core/d3_dev_conf.php new file mode 100644 index 0000000..7311ad5 --- /dev/null +++ b/src/Modules/Core/d3_dev_conf.php @@ -0,0 +1,29 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Devhelper\Modules\Core; + +class d3_dev_conf +{ + const OPTION_PREVENTDELBASKET = 'blD3DevAvoidDelBasket'; + const OPTION_SHOWTHANKYOU = 'blD3DevShowThankyou'; + + const OPTION_SHOWMAILSINBROWSER = 'blD3DevShowOrderMailsInBrowser'; + + const OPTION_BLOCKMAIL = 'blD3DevBlockMails'; + const OPTION_REDIRECTMAIL = 'sD3DevRedirectMail'; +} \ No newline at end of file diff --git a/src/Modules/Core/d3_dev_oxemail.php b/src/Modules/Core/d3_dev_oxemail.php index b858ddc..3398e53 100644 --- a/src/Modules/Core/d3_dev_oxemail.php +++ b/src/Modules/Core/d3_dev_oxemail.php @@ -20,6 +20,9 @@ namespace D3\Devhelper\Modules\Core; use D3\Devhelper\Modules\Application\Model as ModuleModel; use OxidEsales\Eshop\Core\Exception\StandardException; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; +use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererInterface; class d3_dev_oxemail extends d3_dev_oxemail_parent { @@ -49,7 +52,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $sTpl = $this->_sOrderUserTemplate; } - $myConfig = $this->getConfig(); + $myConfig = Registry::getConfig(); $oShop = $this->_getShop(); @@ -78,81 +81,47 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $this->setSmtp($oShop); // create messages - /** @var \Smarty $oSmarty */ - $oSmarty = $this->_getSmarty(); $this->setViewData("order", $oOrder); // Process view data array through oxoutput processor $this->_processViewArray(); - return $oSmarty->fetch($myConfig->getTemplatePath($sTpl, false)); + $renderer = $this->getRenderer(); + return $renderer->renderTemplate($myConfig->getTemplatePath($sTpl, false), $this->getViewData()); } /** - * @param ModuleModel\d3_dev_d3inquiry $oInquiry + * required because private in Email class + * Templating instance getter * - * @param $sType - * - * @return mixed|string + * @return TemplateRendererInterface */ - public function d3GetInquiryMailContent($oInquiry, $sType ) + protected function getRenderer() { - if (Registry::getConfig()->getActiveShop()->isProductiveMode()) { - return ''; + $bridge = ContainerFactory::getInstance()->getContainer() + ->get(TemplateRendererBridgeInterface::class); + $bridge->setEngine($this->_getSmarty()); + + return $bridge->getTemplateRenderer(); + } + + /** + * @param $aRecInfo + * @param array $aCc + * @return array + */ + public function d3ChangeRecipient($aRecInfo, array $aCc): array + { + if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) + && $sNewRecipient != $aRecInfo[0] + ) { + $aRecInfo[1] = $aRecInfo[1] . " (" . $aRecInfo[0] . ")"; + $aRecInfo[0] = $sNewRecipient; + $aCc[] = $aRecInfo; + } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { + $aCc[] = $aRecInfo; } - - switch (strtolower($sType)) { - case 'owner_html': - $sTpl = $this->_sInquiryOwnerTemplate; - break; - case 'owner_plain': - $sTpl = $this->_sInquiryOwnerPlainTemplate; - break; - case 'user_plain': - $sTpl = $this->_sInquiryUserPlainTemplate; - break; - case 'user_html': - default: - $sTpl = $this->_sInquiryUserTemplate; - } - - $myConfig = $this->getConfig(); - - $oShop = $this->_getShop(); - - // cleanup - $this->_clearMailer(); - - // add user defined stuff if there is any - $oInquiry = $this->_addUserInfoOrderEMail($oInquiry); - - $oUser = $oInquiry->getInquiryUser(); - $this->setUser($oUser); - - // send confirmation to shop owner - // send not pretending from order user, as different email domain rise spam filters - $this->setFrom($oShop->getFieldData('oxowneremail')); - - $oLang = Registry::getLang(); - $iOrderLang = $oLang->getObjectTplLanguage(); - - // if running shop language is different from admin lang. set in config - // we have to load shop in config language - if ($oShop->getLanguage() != $iOrderLang) { - $oShop = $this->_getShop($iOrderLang); - } - - $this->setSmtp($oShop); - - // create messages - /** @var \Smarty $oSmarty */ - $oSmarty = $this->_getSmarty(); - $this->setViewData("inquiry", $oInquiry); - - // Process view data array through oxoutput processor - $this->_processViewArray(); - - return $oSmarty->fetch($myConfig->getTemplatePath($sTpl, false)); + return $aCc; } /** @@ -178,20 +147,35 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent return true; } + /** + * @return bool + * @throws StandardException + */ + protected function sendMail() + { + if (Registry::getConfig()->getActiveShop()->isProductiveMode()) { + return parent::sendMail(); + } + + $this->d3clearRecipients(); + $this->d3clearReplies(); + $this->d3clearReplyTo(); + $this->d3clearCC(); + $this->d3clearBCC(); + + if (count($this->getRecipient())) { + return parent::sendMail(); + } + + return true; + } + public function d3clearRecipients() { $aRecipients = array(); if (is_array($this->_aRecipients) && count($this->_aRecipients)) { foreach ($this->_aRecipients as $aRecInfo) { - if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) - && $sNewRecipient != $aRecInfo[0] - ) { - $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; - $aRecInfo[0] = $sNewRecipient; - $aRecipients[] = $aRecInfo; - } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { - $aRecipients[] = $aRecInfo; - } + $aRecipients = $this->d3ChangeRecipient($aRecInfo, $aRecipients); } } $this->_aRecipients = $aRecipients; @@ -202,15 +186,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $aRecipients = array(); if (is_array($this->_aReplies) && count($this->_aReplies)) { foreach ($this->_aReplies as $aRecInfo) { - if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) - && $sNewRecipient != $aRecInfo[0] - ) { - $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; - $aRecInfo[0] = $sNewRecipient; - $aRecipients[] = $aRecInfo; - } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { - $aRecipients[] = $aRecInfo; - } + $aRecipients = $this->d3ChangeRecipient($aRecInfo, $aRecipients); } } $this->_aReplies = $aRecipients; @@ -221,15 +197,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $aRecipients = array(); if (is_array($this->ReplyTo) && count($this->ReplyTo)) { foreach ($this->ReplyTo as $aRecInfo) { - if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) - && $sNewRecipient != $aRecInfo[0] - ) { - $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; - $aRecInfo[0] = $sNewRecipient; - $aRecipients[] = $aRecInfo; - } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { - $aRecipients[] = $aRecInfo; - } + $aRecipients = $this->d3ChangeRecipient($aRecInfo, $aRecipients); } } $this->ReplyTo = $aRecipients; @@ -240,15 +208,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $aCc = array(); if (is_array($this->cc) && count($this->cc)) { foreach ($this->cc as $aRecInfo) { - if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) - && $sNewRecipient != $aRecInfo[0] - ) { - $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; - $aRecInfo[0] = $sNewRecipient; - $aCc[] = $aRecInfo; - } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { - $aCc[] = $aRecInfo; - } + $aCc = $this->d3ChangeRecipient($aRecInfo, $aCc); } } @@ -260,15 +220,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent $aCc = array(); if (is_array($this->bcc) && count($this->bcc)) { foreach ($this->bcc as $aRecInfo) { - if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0])) - && $sNewRecipient != $aRecInfo[0] - ) { - $aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")"; - $aRecInfo[0] = $sNewRecipient; - $aCc[] = $aRecInfo; - } elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) { - $aCc[] = $aRecInfo; - } + $aCc = $this->d3ChangeRecipient($aRecInfo, $aCc); } } @@ -282,10 +234,10 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent */ public function getNewRecipient($sMailAddress) { - if (Registry::getConfig()->getConfigParam('blD3DevBlockMails')) { + if (Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_BLOCKMAIL)) { return false; - } elseif (Registry::getConfig()->getConfigParam('sD3DevRedirectMail')) { - return trim(Registry::getConfig()->getConfigParam('sD3DevRedirectMail')); + } elseif (Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_REDIRECTMAIL)) { + return trim(Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_REDIRECTMAIL)); } return $sMailAddress; diff --git a/src/metadata.php b/src/metadata.php index e7cbb85..7f9791d 100644 --- a/src/metadata.php +++ b/src/metadata.php @@ -1,5 +1,21 @@ + * @link http://www.oxidmodule.com + */ + +use D3\Devhelper\Application\Controller\d3dev; use D3\Devhelper\Modules\Core as ModuleCore; use D3\Devhelper\Modules\Application\Controller as ModuleController; use D3\Devhelper\Modules\Application\Model as ModuleModel; @@ -11,22 +27,22 @@ use OxidEsales\Eshop\Core\Registry; /** * Metadata version */ -$sMetadataVersion = '2.0'; - -$sStyle = class_exists(D3\Devhelper\Application\Controller\d3dev::class) ? "background-color: darkred; color: white; padding: 0 10px;" : ""; +$sMetadataVersion = '2.1'; +$sLogo = '(D3) '; /** * Module information */ $aModule = array( 'id' => 'd3dev', - 'title' => - (class_exists(D3\ModCfg\Application\Model\d3utils::class) ? D3\ModCfg\Application\Model\d3utils::getInstance()->getD3Logo() : 'D³') . - ' TPL Development Tool', - 'description' => array( + 'title' => [ + 'de' => $sLogo . 'TPL Entwicklerwerkzeug', + 'en' => $sLogo . 'TPL Development Tool' + ], + 'description' => [ 'de' => '