Skip to content

Commit b88d43c

Browse files
committed
Release 2.4.1
Fix #230 Fix #242
1 parent bd5abd5 commit b88d43c

6 files changed

Lines changed: 63 additions & 47 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ https://www.h-hennes.fr/blog/2017/07/11/module-catpcha-pour-prestashop-1-7/
7272
|--------------------| -----------|
7373
| 1.6.1.x and under | :x: use version 0.4.x or 0.5.x instead |
7474
| 1.7.0.x to 1.7.8.x | :heavy_check_mark: |
75-
| 8.0.x | ::heavy_check_mark:|
75+
| 8.0.x | :heavy_check_mark:|

changelog.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/**
22
* Module Captcha
33
* Add (re)captcha on contact and account creation forms
4-
* © Hervé Hennes 2013-2022
4+
* © Hervé Hennes 2013-2023
55
* https://github.com/nenes25/eicaptcha
66
* https://www.h-hennes.fr/blog/
77
*/
88

9-
- V 2.4.1 - 2022 #225 Recaptcha bug create account
9+
- V 2.4.1 - 2023-02-12 #225 Recaptcha bug create account
10+
#241 Add 2 missing hooks on installation (thanks to prestasafe)
11+
#242 customer-form.tpl verified only in '_PS_THEME_DIR_' and not in '_PS_PARENT_THEME_DIR_' too
12+
#230 Not registered on hook actionContactFormSubmitCaptcha
1013
- V 2.4.0 - 2022-08-22 #202 V2.3.1: les modes sombre et clair sont inversés
1114
#205 Captcha box is not visible (Clarify behavior of V3 keys)
1215
#184 Don't require recaptcha for logged in clients

eicaptcha.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct()
5656
$this->author = 'hhennes';
5757
$this->name = 'eicaptcha';
5858
$this->tab = 'front_office_features';
59-
$this->version = '2.4.0';
59+
$this->version = '2.4.1';
6060
$this->need_instance = 1;
6161

6262
$this->bootstrap = true;
@@ -166,7 +166,7 @@ public function getContent()
166166
*
167167
* @return string|void
168168
*/
169-
public function hookHeader($params)
169+
public function hookHeader(array $params)
170170
{
171171
if (!$this->shouldDisplayToCustomer()) {
172172
return;
@@ -266,7 +266,7 @@ public function renderHeaderV3()
266266
*
267267
* @return string|void
268268
*/
269-
public function hookDisplayCustomerAccountForm($params)
269+
public function hookDisplayCustomerAccountForm(array $params)
270270
{
271271
if (Configuration::get('CAPTCHA_ENABLE_ACCOUNT') == 1) {
272272
$this->context->smarty->assign([
@@ -290,7 +290,7 @@ public function hookDisplayCustomerAccountForm($params)
290290
*
291291
* @deprecated since 2.4.0
292292
*/
293-
public function hookActionContactFormSubmitCaptcha($params)
293+
public function hookActionContactFormSubmitCaptcha(array $params)
294294
{
295295
if (Configuration::get('CAPTCHA_ENABLE_ACCOUNT') == 1) {
296296
return $this->_validateCaptcha();
@@ -307,7 +307,7 @@ public function hookActionContactFormSubmitCaptcha($params)
307307
*
308308
* @since 2.4.0
309309
*/
310-
public function hookActionCustomerRegisterSubmitCaptcha($params)
310+
public function hookActionCustomerRegisterSubmitCaptcha(array $params)
311311
{
312312
if (Configuration::get('CAPTCHA_ENABLE_ACCOUNT') == 1) {
313313
return $this->_validateCaptcha();
@@ -336,7 +336,7 @@ public function hookActionContactFormSubmitBefore()
336336
*
337337
* @since 2.1.0
338338
*/
339-
public function hookActionAdminControllerSetMedia($params)
339+
public function hookActionAdminControllerSetMedia(array $params)
340340
{
341341
if (
342342
$this->context->controller instanceof AdminModulesController
@@ -359,7 +359,7 @@ public function hookActionAdminControllerSetMedia($params)
359359
*
360360
* @since 2.1.0
361361
*/
362-
public function hookDisplayNewsletterRegistration($params)
362+
public function hookDisplayNewsletterRegistration(array $params)
363363
{
364364
if (
365365
Configuration::get('CAPTCHA_ENABLE_NEWSLETTER') == 1
@@ -386,7 +386,7 @@ public function hookDisplayNewsletterRegistration($params)
386386
*
387387
* @since 2.1.0
388388
*/
389-
public function hookActionNewsletterRegistrationBefore($params)
389+
public function hookActionNewsletterRegistrationBefore(array $params)
390390
{
391391
if (Configuration::get('CAPTCHA_ENABLE_NEWSLETTER') == 1
392392
&& $this->canUseCaptchaOnNewsletter()
@@ -445,7 +445,7 @@ protected function _validateCaptcha()
445445
*
446446
* @return array The eicaptcha configuration
447447
*/
448-
public function hookActionGetEicaptchaParams($params)
448+
public function hookActionGetEicaptchaParams(array $params)
449449
{
450450
return [
451451
'displayCaptcha' => $this->shouldDisplayToCustomer(),
@@ -463,7 +463,7 @@ public function hookActionGetEicaptchaParams($params)
463463
*
464464
* @return string the rendered template for displaying the captcha ( if needed)
465465
*/
466-
public function hookDisplayEicaptchaVerification($params)
466+
public function hookDisplayEicaptchaVerification(array $params)
467467
{
468468
$this->context->smarty->assign([
469469
'displayCaptcha' => $this->shouldDisplayToCustomer(),
@@ -483,7 +483,7 @@ public function hookDisplayEicaptchaVerification($params)
483483
*
484484
* @return bool
485485
*/
486-
public function hookActionValidateCaptcha($params = [])
486+
public function hookActionValidateCaptcha(array $params = [])
487487
{
488488
return $this->_validateCaptcha();
489489
}

src/Debugger.php

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,36 @@ protected function checkNewsletter()
252252
} else {
253253
if ($this->module->canUseCaptchaOnNewsletter()) {
254254
$success[] = $this->l('Module ps_emailsubscription version allow to use captcha on newsletter');
255-
$newsletterTemplateFile = _PS_THEME_DIR_ . 'modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl';
256-
if (is_file($newsletterTemplateFile)) {
257-
$newsletterTemplateContent = file_get_contents($newsletterTemplateFile);
258-
if (!preg_match('#displayNewsletterRegistration#', $newsletterTemplateContent)) {
259-
$moduleDefaultFile = _PS_MODULE_DIR_ . 'ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl';
260-
$errors[] = sprintf(
261-
$this->l(
262-
'Missing hook %s in template %s , Please check in original module file to adapt : %s'
263-
),
264-
'<strong>displayNewsletterRegistration</strong>',
265-
'<i>' . $newsletterTemplateFile . '</i>',
266-
'<i>' . $moduleDefaultFile . '</i>'
267-
);
255+
256+
$newsletterTemplatesFiles = [
257+
_PS_THEME_DIR_ . 'modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl',
258+
_PS_PARENT_THEME_DIR_ . 'modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl',
259+
];
260+
$hookFound = $hasThemeFile = false;
261+
foreach ($newsletterTemplatesFiles as $newsletterTemplateFile) {
262+
if (is_file($newsletterTemplateFile)) {
263+
$hasThemeFile = true;
264+
$newsletterTemplateContent = file_get_contents($newsletterTemplateFile);
265+
if (preg_match('#displayNewsletterRegistration#', $newsletterTemplateContent)) {
266+
$hookFound = true;
267+
}
268+
break;
268269
}
269-
//@Todo manage multi-shop configuration
270-
} else {
271-
$errors[] = $this->l('Module ps_emailsubscription version do not allow to use captcha on newsletter');
272270
}
271+
if (false === $hookFound && true === $hasThemeFile) {
272+
$moduleDefaultFile = _PS_MODULE_DIR_ . 'ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl';
273+
$errors[] = sprintf(
274+
$this->l(
275+
'Missing hook %s in template %s , Please check in original module file to adapt : %s'
276+
),
277+
'<strong>displayNewsletterRegistration</strong>',
278+
'<i>' . $newsletterTemplateFile . '</i>',
279+
'<i>' . $moduleDefaultFile . '</i>'
280+
);
281+
}
282+
//@Todo manage multi-shop configuration
283+
} else {
284+
$errors[] = $this->l('Module ps_emailsubscription version do not allow to use captcha on newsletter');
273285
}
274286
}
275287

@@ -289,19 +301,23 @@ protected function checkNewsletter()
289301
protected function checkHookDisplayCustomerAccountForm()
290302
{
291303
$errors = $success = [];
292-
$templateFile = _PS_THEME_DIR_ . 'templates/customer/_partials/customer-form.tpl';
293-
if (is_file($templateFile)) {
294-
$templateContent = file_get_contents($templateFile);
295-
if (preg_match('#\{\$hook_create_account_form nofilter\}#', $templateContent)) {
296-
$success[] = $this->l('The hook displayCustomerAccountForm is present in the default template');
297-
} else {
298-
$errors[] = sprintf(
299-
$this->l('Unable to find the hook displayCustomerAccountForm in the default template, you can read more about it %s'),
300-
'<a href="' . self::URL_WIKI_DISPLAYCUSTOMERACCOUNTFORM . '" target="_blank">' . $this->l('here') . '</a>'
301-
);
304+
$templateFiles = [
305+
_PS_THEME_DIR_ . 'templates/customer/_partials/customer-form.tpl',
306+
_PS_PARENT_THEME_DIR_ . 'templates/customer/_partials/customer-form.tpl',
307+
];
308+
foreach ($templateFiles as $templateFile) {
309+
if (is_file($templateFile)) {
310+
$templateContent = file_get_contents($templateFile);
311+
if (preg_match('#\{\$hook_create_account_form nofilter\}#', $templateContent)) {
312+
$success[] = $this->l('The hook displayCustomerAccountForm is present in the default template');
313+
} else {
314+
$errors[] = sprintf(
315+
$this->l('Unable to find the hook displayCustomerAccountForm in the default template, you can read more about it %s'),
316+
'<a href="' . self::URL_WIKI_DISPLAYCUSTOMERACCOUNTFORM . '" target="_blank">' . $this->l('here') . '</a>'
317+
);
318+
}
319+
break;
302320
}
303-
} else {
304-
$errors[] = sprintf($this->l('Unable to find the default customer account file : %s'), $templateFile);
305321
}
306322

307323
return [
@@ -317,7 +333,7 @@ protected function checkHookDisplayCustomerAccountForm()
317333
*
318334
* @return void
319335
*/
320-
public function log($message)
336+
public function log($message): void
321337
{
322338
if ($this->isDebugEnabled()) {
323339
file_put_contents(

src/Installer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Installer
4141
'actionContactFormSubmitBefore',
4242
'actionNewsletterRegistrationBefore',
4343
'actionAdminControllerSetMedia',
44-
'actionContactFormSubmitCaptcha',
4544
'displayEicaptchaVerification',
4645
];
4746

translations/fr.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
$_MODULE = array();
55
$_MODULE['<{eicaptcha}prestashop>eicaptcha_3e87eed4786fe702ae961b55bbf02c6a'] = 'EiCaptcha';
66
$_MODULE['<{eicaptcha}prestashop>eicaptcha_76870a3a596aa5fe3b836a20e53c7698'] = 'Ajout de Captcha sur le formulaire de contact et de création de compte';
7-
$_MODULE['<{eicaptcha}prestashop>eicaptcha_793b58515cefe26f6a3c5ab782460a69'] = 'Le mode Captcha doit être configuré';
87
$_MODULE['<{eicaptcha}prestashop>eicaptcha_632ee8e447c5c09ca7577f9281cbb999'] = 'Merci de valider le captcha';
98
$_MODULE['<{eicaptcha}prestashop>eicaptcha_9ed81dbbae814f9a81cd15927ebd4795'] = 'Réponse recaptcha %s';
109
$_MODULE['<{eicaptcha}prestashop>eicaptcha_e8a0559d823da2ac04358b8bf1a1dbd1'] = 'Captcha soumis avec succès';
@@ -29,9 +28,8 @@
2928
$_MODULE['<{eicaptcha}prestashop>debugger_7f23d4054a5061b22541b424afedd341'] = 'Le hook %s est manquant dans le template %s, merci de regarder le fichier original pour adapter : %s';
3029
$_MODULE['<{eicaptcha}prestashop>debugger_d67c59bfd472277a56f1423766b99929'] = 'La version du module ps_emailsubscription ne vous permets pas d\'utiliser le captcha sur la newsletter';
3130
$_MODULE['<{eicaptcha}prestashop>debugger_31af46ab2a3c469c5018c81963f0a6ab'] = 'Le hook displayCustomerAccountForm est présent dans le template du formulaire par défaut';
32-
$_MODULE['<{eicaptcha}prestashop>debugger_8ec3b69923dbe0ef570523badb438c57'] = 'Le hook displayCustomerAccountForm est présent dans le template du formulaire par défaut, vous pouvez trouver plus d\'informations %s';
31+
$_MODULE['<{eicaptcha}prestashop>debugger_8ec3b69923dbe0ef570523badb438c57'] = 'Le hook displayCustomerAccountForm n\'est pas présent dans le template du formulaire par défaut, vous pouvez trouver plus d\'informations %s';
3332
$_MODULE['<{eicaptcha}prestashop>debugger_6c92285fa6d3e827b198d120ea3ac674'] = 'ici';
34-
$_MODULE['<{eicaptcha}prestashop>debugger_adc97d9600fc738216260afbf67e34cf'] = 'Impossible de trouver le template par défaut du formulaire de création de compte %s';
3533
$_MODULE['<{eicaptcha}prestashop>configform_fabff9d49a682feeffead298a9801c2b'] = 'Configuration EiCaptcha';
3634
$_MODULE['<{eicaptcha}prestashop>configform_d2126da975d5b9a5b846efaf57d3fd53'] = 'Configuration générale';
3735
$_MODULE['<{eicaptcha}prestashop>configform_a88fa0f6033212151410a58809337c83'] = 'Paramètres avancés';

0 commit comments

Comments
 (0)