From 94c58d00ed003b557d762eacadce5aafbf4c3c90 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Tue, 25 Mar 2025 11:16:32 +0100
Subject: [PATCH] dev#158027 : add RGPD consent in subscription and contact
 form

---
 FEATURES/158027                               | 10 ++++
 VERSIONS_WIP/158027                           |  1 +
 .../opac/controllers/AuthController.php       |  2 +-
 .../scripts/auth/newsletter-register.phtml    |  2 +-
 cosmogramme/sql/patch/patch_479.php           |  7 +++
 library/Class/AdminVar.php                    |  2 +-
 library/Class/AdminVar/PortalBorrowers.php    |  2 +-
 .../SIGB/AbstractPreRegistration.php          | 13 +----
 library/ZendAfi/Form.php                      | 14 +++++
 .../Form/Configuration/AuthRegister.php       | 20 +------
 library/ZendAfi/Form/ContactForm.php          |  3 +-
 library/ZendAfi/Form/NewsletterRegister.php   |  1 +
 library/ZendAfi/Form/Register.php             | 25 ++-------
 .../Helper/Admin/PortalBorrowersDashboard.php |  2 +-
 ...ditControllerRgpdConditionsMessageTest.php | 50 +++++++++++++++++
 ...ollerNewsletterRegisterRgpdConsentTest.php | 53 +++++++++++++++++++
 .../AuthControllerPreRegistrationTest.php     |  6 +--
 .../AuthControllerRegisterRgpdConsentTest.php | 47 ++++++++++++++++
 .../opac/controllers/AuthControllerTest.php   | 29 ++++++++++
 .../FormulaireContactRgpdConsentTest.php      | 45 ++++++++++++++++
 .../controllers/FormulaireContactTest.php     | 12 +++++
 .../PortalBorrowersAdminTest.php              |  4 +-
 .../PortalBorrowersConfigTest.php             |  7 ---
 .../PortalBorrowersFrontTest.php              |  8 ++-
 .../PortalBorrowersTestCases.php              |  2 +-
 .../scenarios/Templates/TemplatesFormTest.php |  2 +-
 tests_db/UpgradeDBTest.php                    | 20 +++++++
 27 files changed, 312 insertions(+), 77 deletions(-)
 create mode 100644 FEATURES/158027
 create mode 100644 VERSIONS_WIP/158027
 create mode 100644 cosmogramme/sql/patch/patch_479.php
 create mode 100644 tests/application/modules/admin/controllers/AdminVarEditControllerRgpdConditionsMessageTest.php
 create mode 100644 tests/application/modules/opac/controllers/AuthControllerNewsletterRegisterRgpdConsentTest.php
 create mode 100644 tests/application/modules/opac/controllers/AuthControllerRegisterRgpdConsentTest.php
 create mode 100644 tests/application/modules/opac/controllers/FormulaireContactRgpdConsentTest.php

diff --git a/FEATURES/158027 b/FEATURES/158027
new file mode 100644
index 00000000000..bfc5d474507
--- /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 00000000000..91f1c8fcb07
--- /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 ab7798f5ef0..cb9d1adb491 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 5b5423e2077..f4679f0e4fc 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 00000000000..223badd279f
--- /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 16591ba8ad8..8f62726cfd9 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 f971d219900..0914fedbdda 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 13af24ea762..caf14e4d332 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 b358599da9e..f40717bcaa8 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 c0e832b4ef0..59fc40b7f9e 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 5a9ffdb1cb8..541bdd991a7 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 3b60dd668bf..14e2af97332 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 85dceb2d5cf..817ed5769e3 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 3319d03715e..49afad4cd4c 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 00000000000..9a5b3859448
--- /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 00000000000..f3eac9d011e
--- /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 6b8fc61f863..721c39d4fe7 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 00000000000..93fd3a19f8b
--- /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 7d2743851a2..3b87cac062e 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 00000000000..717c7fe08f5
--- /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 9b4e2ff1389..8d8dc0323e6 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 ba9698a7160..0c4caf0f94e 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 edaa7765f4c..d55fb6c17b9 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 31601d09c0c..a8b8b23b79b 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 9ced38a8272..8fc7aad516e 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 800280545ff..9d84e0b30e8 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 1e85c1b0920..afd84f538e3 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']);
+  }
+}
-- 
GitLab