diff --git a/FEATURES/158027 b/FEATURES/158027 new file mode 100644 index 0000000000000000000000000000000000000000..bfc5d474507d96dcb125895d2ff1e0bc34da4939 --- /dev/null +++ b/FEATURES/158027 @@ -0,0 +1,10 @@ + '158027' => + ['Label' => $this->_('Ajout du consentement RGPD dans les formulaires d'inscription et de contact'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2025-03-26'], \ No newline at end of file diff --git a/VERSIONS_WIP/158027 b/VERSIONS_WIP/158027 new file mode 100644 index 0000000000000000000000000000000000000000..91f1c8fcb070e37cd9489f41c64be25697ef1544 --- /dev/null +++ b/VERSIONS_WIP/158027 @@ -0,0 +1 @@ + - fonctionnalité #158027 : Ajout du consentement RGPD dans les formulaires d'inscription et de contact \ No newline at end of file diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index ab7798f5ef0198d1650fc781efe3834141a336d2..cb9d1adb49183b1b8dabc968c2353d93837db7be 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -703,7 +703,7 @@ class AuthController extends ZendAfi_Controller_Action { return null; unset($data['website']); - unset($data[Class_WebService_SIGB_AbstractPreRegistration::REQUIRED_CHECKBOX_NAME]); + unset($data[ZendAfi_Form::RGPD_CHECKBOX_NAME]); $registration_data = $registration->getData($data); diff --git a/application/modules/opac/views/scripts/auth/newsletter-register.phtml b/application/modules/opac/views/scripts/auth/newsletter-register.phtml index 5b5423e2077d897d375711644839df5cd6c9bae0..f4679f0e4fcf0b79a3718adec760e4c9cf08603a 100644 --- a/application/modules/opac/views/scripts/auth/newsletter-register.phtml +++ b/application/modules/opac/views/scripts/auth/newsletter-register.phtml @@ -1,6 +1,6 @@ <?php $this->openBoite($this->titre); -echo $this->form; +echo $this->renderForm($this->form); echo $this->error ? $this->renderError($this->error) : ''; echo $this->tag('br',''); echo $this->getConnectionUrl($this->_('J\'ai déjà un compte.')); diff --git a/cosmogramme/sql/patch/patch_479.php b/cosmogramme/sql/patch/patch_479.php new file mode 100644 index 0000000000000000000000000000000000000000..223badd279fdb5e2cc3317150b51962552470f9c --- /dev/null +++ b/cosmogramme/sql/patch/patch_479.php @@ -0,0 +1,7 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query('UPDATE `bib_admin_var` SET `clef` = "RGPD_CONDITIONS_MESSAGE"' + . ' WHERE `clef` = "PREREGISTRATION_CONDITIONS_MESSAGE"'); +} catch(Exception $e) {} diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 16591ba8ad82f2db04f90743d0d351ad29f852a9..8f62726cfd9bbf9433f0dedfe5fb89a6137fe12f 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -813,7 +813,7 @@ class Class_AdminVarLoader extends Storm_Model_Loader 'NOTIFICATION_TEMPLATE_PREREGISTRATION' => Class_AdminVar_Meta::newEditor($this->_('Modèle utilisé pour les courriels d\'accueil d\'une préinscription.'), ['value'=> "Bonjour,<br><br><p>Votre demande d'inscription à <b>{library.libelle}</b> a bien été enregistrée.</p><p>Afin de finaliser votre inscription, merci de vous rendre dans votre médiathèque : <b>{library.adresse} {library.cp} {library.ville}</b></p>"]), - 'PREREGISTRATION_CONDITIONS_MESSAGE' => Class_AdminVar_Meta::newEditor($this->_('Formulaire de préinscription : texte de la case à cocher permettant d\'accepter les conditions de validation.'), ['value' => '']), + 'RGPD_CONDITIONS_MESSAGE' => Class_AdminVar_Meta::newEditor($this->_('Formulaires : texte de la case à cocher permettant d\'accepter les conditions de validation.'), ['value' => '']), 'NOTIFICATION_TEMPLATE_NEW_REGISTRATION_SUBJECT' => Class_AdminVar_Meta::newDefault($this->_('Sujet des courriels d\'accueil des nouveaux utilisateurs.'), ['value'=> 'Demande d\'inscription: {profil.libelle}'])]; } diff --git a/library/Class/AdminVar/PortalBorrowers.php b/library/Class/AdminVar/PortalBorrowers.php index f971d2199009307a4e9ef92fb73aa9819ac1284b..0914fedbdda3f162342f7b2df9c79dc23f369999 100644 --- a/library/Class/AdminVar/PortalBorrowers.php +++ b/library/Class/AdminVar/PortalBorrowers.php @@ -101,7 +101,7 @@ class Class_AdminVar_PortalBorrowers { return [Class_AdminVar::find(static::TRIGGER), Class_AdminVar::find(static::FORBID_REGISTER), - Class_AdminVar::find('PREREGISTRATION_CONDITIONS_MESSAGE'), + Class_AdminVar::find('RGPD_CONDITIONS_MESSAGE'), Class_AdminVar::find(static::LIBRARIES_IDS), Class_AdminVar::find(static::VALIDATION_DELAY), Class_AdminVar::find(static::VALID_SUBSCRIPTION_DELAY), diff --git a/library/Class/WebService/SIGB/AbstractPreRegistration.php b/library/Class/WebService/SIGB/AbstractPreRegistration.php index 13af24ea76242afa007738315edab1332b1d29f2..caf14e4d332e8bd544ff80c94ad8be4ba68873f9 100644 --- a/library/Class/WebService/SIGB/AbstractPreRegistration.php +++ b/library/Class/WebService/SIGB/AbstractPreRegistration.php @@ -24,8 +24,6 @@ abstract class Class_WebService_SIGB_AbstractPreRegistration { use Trait_Translator, Trait_Logger; - const REQUIRED_CHECKBOX_NAME = 'conditions_message'; - protected $_user, $_form; @@ -101,16 +99,7 @@ abstract class Class_WebService_SIGB_AbstractPreRegistration { $form = $this->_getFormInstance()->setAttrib('autocomplete', 'on'); $form->setAction(Class_Url::absolute()); $form = $this->_populateFormWith($form, $this->_user); - - if ( ! $validation_message = trim(Class_AdminVar::get('PREREGISTRATION_CONDITIONS_MESSAGE') ?? '')) - return $this->setForm($form); - - $form->addElement('requiredCheckbox', - static::REQUIRED_CHECKBOX_NAME, - ['label' => $validation_message ]); - - $form->addDisplayGroup(['conditions_message'], 'conditions', - ['legend' => $this->_('Conditions')]); + $form->addRgpdConsent(); return $this->setForm($form); } diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index b358599da9e68455b591072cd8b3813516689ce4..f40717bcaa8f107be804e967c7f1c447626dc97e 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -24,6 +24,7 @@ class ZendAfi_Form extends Zend_Form { use Trait_Translator; const EXPERT_LEVEL = 'expert'; + const RGPD_CHECKBOX_NAME = 'conditions_message'; protected $_text_size = 40, @@ -534,4 +535,17 @@ class ZendAfi_Form extends Zend_Form { $name = explode('_', get_class($this)); return strtolower((string) array_pop($name)); } + + + public function addRgpdConsent(): self + { + if ($consent_message = trim(Class_AdminVar::get('RGPD_CONDITIONS_MESSAGE') ?? '')) + $this->addElement('requiredCheckbox', + static::RGPD_CHECKBOX_NAME, + ['label' => $consent_message]) + ->addDisplayGroup([static::RGPD_CHECKBOX_NAME], 'conditions', + ['legend' => $this->_('Conditions')]); + + return $this; + } } diff --git a/library/ZendAfi/Form/Configuration/AuthRegister.php b/library/ZendAfi/Form/Configuration/AuthRegister.php index c0e832b4ef02d45607be2e10784d55901ac416cd..59fc40b7f9e3ffed60b6e217ce2c55f036d09ff6 100644 --- a/library/ZendAfi/Form/Configuration/AuthRegister.php +++ b/library/ZendAfi/Form/Configuration/AuthRegister.php @@ -77,23 +77,7 @@ class ZendAfi_Form_Configuration_AuthRegister extends ZendAfi_Form_Configuration 'prefs', ['legend' => $this->_('Préférences')]) - ->_addOptionalFields() - ->_addRgpd(); - } - - - protected function _addRgpd() : self { - if (!$this->_portalBorrowers()->isEnabled()) - return $this; - - return $this - ->addElement('ckeditor', - 'rgpd', - ['label' => $this->_('Texte RGPD à accepter'), - 'required' => true, - 'allowEmpty' => false]) - - ->addToDisplayGroup(['rgpd'], 'prefs'); + ->_addOptionalFields(); } @@ -116,7 +100,7 @@ class ZendAfi_Form_Configuration_AuthRegister extends ZendAfi_Form_Configuration parent::populate($datas); if ( (! ($datas['rgpd'] ?? '')) && ($rgpd = $this->getElement('rgpd'))) - $rgpd->setValue(Class_AdminVar::get('PREREGISTRATION_CONDITIONS_MESSAGE')); + $rgpd->setValue(Class_AdminVar::get('RGPD_CONDITIONS_MESSAGE')); if (!array_key_exists('fields', $datas)) return $this; diff --git a/library/ZendAfi/Form/ContactForm.php b/library/ZendAfi/Form/ContactForm.php index 5a9ffdb1cb8c87693086ca70ba3743071be20ccd..541bdd991a71a198e9471494936d3b457b09e04b 100644 --- a/library/ZendAfi/Form/ContactForm.php +++ b/library/ZendAfi/Form/ContactForm.php @@ -27,7 +27,8 @@ class ZendAfi_Form_ContactForm extends ZendAfi_Form { $this->setAttrib('class', 'zend_form form') ->setAttrib('autocomplete', 'on') ->addAllElements() - ->addAllGroups(); + ->addAllGroups() + ->addRgpdConsent(); } diff --git a/library/ZendAfi/Form/NewsletterRegister.php b/library/ZendAfi/Form/NewsletterRegister.php index 3b60dd668bf83d9dd5ec4bfbd9ea06c2af08d8e5..14e2af97332e11c90e5d4388984bb0b18705867f 100644 --- a/library/ZendAfi/Form/NewsletterRegister.php +++ b/library/ZendAfi/Form/NewsletterRegister.php @@ -31,6 +31,7 @@ class ZendAfi_Form_NewsletterRegister extends ZendAfi_Form { 'required' => true, 'allowEmpty'=> false]) ->addElement('negativeCaptcha', 'website') + ->addRgpdConsent() ->addElement('submit', 'submit', ['label' => $this->_('Valider')]); } } diff --git a/library/ZendAfi/Form/Register.php b/library/ZendAfi/Form/Register.php index 85dceb2d5cf4621c984ecab7c67e5cc221b89b27..817ed5769e342b878b542c0d922f3f638b9a02ef 100644 --- a/library/ZendAfi/Form/Register.php +++ b/library/ZendAfi/Form/Register.php @@ -28,7 +28,7 @@ class ZendAfi_Form_Register extends ZendAfi_Form { $this->_initCommons() ->_initOptionals() - ->_addRGPDElements(); + ->addRgpdConsent(); $this->addElement('submit','submit', ['label' => $this->_('Valider')]); } @@ -88,24 +88,6 @@ class ZendAfi_Form_Register extends ZendAfi_Form { } - protected function _addRGPDElements() : self { - if (!$this->_portalBorrowers()->isEnabled()) - return $this; - - $explaination = ($explaination = $this->_pref('rgpd')) - ? $explaination - : Class_AdminVar::get('PREREGISTRATION_CONDITIONS_MESSAGE'); - - if (!trim(strip_tags($explaination))) - return $this; - - return $this - ->addElement('requiredCheckbox', - 'accept_rgpd', - ['label' => $explaination]); - } - - protected function _pref(string $name) : string { return Class_Profil::getCurrentProfil() ->getModulePreference('auth', 'register', $name) ?? ''; @@ -113,10 +95,9 @@ class ZendAfi_Form_Register extends ZendAfi_Form { public function hasRequiredElements() : bool { - return 3 === + return 2 === (new Storm_Collection(['idabon', - 'id_site', - 'accept_rgpd'])) + 'id_site'])) ->select(fn($element_id) => $this->_hasRequiredElement($element_id)) ->count(); } diff --git a/library/ZendAfi/View/Helper/Admin/PortalBorrowersDashboard.php b/library/ZendAfi/View/Helper/Admin/PortalBorrowersDashboard.php index 3319d03715e890534d9f4e393b07bc7d3e626d72..49afad4cd4c5fe3585aa1745d73e9b6e4ea5d9b1 100644 --- a/library/ZendAfi/View/Helper/Admin/PortalBorrowersDashboard.php +++ b/library/ZendAfi/View/Helper/Admin/PortalBorrowersDashboard.php @@ -124,7 +124,7 @@ class ZendAfi_View_Helper_Admin_PortalBorrowersDashboard extends ZendAfi_View_He $errors [] = $this->_tagError($this->_('La variable PORTAL_BORROWERS_LIBRARIES_IDS doit être renseignée')); if ( ! $vars->isAuthRegisterFormReady()) - $errors [] = $this->_tagError($this->_('Dans le formulaire d\'inscription, les champs "Bibliothèque d\'inscription", "N° de carte" et "Texte RGPD à accepter" doivent être "Affiché et obligatoire"')); + $errors [] = $this->_tagError($this->_('Dans le formulaire d\'inscription, les champs "Bibliothèque d\'inscription", "N° de carte" et doivent être "Affiché et obligatoire"')); return ($errors !== [] ? $this->view->button((new Class_Button) diff --git a/tests/application/modules/admin/controllers/AdminVarEditControllerRgpdConditionsMessageTest.php b/tests/application/modules/admin/controllers/AdminVarEditControllerRgpdConditionsMessageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9a5b38594489ae6ebfdf351b74013cb29413c3fc --- /dev/null +++ b/tests/application/modules/admin/controllers/AdminVarEditControllerRgpdConditionsMessageTest.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright (c) 2012-2025, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class AdminVarEditControllerRgpdConditionsMessageTest + extends Admin_AbstractControllerTestCase +{ + + public function setUp(): void + { + parent::setUp(); + $this->fixture(Class_AdminVar::class, + ['id' => 'RGPD_CONDITIONS_MESSAGE', + 'valeur' => 'foo']); + + $this->dispatch('/admin/index/adminvaredit/cle/RGPD_CONDITIONS_MESSAGE'); + } + + /** @test */ + public function pageTitleShouldBeModifierLaVariableRgpd() + { + $this->assertXPathContentContains('//div[@class="modules"]/h1', + 'Modifier la variable: RGPD_CONDITIONS_MESSAGE'); + } + + /** @test */ + public function variableTitleShouldBeFormualireTextDelaCaseACocher() + { + $this->assertXPathContentContains('//div[@class="modules"]/p', + 'Formulaires : texte de la case à cocher permettant d\'accepter les conditions de validation.'); + } +} diff --git a/tests/application/modules/opac/controllers/AuthControllerNewsletterRegisterRgpdConsentTest.php b/tests/application/modules/opac/controllers/AuthControllerNewsletterRegisterRgpdConsentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f3eac9d011ea523f47344c25103f6cc2df97208b --- /dev/null +++ b/tests/application/modules/opac/controllers/AuthControllerNewsletterRegisterRgpdConsentTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2012-2025, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class AuthControllerNewsletterRegisterRgpdConsentTest extends AbstractControllerTestCase +{ + public function setUp(): void + { + parent::setUp(); + + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); + ZendAfi_Auth::getInstance()->clearIdentity(); + + $this->fixture(Class_Newsletter::class, + ['id' => 5, + 'mail_subject' => 'Goog News', + 'titre' => 'Good News']); + + $this->dispatch('/opac/auth/newsletter-register/id/5'); + } + + /** @test */ + public function newsletterRegisterRgpdConsentMessageShouldBeDisplayed() + { + $this->assertXPathContentContains('//form//label[@for="conditions_message"]', + 'Vos données vous appartiennent'); + } + + /** @test */ + public function newsletterRegisterRgpdConsentCheckboxShouldBeDisplayed() + { + $this->assertXPath('//form//input[@id="conditions_message"]' + . '[@type="checkbox"][@required="required"]'); + } +} diff --git a/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php b/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php index 6b8fc61f8636737d0f14a7536ef8662927d24ccf..721c39d4fe7d48c3769687bf4c910d7922c48bb4 100644 --- a/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php @@ -121,7 +121,7 @@ abstract class AuthControllerPreRegistrationKohaPostDispatchTestCase extends Aut 'website' => '']; if ($this->_required_checkbox) - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); $values = []; if ($this->_required_checkbox) @@ -391,7 +391,7 @@ class AuthControllerPreRegistrationNanookDispatchWithValidationTest public function setUp(): void { parent::setUp(); - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', '<a href"#">Vous devez accepter les conditions de validation</a>'); + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', '<a href"#">Vous devez accepter les conditions de validation</a>'); $this->postDispatch('/opac/auth/pre-registration', []); } @@ -410,7 +410,7 @@ class AuthControllerRegistrationWithConditionsTest extends AuthControllerPreRegi public function setUp(): void { parent::setUp(); - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); $this->dispatch('/opac/auth/pre-registration'); } diff --git a/tests/application/modules/opac/controllers/AuthControllerRegisterRgpdConsentTest.php b/tests/application/modules/opac/controllers/AuthControllerRegisterRgpdConsentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..93fd3a19f8b5c5395bcb58c24a92347637e2b4f4 --- /dev/null +++ b/tests/application/modules/opac/controllers/AuthControllerRegisterRgpdConsentTest.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2012-2025, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + +class AuthControllerRegisterRgpdConsentTest extends AbstractControllerTestCase +{ + public function setUp(): void + { + parent::setUp(); + + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); + $this->dispatch('/opac/index/formulairecontact'); + } + + /** @test */ + public function registerRgpdConsentMessageShouldBeDisplayed() + { + $this->assertXPathContentContains('//form//label[@for="conditions_message"]', + 'Vos données vous appartiennent'); + } + + /** @test */ + public function registerRgpdConsentCheckboxShouldBeDisplayed() + { + $this->assertXPath('//form//input[@id="conditions_message"]' + . '[@type="checkbox"][@required="required"]'); + } +} diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index 7d2743851a2f6c88bba0379b6a9f8f621d6af931..3b87cac062ebd2696b6b776786d1b2ff1726efc6 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -1556,6 +1556,20 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest public function inputMdp2ShouldBePresent() { $this->assertXPath('//input[@name="mdp2"][@maxlength=15]'); } + + + /** @test */ + public function registerRgpdConsentMessageShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//label[@for="conditions_message"]'); + } + + /** @test */ + public function registerRpdConsentCheckboxShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//input[@id="conditions_message"]' + . '[@type="checkbox"][@required="required"]'); + } } @@ -2245,6 +2259,21 @@ class AuthControllerNobodyLoggedAndRegisterNewsletterTest extends AuthController public function submitButtonShouldBePresent() { $this->assertXPath('//form//input[@type="submit"][@value="Valider"]'); } + + + + /** @test */ + public function newsletterRegisterRgpdConsentMessageShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//label[@for="conditions_message"]'); + } + + /** @test */ + public function newsletterRegisterRpdConsentCheckboxShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//input[@id="conditions_message"]' + . '[@type="checkbox"][@required="required"]'); + } } diff --git a/tests/application/modules/opac/controllers/FormulaireContactRgpdConsentTest.php b/tests/application/modules/opac/controllers/FormulaireContactRgpdConsentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..717c7fe08f5f13c9bec9338e799d7379662afef7 --- /dev/null +++ b/tests/application/modules/opac/controllers/FormulaireContactRgpdConsentTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright (c) 2012-2025, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class FormulaireContactRgpdConsentTest extends AbstractControllerTestCase +{ + public function setUp(): void + { + parent::setUp(); + + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); + $this->dispatch('/opac/index/formulairecontact'); + } + + /** @test */ + public function contactRgpdConsentMessageShouldBeDisplayed() + { + $this->assertXPath('//form//label[@for="conditions_message"]'); + } + + /** @test */ + public function contactRgpdConsentCheckboxShouldBeDisplayed() + { + $this->assertXPath('//form//input[@id="conditions_message"]' + . '[@type="checkbox"][@required="required"]'); + } +} diff --git a/tests/application/modules/opac/controllers/FormulaireContactTest.php b/tests/application/modules/opac/controllers/FormulaireContactTest.php index 9b4e2ff1389209f0270bb9544c1a471afc48dd46..8d8dc0323e631a1dedca098e2eb0e0913e36c362 100644 --- a/tests/application/modules/opac/controllers/FormulaireContactTest.php +++ b/tests/application/modules/opac/controllers/FormulaireContactTest.php @@ -72,6 +72,18 @@ class FormulaireContactNewTest extends AbstractControllerTestCase { public function formShouldContainsTextAreaForMessage() { $this->assertXPath('//form//textarea[@name="message"]'); } + + /** @test */ + public function rgpdConsentMessageShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//label[@for="conditions_message"]'); + } + + /** @test */ + public function rgpdConsentCheckboxShouldNotBeDisplayed() + { + $this->assertNotXPath('//form//input[@id="conditions_message"]'); + } } diff --git a/tests/scenarios/PortalBorrowers/PortalBorrowersAdminTest.php b/tests/scenarios/PortalBorrowers/PortalBorrowersAdminTest.php index ba9698a71601dc9dfcf6ce044343597c4a4b4c0e..0c4caf0f94ee54444c224ba8acee4ee85cdd2afa 100644 --- a/tests/scenarios/PortalBorrowers/PortalBorrowersAdminTest.php +++ b/tests/scenarios/PortalBorrowers/PortalBorrowersAdminTest.php @@ -72,7 +72,7 @@ class PortalBorrowersAdminIndexTest extends PortalBorrowersActivatedTestCase { 'PORTAL_BORROWERS_EMAIL_DELETE_SUBJECT', 'PORTAL_BORROWERS_EMAIL_DELETE_BODY', 'INTERDIRE_ENREG_UTIL', - 'PREREGISTRATION_CONDITIONS_MESSAGE']); + 'RGPD_CONDITIONS_MESSAGE']); } @@ -1259,7 +1259,7 @@ class PortalBorrowersAdminWithRegisterFormErrorsTest extends PortalBorrowersNyon $this->dispatch('/admin/portal-borrowers'); $this->assertXPathContentContains('//p[@class="error"]', - 'Dans le formulaire d\'inscription, les champs "Bibliothèque d\'inscription", "N° de carte" et "Texte RGPD à accepter" doivent être "Affiché et obligatoire"'); + 'Dans le formulaire d\'inscription, les champs "Bibliothèque d\'inscription", "N° de carte" et doivent être "Affiché et obligatoire"'); } diff --git a/tests/scenarios/PortalBorrowers/PortalBorrowersConfigTest.php b/tests/scenarios/PortalBorrowers/PortalBorrowersConfigTest.php index edaa7765f4cf93dc982c96a1894a9c4bd302be08..d55fb6c17b92c030fb4b943c83d979e770c07b94 100644 --- a/tests/scenarios/PortalBorrowers/PortalBorrowersConfigTest.php +++ b/tests/scenarios/PortalBorrowers/PortalBorrowersConfigTest.php @@ -102,7 +102,6 @@ class PortalBorrowersConfigAdminvareditTest extends PortalBorrowersActivatedTest class PortalBorrowersConfigWidgetEditAuthRegisterTest extends PortalBorrowersActivatedTestCase { public function setUp(): void { parent::setUp(); - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); $this->dispatch('/admin/widget/edit-action/id/auth_register/id_profil/3'); } @@ -125,12 +124,6 @@ class PortalBorrowersConfigWidgetEditAuthRegisterTest extends PortalBorrowersAct } - /** @test */ - public function rgdpPlaceholderShouldBeVosDonneesVousAppartiennent() { - $this->assertXPathContentContains('//form//textarea[@name="rgpd"]', 'Vos données vous appartiennent'); - } - - /** @test */ public function placeholderForLoginShouldBePresent() { $this->assertXPath('//form//input[@name="placeholder_login"]'); diff --git a/tests/scenarios/PortalBorrowers/PortalBorrowersFrontTest.php b/tests/scenarios/PortalBorrowers/PortalBorrowersFrontTest.php index 31601d09c0ccbb5ad8d4e649867bdadc19d12c6f..a8b8b23b79b4b60a83125b3a147982f4eff68d52 100644 --- a/tests/scenarios/PortalBorrowers/PortalBorrowersFrontTest.php +++ b/tests/scenarios/PortalBorrowers/PortalBorrowersFrontTest.php @@ -103,7 +103,7 @@ class PortalBorrowersFrontRegisterTest extends PortalBorrowersActivatedTestCase /** @test */ public function formShouldContainsRequiredCheckboxAcceptRGPD() { - $this->assertXPath('//form//input[@type="checkbox"][@name="accept_rgpd"][@required]'); + $this->assertXPath('//form//input[@type="checkbox"][@name="conditions_message"][@required]'); } @@ -143,9 +143,7 @@ class PortalBorrowersFrontRegisterPostTest extends PortalBorrowersActivatedTestC implode(';', ['library:required', 'civilite:required', - 'naissance:required'])) - ->setModulePreference('auth', 'register', 'rgpd', - 'Vos données vous appartiennent'); + 'naissance:required'])); Zend_Mail::setDefaultTransport($this->_mail_transport=new MockMailTransport); @@ -158,7 +156,7 @@ class PortalBorrowersFrontRegisterPostTest extends PortalBorrowersActivatedTestC 'id_site' => '1', 'civilite' => '-1', 'naissance' => '1977-08-18', - 'accept_rgpd' => '1']); + 'conditions_message' => 1]); $this->_temp_user = Class_UsersNonValid::findFirstBy([]); } diff --git a/tests/scenarios/PortalBorrowers/PortalBorrowersTestCases.php b/tests/scenarios/PortalBorrowers/PortalBorrowersTestCases.php index 9ced38a82726fc6906937431c1ce986121fe8512..8fc7aad516e313eb3367026cafe407722cb3ca73 100644 --- a/tests/scenarios/PortalBorrowers/PortalBorrowersTestCases.php +++ b/tests/scenarios/PortalBorrowers/PortalBorrowersTestCases.php @@ -29,7 +29,7 @@ abstract class PortalBorrowersTestCase extends AbstractControllerTestCase { 'libelle' => 'Nyons', 'mail' => 'webmaster-nyons@test.org']); - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', 'Vos données vous appartiennent'); Class_AdminVar::set('PORTAL_BORROWERS_LIBRARIES_IDS', ''); Class_AdminVar::set('PORTAL_BORROWERS_VALIDATION_DELAY', ''); } diff --git a/tests/scenarios/Templates/TemplatesFormTest.php b/tests/scenarios/Templates/TemplatesFormTest.php index 800280545fff93181a5690f949ee6f1182b2918d..9d84e0b30e8dda58359b4210b11ac9251863b8d8 100644 --- a/tests/scenarios/Templates/TemplatesFormTest.php +++ b/tests/scenarios/Templates/TemplatesFormTest.php @@ -33,7 +33,7 @@ abstract class TemplatesFormPreRegistrationTestCase Zend_Mail::setDefaultTransport($this->mock_transport); $this->mock_web_client = KohaCommunityFixtures::mockWebClientForPreRegistration($this); - Class_AdminVar::set('PREREGISTRATION_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); + Class_AdminVar::set('RGPD_CONDITIONS_MESSAGE', '<a href="#">Vous devez accepter les conditions de validation</a>'); } } diff --git a/tests_db/UpgradeDBTest.php b/tests_db/UpgradeDBTest.php index 1e85c1b09209c323bd1fab4e095efda2c663210b..afd84f538e306fa7c8765353773b120557002739 100644 --- a/tests_db/UpgradeDBTest.php +++ b/tests_db/UpgradeDBTest.php @@ -7150,3 +7150,23 @@ class UpgradeDB_478_Test extends UpgradeDBTestCase $this->assertEquals($this->_cdif3_id, $data[1]['annexe']); } } + + + + +class UpgradeDB_479_Test extends UpgradeDBTestCase +{ + public function prepare() + { + $this->silentQuery('INSERT INTO `bib_admin_var` (`clef`, `valeur`)' + . ' VALUES ("PREREGISTRATION_CONDITIONS_MESSAGE", "my_rgpd_message")'); + } + + /** @test */ + public function preregistrationConditionsMessageVarKeyShouldBecomeRgpd() + { + $this->assertEquals('my_rgpd_message', + $this->query('select valeur from bib_admin_var where clef="RGPD_CONDITIONS_MESSAGE"') + ->fetch()['valeur']); + } +}