Skip to content

Commit

Permalink
Merge branch 'b-7.2.x' into b-8.0.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG-7.2.md
#	source/Core/Email.php
  • Loading branch information
AshrafOxid committed Oct 8, 2024
2 parents 595ba73 + d6ca04e commit 47bb33f
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 37 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG-7.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Change Log for OXID eShop Community Edition Core Component

## v7.2.0 - unreleased

### Added
- Translations for Change language and currency
- New parameter `oxid_esales.email.disable_order_emails` to enable and disable sending order emails

### Deprecated
- Filesystem module cache related services and interface will be refactored and some of them will be removed
- `OxidEsales\EshopCommunity\Application\Model\Attribute::_sTitle` property

### Fixed
- User registration in the Private Sales mode
- New item in basket message display [#0007548](https://bugs.oxid-esales.com/view.php?id=7548) [PR-964](https://github.com/OXID-eSales/oxideshop_ce/pull/964)
- Multiple language creation [#0007683](https://bugs.oxid-esales.com/view.php?id=7683)
- Remove unnecessary `<small>` tags from CHF currency
- Existing sessions should be destroyed on password change [#0007324](https://bugs.oxid-esales.com/view.php?id=7324)
- Forgot password message

### Changed
- Changed the exported user file name from `Export_recipient_` to `Export_user_recipient_status_` to better reflect the content of the export.
- User needs to log in again after changing his password

### Removed
- Obsolete demo data and images from the `source/out` directory
- PHP v8.1 support
3 changes: 3 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<arg name="parallel" value="75"/>
<arg name="extensions" value="php"/>
<rule ref="PSR12"/>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern>*tests/Codeception/.*$</exclude-pattern>
</rule>
</ruleset>
33 changes: 13 additions & 20 deletions source/Application/Controller/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OxidEsales\EshopCommunity\Application\Controller;

use OxidEsales\Eshop\Core\Email;
use OxidEsales\Eshop\Core\Registry;

/**
Expand All @@ -30,7 +31,7 @@ class ForgotPasswordController extends \OxidEsales\Eshop\Application\Controller\
*
* @var string
*/
protected $_sForgotEmail = null;
protected $_sForgotEmail;

/**
* Current view search engine indexing state
Expand All @@ -43,8 +44,10 @@ class ForgotPasswordController extends \OxidEsales\Eshop\Application\Controller\
* Update link expiration status
*
* @var bool
*
* @deprecated property will be removed in next major
*/
protected $_blUpdateLinkStatus = null;
protected $_blUpdateLinkStatus;

/**
* Sign if to load and show bargain action
Expand All @@ -54,27 +57,17 @@ class ForgotPasswordController extends \OxidEsales\Eshop\Application\Controller\
protected $_blBargainAction = true;

/**
* Executes oxemail::SendForgotPwdEmail() and sends login
* password to user according to login name (email).
*
* Template variables:
* <b>sendForgotMail</b>
* Executes Email::sendForgotPwdEmail() to send "forgot password" email to user
*/
public function forgotPassword()
{
$sEmail = Registry::getRequest()->getRequestEscapedParameter('lgn_usr');
$this->_sForgotEmail = $sEmail;
$oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);

// problems sending passwd reminder ?
$iSuccess = false;
if ($sEmail) {
$iSuccess = $oEmail->sendForgotPwdEmail($sEmail);
}
if ($iSuccess !== true) {
$sError = ($iSuccess === false) ? 'ERROR_MESSAGE_PASSWORD_EMAIL_INVALID' : 'MESSAGE_NOT_ABLE_TO_SEND_EMAIL';
Registry::getUtilsView()->addErrorToDisplay($sError);
$this->_sForgotEmail = false;
$this->_sForgotEmail = Registry::getRequest()->getRequestEscapedParameter('lgn_usr');
if ($this->_sForgotEmail) {
$result = oxNew(Email::class)->sendForgotPwdEmail($this->_sForgotEmail);
if ($result === -1) {
Registry::getUtilsView()->addErrorToDisplay('MESSAGE_NOT_ABLE_TO_SEND_EMAIL');
$this->_sForgotEmail = false;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions source/Application/translations/de/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@
'ERROR_MESSAGE_INPUT_NOVALIDEMAIL' => 'Bitte geben Sie eine gültige E-Mail-Adresse ein',
'ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS' => 'Ungültige E-Mail-Adresse. Bitte überprüfen Sie die E-Mail-Adressen.',
'ERROR_MESSAGE_MANDATES_EXCEEDED' => 'Die Anzahl der lizenzierten Mandanten ist überschritten. Tragen Sie bitte im Shop Admin einen gültigen Lizenzschlüssel ein oder kontaktieren Sie',
'FOR_MORE_INFORMATION' => 'für mehr Informationen.',
'FOR_MORE_INFORMATION' => 'für mehr Informationen.',//
'ERROR_MESSAGE_NOFILE' => 'Keine Datei hochgeladen',
'EXCEPTION_NOTALLOWEDTYPE' => 'Verbotener Dateityp. Bitte config.inc.php anpassen, um diesen Dateityp zu erlauben.',
'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK' => 'Der Lagerbestand dieses Artikels ist nicht ausreichend! Verfügbar',
'ERROR_MESSAGE_OXID_ESALES' => 'OXID eSales',
'ERROR_MESSAGE_OXID_SHOP_ERROR' => 'OXID eShop Fehler',
'ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH' => 'Fehler: Die Passwörter stimmen nicht überein.',
// @deprecated will be removed in next major
'ERROR_MESSAGE_PASSWORD_EMAIL_INVALID' => 'Bitte geben Sie eine gültige E-Mail-Adresse ein!',
// END deprecated
'ERROR_MESSAGE_PASSWORD_LINK_EXPIRED' => 'Diese Seite ist nicht mehr gültig. Bitte benutzen Sie die Funktion "Passwort vergessen?" erneut.',
'ERROR_MESSAGE_PASSWORD_TOO_SHORT' => 'Fehler: Ihr Passwort ist zu kurz.',
'ERROR_REVIEW_AND_RATING_NOT_DELETED' => 'Bewertung und Sterne-Rating konnten nicht gelöscht werden',
Expand Down Expand Up @@ -360,7 +362,7 @@
'PAGE' => 'Seite',
'PASSWORD' => 'Passwort',
'PASSWORD_CHANGED' => 'Ihr Passwort wurde erfolgreich geändert.',
'PASSWORD_WAS_SEND_TO' => 'Passwort wurde verschickt an',
'PASSWORD_WAS_SEND_TO' => 'Bei bestehender Registrierung erhalten Sie eine E-Mail mit einem Link zur Passwortvergabe an',
'PAY' => 'Bezahlen',
'PAYMENT_INFORMATION' => 'Bezahlinformation',
'PAYMENT_METHOD' => 'Zahlungsart',
Expand Down
4 changes: 3 additions & 1 deletion source/Application/translations/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
'ERROR_MESSAGE_OXID_ESALES' => 'OXID eSales',
'ERROR_MESSAGE_OXID_SHOP_ERROR' => 'OXID eShop error',
'ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH' => 'Error: passwords don\'t match.',
// @deprecated will be removed in next major
'ERROR_MESSAGE_PASSWORD_EMAIL_INVALID' => 'Please enter a valid e-mail address!',
// END deprecated
'ERROR_MESSAGE_PASSWORD_LINK_EXPIRED' => 'This page is expired. Please use the function "Forgot password?" once again.',
'ERROR_MESSAGE_PASSWORD_TOO_SHORT' => 'Error: your password is too short.',
'ERROR_REVIEW_AND_RATING_NOT_DELETED' => 'The review and the star rating could not be deleted',
Expand Down Expand Up @@ -360,7 +362,7 @@
'PAGE' => 'Page',
'PASSWORD' => 'Password',
'PASSWORD_CHANGED' => 'Your password was changed successfully.',
'PASSWORD_WAS_SEND_TO' => 'Password was sent to',
'PASSWORD_WAS_SEND_TO' => 'If you have registered, you will receive an e-mail with a link to the password assignment to',
'PAY' => 'Pay',
'PAYMENT_INFORMATION' => 'Payment information',
'PAYMENT_METHOD' => 'Payment method',
Expand Down
16 changes: 16 additions & 0 deletions source/Core/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ protected function isValidSmtpHost($smtpHost)
*/
public function sendOrderEmailToUser($order, $subject = null)
{
if ($this->areOrderEmailsDisabled()) {
ContainerFacade::get(LoggerInterface::class)
->notice('Order email not sent to user due to disabled configuration option');
return true;
}
// add user defined stuff if there is any
$order = $this->addUserInfoOrderEMail($order);

Expand Down Expand Up @@ -506,6 +511,11 @@ public function sendOrderEmailToUser($order, $subject = null)
*/
public function sendOrderEmailToOwner($order, $subject = null)
{
if ($this->areOrderEmailsDisabled()) {
ContainerFacade::get(LoggerInterface::class)
->notice('Order email not sent to owner due to disabled configuration option');
return true;
}
$config = Registry::getConfig();

$shop = $this->getShop();
Expand Down Expand Up @@ -2008,4 +2018,10 @@ private function dispatchAdminModeChangedEvent(): void
new AdminModeChangedEvent()
);
}

private function areOrderEmailsDisabled(): bool
{
return ContainerFacade::hasParameter('oxid_esales.email.disable_order_emails')
&& ContainerFacade::getParameter('oxid_esales.email.disable_order_emails');
}
}
5 changes: 4 additions & 1 deletion source/Internal/Utility/Email/services.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parameters:
oxid_esales.email.disable_order_emails: false

services:
_defaults:
autowire: true
Expand All @@ -8,4 +11,4 @@ services:

OxidEsales\EshopCommunity\Internal\Utility\Email\EmailValidatorServiceBridgeInterface:
class: OxidEsales\EshopCommunity\Internal\Utility\Email\EmailValidatorServiceBridge
public: true
public: true
20 changes: 10 additions & 10 deletions tests/Codeception/Acceptance/UserAccountCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,24 @@ public function sendUserPasswordReminder(AcceptanceTester $I): void
$I->wantToTest('user password reminder in my account navigation');

$userData = $this->getExistingUserData();

$startPage = $I->openShop();

//open password reminder page in account menu popup
$passwordReminderPage = $startPage->openUserPasswordReminderPage();
$I->see(Translator::translate('HAVE_YOU_FORGOTTEN_PASSWORD'));

//enter not existing email
$passwordReminderPage = $passwordReminderPage->resetPassword('[email protected]');
$I->see(Translator::translate('ERROR_MESSAGE_PASSWORD_EMAIL_INVALID'));
$I->amGoingTo('reset password with invalid email format');
$passwordReminderPage->resetPassword('wrongEmail');
$I->see(Translator::translate('DD_FORM_VALIDATION_VALIDEMAIL'));

//enter existing email
$passwordReminderPage = $passwordReminderPage->resetPassword($userData['userLoginName']);
$I->amGoingTo('reset password with existing user email');
$passwordReminderPage->resetPassword($userData['userLoginName']);
$I->see(Translator::translate('PASSWORD_WAS_SEND_TO') . ' ' . $userData['userLoginName']);

//open password reminder page in main user account page
$passwordReminderPage->openUserPasswordReminderPage();
$I->see(Translator::translate('HAVE_YOU_FORGOTTEN_PASSWORD'));
$I->amGoingTo('reset password with non-existing user email');
$nonExistingEmail = '[email protected]';
$startPage->openUserPasswordReminderPage()
->resetPassword($nonExistingEmail);
$I->see(Translator::translate('PASSWORD_WAS_SEND_TO') . ' ' . $nonExistingEmail);
}

/**
Expand Down
40 changes: 37 additions & 3 deletions tests/ContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

namespace OxidEsales\EshopCommunity\Tests;

use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use ReflectionClass;
use Symfony\Component\DependencyInjection\Container;
use UnitEnum;

/**
* @internal
Expand All @@ -18,7 +21,7 @@
trait ContainerTrait
{
private $container;

protected function get(string $serviceId)
{
$this->prepareContainer();
Expand All @@ -31,12 +34,43 @@ private function getParameter(string $name)
return $this->container->getParameter($name);
}

private function setParameter(string $name, array|bool|string|int|float|UnitEnum|null $value): void
{
if (!$this->container) {
$this->createContainer();
}
$this->container->setParameter($name, $value);
}

private function prepareContainer(): void
{
if ($this->container === null) {
$this->container = (new TestContainerFactory())->create();
$this->createContainer();
$this->compileContainer();
}
}

private function createContainer(): void
{
$this->container = (new TestContainerFactory())->create();
}

private function compileContainer(): void
{
$this->container->compile(true);
$this->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator')->generate();
}

/**
* Run tests in a separate process if you use this function.
*/
private function attachContainerToContainerFactory(): void
{
if (!$this->container->isCompiled()) {
$this->container->compile();
$this->get('oxid_esales.module.install.service.launched_shop_project_configuration_generator')->generate();
}
$reflectionClass = new ReflectionClass(ContainerFactory::getInstance());
$reflectionProperty = $reflectionClass->getProperty('symfonyContainer');
$reflectionProperty->setValue(ContainerFactory::getInstance(), $this->container);
}
}
Loading

0 comments on commit 47bb33f

Please sign in to comment.