Cette révision appartient à :
Daniel Seifert 2024-07-03 09:32:01 +02:00
Parent f183c61c57
révision 346a189881
7 fichiers modifiés avec 112 ajouts et 65 suppressions

Voir le fichier

@ -2,21 +2,23 @@
namespace D3\Devhelper\Application\Controller;
use D3\Devhelper\Application\Model\Exception\UnauthorisedException;
use D3\Devhelper\Modules\Application\Controller as ModuleController;
use D3\Devhelper\Modules\Core as ModuleCore;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Exception;
use GuzzleHttp\Psr7\ServerRequest;
use OxidEsales\Eshop\Application\Controller\FrontendController;
use OxidEsales\Eshop\Application\Controller\ThankYouController;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Email;
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\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* This Software is the property of Data Development and is protected
@ -84,30 +86,42 @@ class d3dev extends FrontendController
}
/**
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws DBALDriverException
*/
public function showOrderMailContent()
public function showOrderMailContent(): void
{
header('Content-type: text/html; charset='.Registry::getLang()->translateString('charset'));
/** @var ModuleSettingService $moduleSettingService */
$moduleSettingService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
try {
header( 'Content-type: text/html; charset=' . Registry::getLang()->translateString( 'charset' ) );
/** @var ModuleSettingService $moduleSettingService */
$moduleSettingService = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
if ( Registry::getConfig()->getActiveShop()->isProductiveMode()
|| ! $moduleSettingService->getBoolean( ModuleCore\d3_dev_conf::OPTION_SHOWMAILSINBROWSER, 'd3dev' )
) {
Registry::getUtils()->redirect(Registry::getConfig()->getShopUrl().'index.php?cl=start');
if ( Registry::getConfig()->getActiveShop()->isProductiveMode() ||
! $moduleSettingService->getBoolean( ModuleCore\d3_dev_conf::OPTION_SHOWMAILSINBROWSER, 'd3dev' )
) {
throw oxNew(UnauthorisedException::class);
}
$sTpl = Registry::getRequest()->getRequestEscapedParameter( 'type' );
/** @var ModuleController\d3_dev_thankyou $oThankyou */
$oThankyou = oxNew( ThankYouController::class );
$oOrder = $oThankyou->d3GetLastOrder();
/** @var ModuleCore\d3_dev_oxemail $oEmail */
$oEmail = oxNew( Email::class );
echo $oEmail->d3GetOrderMailContent( $oOrder, $sTpl );
http_response_code( 200 );
} catch (UnauthorisedException $exception) {
echo $exception->getMessage();
http_response_code(401);
} catch (Exception $exception) {
echo $exception->getMessage();
http_response_code(400);
} finally {
Registry::getConfig()->pageClose();
die();
}
$sTpl = Registry::getRequest()->getRequestEscapedParameter('type');
/** @var ModuleController\d3_dev_thankyou $oThankyou */
$oThankyou = oxNew(ThankYouController::class);
$oOrder = $oThankyou->d3GetLastOrder();
/** @var ModuleCore\d3_dev_oxemail $oEmail */
$oEmail = oxNew(Email::class);
echo $oEmail->d3GetOrderMailContent($oOrder, $sTpl);
die();
}
}

Voir le fichier

@ -0,0 +1,14 @@
<?php
namespace D3\Devhelper\Application\Model\Exception;
use Exception;
use OxidEsales\Eshop\Core\Exception\StandardException;
class NoOrderFoundException extends StandardException
{
public function __construct( $sMessage = "no order found", $iCode = 0, Exception $previous = null )
{
parent::__construct( $sMessage, $iCode, $previous );
}
}

Voir le fichier

@ -0,0 +1,13 @@
<?php
namespace D3\Devhelper\Application\Model\Exception;
use OxidEsales\Eshop\Core\Exception\StandardException;
class UnauthorisedException extends StandardException
{
public function __construct( $sMessage = "unauthorised, disable productive and activate option", $iCode = 0, Exception $previous = null )
{
parent::__construct( $sMessage, $iCode, $previous );
}
}

Voir le fichier

@ -3,8 +3,12 @@
namespace D3\Devhelper\Modules\Application\Controller;
// .../?cl=thankyou[&d3orderid=23]
use D3\Devhelper\Application\Model\Exception\NoOrderFoundException;
use D3\Devhelper\Application\Model\Exception\UnauthorisedException;
use D3\Devhelper\Modules\Application\Model\d3_dev_oxorder;
use D3\Devhelper\Modules\Core\d3_dev_conf;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use Exception;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\User;
@ -12,7 +16,8 @@ use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\UserException;
use OxidEsales\Eshop\Core\Registry;
use oxOrder;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* This Software is the property of Data Development and is protected
@ -42,7 +47,7 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
parent::init();
if (Registry::getRequest()->getRequestEscapedParameter("d3dev")
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
&& !Registry::getConfig()->getActiveShop()->isProductiveMode()
&& Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_PREVENTDELBASKET)
) {
Registry::getSession()->setVariable( 'sess_challenge', $sSessChallenge );
@ -60,9 +65,9 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
*/
public function d3DevCanShowThankyou()
{
return Registry::getRequest()->getRequestEscapedParameter("d3dev")
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
&& Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_SHOWTHANKYOU);
return Registry::getRequest()->getRequestEscapedParameter("d3dev") &&
!Registry::getConfig()->getActiveShop()->isProductiveMode() &&
Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_SHOWTHANKYOU);
}
/**
@ -128,7 +133,7 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
}
/**
* @return bool|d3_dev_oxorder|oxOrder
* @return bool|d3_dev_oxorder|Order
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
@ -155,14 +160,19 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
}
/**
* @return bool|d3_dev_oxorder
* @return d3_dev_oxorder
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws NoOrderFoundException
* @throws DBALDriverException
* @throws DBALException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function d3GetLastOrder()
public function d3GetLastOrder(): d3_dev_oxorder
{
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
return false;
throw oxNew(UnauthorisedException::class);
}
/** @var d3_dev_oxorder $oOrder */

Voir le fichier

@ -28,8 +28,8 @@ class d3_dev_oxbasket extends d3_dev_oxbasket_parent
{
public function deleteBasket()
{
if (Registry::getConfig()->getActiveShop()->isProductiveMode()
|| false == Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_PREVENTDELBASKET)
if ( Registry::getConfig()->getActiveShop()->isProductiveMode()
|| ! Registry::getConfig()->getConfigParam( d3_dev_conf::OPTION_PREVENTDELBASKET )
) {
parent::deleteBasket();
}

Voir le fichier

@ -17,6 +17,9 @@
namespace D3\Devhelper\Modules\Application\Model;
use D3\Devhelper\Application\Model\Exception\NoOrderFoundException;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Query\QueryBuilder;
use oxarticleinputexception;
use OxidEsales\Eshop\Application\Model\Basket;
@ -24,11 +27,14 @@ use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\Voucher;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\SystemComponentException;
use OxidEsales\Eshop\Core\Model\ListModel;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use oxnoarticleexception;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class d3_dev_oxorder extends d3_dev_oxorder_parent
{
@ -53,10 +59,13 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
}
/**
* @return string
* @throws DatabaseConnectionException
* @return false|string
* @throws ContainerExceptionInterface
* @throws DBALException
* @throws DBALDriverException
* @throws NotFoundExceptionInterface
*/
public function d3getLastOrderId()
public function d3getLastOrderId(): false|string
{
/** @var QueryBuilder $qb */
$qb = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
@ -64,7 +73,7 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
->from((oxNew(Order::class))->getViewName())
->where(
$qb->expr()->and(
$qb->expr()->eq(
$qb->expr()->neq(
'oxuserid',
$qb->createNamedParameter('')
),
@ -91,13 +100,22 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
}
/**
* @throws ContainerExceptionInterface
* @throws DBALDriverException
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws NoOrderFoundException
* @throws NotFoundExceptionInterface
*/
public function d3getLastOrder()
public function d3getLastOrder(): void
{
$this->load($this->d3getLastOrderId());
$this->_d3AddVouchers();
if ($orderId = $this->d3getLastOrderId()) {
$this->load($orderId);
$this->_d3AddVouchers();
} else {
throw new NoOrderFoundException();
}
}
/**

Voir le fichier

@ -17,6 +17,7 @@
namespace D3\Devhelper\Modules\Core;
use D3\Devhelper\Application\Model\Exception\UnauthorisedException;
use D3\Devhelper\Modules\Application\Model as ModuleModel;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
@ -34,7 +35,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
public function d3GetOrderMailContent($oOrder, $sType)
{
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
return '';
throw oxNew(UnauthorisedException::class);
}
switch (strtolower($sType)) {
@ -129,29 +130,6 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
return $aCc;
}
/**
* @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;
}
/**
* @return bool
* @throws StandardException