diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 87eeba675d6be62636ff5fd0abbcfa07fe512957..53527cfe81df3fb943b4c53c03d3fe986e19432a 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -162,7 +162,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'TEXT_REPLACEMENTS' => Class_AdminVar_Meta::newRawText($this->_('Remplacement de textes à la volée. <br/>Ex:<br/>Panier;Sélection<br/>Vous avez %%d paniers;Vous avez %%d sélections')), 'URL_COSMOGRAMME' => Class_AdminVar_Meta::newDefault('')->bePrivate(), - 'PACK_MOBILE' => Class_AdminVar_Meta::newOnOff($this->_('Activation des fonctions avancées du téléphone'))->bePrivate()], + 'PACK_MOBILE' => Class_AdminVar_Meta::newOnOff($this->_('Activation des fonctions avancées du téléphone'))->bePrivate(), + 'CNIL_CONSENT_ENABLE' => Class_AdminVar_Meta::newOnOff("Affiche la demande de consentement avant l'insertion de cookies ou autres traceurs")->bePrivate()], 'catalogue' => [ 'OAI_SERVER' => Class_AdminVar_Meta::newOnOff($this->_('Activation du serveur OAI: permet le moissonnage des domaines par d\'autres logiciels via OAI'))], 'newsletter' => [ diff --git a/library/ZendAfi/Controller/Plugin/CnilConsent.php b/library/ZendAfi/Controller/Plugin/CnilConsent.php index 14544081a50eb752557b95da05090e2353adab0c..cf0b78107ad59710d9a4948c5e9cb4ed50b41ab9 100644 --- a/library/ZendAfi/Controller/Plugin/CnilConsent.php +++ b/library/ZendAfi/Controller/Plugin/CnilConsent.php @@ -24,6 +24,7 @@ class ZendAfi_Controller_Plugin_CnilConsent extends Zend_Controller_Plugin_Abstract { function preDispatch(Zend_Controller_Request_Abstract $request) { - (new Class_Cnil())->trackConsent(); + if (Class_AdminVar::get('CNIL_CONSENT_ENABLE')) + (new Class_Cnil())->trackConsent(); } } diff --git a/tests/application/modules/opac/controllers/IndexControllerTest.php b/tests/application/modules/opac/controllers/IndexControllerTest.php index 735d5d6510f494ff20c757a16f0d1ea89c6e7cee..46202796e821cbe853c7288171e3ead304b84667 100644 --- a/tests/application/modules/opac/controllers/IndexControllerTest.php +++ b/tests/application/modules/opac/controllers/IndexControllerTest.php @@ -322,6 +322,10 @@ abstract class IndexControllerCnilTrackingTestCase extends AbstractControllerTes public function setUp() { parent::setUp(); + + $this->fixture('Class_AdminVar', ['id' => 'CNIL_CONSENT_ENABLE', + 'valeur' => true]); + Class_Cnil::setTimeSource($this->mock() ->whenCalled('time') ->answers(strtotime('2015-09-25 15:45:54'))); @@ -348,6 +352,7 @@ class IndexControllerCnilTrackingFirstVisitTest public function setUp() { parent::setUp(); + $this->dispatch('/', true); } @@ -366,6 +371,26 @@ class IndexControllerCnilTrackingFirstVisitTest +class IndexControllerCnilTrackingFirstVisitWithAdminVarDisabledTest + extends IndexControllerCnilTrackingTestCase { + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_AdminVar', ['id' => 'CNIL_CONSENT_ENABLE', + 'valeur' => false]); + $this->dispatch('/', true); + } + + + /** @test */ + public function shouldDisplayCnilMessage() { + $this->assertNotXPathContentContains('//script', $this->_expected_message); + } +} + + + class IndexControllerCnilTrackingSecondVisitTest extends IndexControllerCnilTrackingTestCase {