From ba60332fdca4455aa2d275115553adc38c1cc44c Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Tue, 26 May 2020 12:35:33 +0200 Subject: [PATCH] hotline#110024 : OPAC : add cardnumber information for loggedin user --- VERSIONS_HOTLINE/110024 | 1 + library/ZendAfi/Controller/Action/Helper/View.php | 7 ++++++- .../modules/opac/controllers/IndexControllerTest.php | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 VERSIONS_HOTLINE/110024 diff --git a/VERSIONS_HOTLINE/110024 b/VERSIONS_HOTLINE/110024 new file mode 100644 index 00000000000..1ca445039d0 --- /dev/null +++ b/VERSIONS_HOTLINE/110024 @@ -0,0 +1 @@ + - ticket #110024 : OPAC : Ajouter l'information du code barre lecteur dans la page \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/View.php b/library/ZendAfi/Controller/Action/Helper/View.php index 2fd6d373edf..7dc10c86e1b 100644 --- a/library/ZendAfi/Controller/Action/Helper/View.php +++ b/library/ZendAfi/Controller/Action/Helper/View.php @@ -53,14 +53,19 @@ class ZendAfi_Controller_Action_Helper_View extends Zend_View { $action, Class_Profil::getCurrentProfil()->getId()); - $logged = Class_Users::getIdentity() ? 'true' : 'false'; + $logged = ($current_user = Class_Users::getIdentity()) ? 'true' : 'false'; $this->body_attribs = ['class' => $classes, 'data-logged' => $logged]; + $this->bodyParam = sprintf('class="%s" data-logged="%s"', $classes, $logged); + if ($current_user) { + $this->body_attribs['data-idabon'] = $current_user->getIdabon(); + $this->bodyParam .= sprintf(' data-idabon="%s"',$current_user->getIdabon()); + } } diff --git a/tests/application/modules/opac/controllers/IndexControllerTest.php b/tests/application/modules/opac/controllers/IndexControllerTest.php index 7177e4a0a45..18d519c767f 100644 --- a/tests/application/modules/opac/controllers/IndexControllerTest.php +++ b/tests/application/modules/opac/controllers/IndexControllerTest.php @@ -236,6 +236,7 @@ class IndexControllerWithLoggedUserTest extends AbstractControllerTestCase { ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users', ['id' => 1, 'login' => 'tom', + 'idabon' => '1234', 'date_maj' => '', 'password' => 'ok'])); $this->dispatch('index/index', true); @@ -248,6 +249,12 @@ class IndexControllerWithLoggedUserTest extends AbstractControllerTestCase { } + /** @test */ + public function bodyShouldHaveDataIdAbon1234() { + $this->assertXPath('//body[@data-idabon="1234"]'); + } + + /** @test */ public function bodyShouldHaveClassOpac() { $this->assertXPath('//body[contains(@class, "opac")]'); -- GitLab