diff --git a/VERSIONS_HOTLINE/59808 b/VERSIONS_HOTLINE/59808 new file mode 100644 index 0000000000000000000000000000000000000000..80e4bccdcad85ff845fb3f015d0970ba8f04228a --- /dev/null +++ b/VERSIONS_HOTLINE/59808 @@ -0,0 +1 @@ + - ticket #59808 : PNB: le player ne s'affiche pas si on est loggé sysadm \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index 01a2cec25dbae49d770cb6ac045906381d9b12bd..931857a1a4833e3a524f5e1da69497a46c20cc74 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1730,7 +1730,9 @@ class Class_Users extends Storm_Model_Abstract { public function getBibGLN() { - return $this->getBib()->getGln(); + return $this->hasBib() + ? $this->getBib()->getGln() + : ''; } diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index c027963fc2928b11954aeb65e1536c3ea98b1163..19983f644300af699e669c844f6709d078b20c90 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -21,28 +21,34 @@ class ZendAfi_View_Helper_TagDilicomWidget extends ZendAfi_View_Helper_BaseHelper { - protected $_album, + protected + $_album, $_user; public function tagDilicomWidget($album) { $this->_album = $album; + return $this->_renderPNBActions() . $this->renderBookPreview($album); + } - $links = $this->_tag('p', - $this->_('Vous n\'avez pas le droit d\'accéder à la consultation en ligne.')); + protected function _renderPNBActions() { $this->_user = Class_Users::getIdentity(); if (!$this->_user || ($this->_user->hasRightAccessDilicom() && $this->_user->getBibGLN())) - $links = $this->getConsultBookAnchor() - . $this->getLoanBookAnchor(); + return $this->getConsultBookAnchor() . $this->getLoanBookAnchor(); + + if (!$this->_user->hasRightAccessDilicom()) + return $this->_tag('p', + $this->_('Vous n\'avez pas le droit d\'accéder à la consultation en ligne.')); + - if ($this->_user - && $this->_user->hasRightAccessDilicom() - && !$this->_user->getBibGLN()) - $links = $this->_tag('p', - $this->_('%s n\'a pas accès à la consultation en ligne.', $this->_user->getBib()->getLibelle())); + if (!$this->_user->getBib()) + return $this->_tag('p', + $this->_('Vous devez être inscrit dans une bibliothèque pour accéder à la consultation en ligne')); - return $links . $this->renderBookPreview($album); + return $this->_tag('p', + $this->_('%s n\'a pas accès à la consultation en ligne.', + $this->_user->getBib()->getLibelle())); } diff --git a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php index 0f914fed16fa88f28f999ff30e1a071f96b53d48..e938c6191678e00b207402c273dd3dce08808c5f 100644 --- a/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php +++ b/tests/library/ZendAfi/View/Helper/RenderAlbumTest.php @@ -405,6 +405,15 @@ class ZendAfi_View_Helper_RenderAlbumDilicomPNBTest extends ZendAfi_View_Helper_ } + /** @test */ + public function userWithoutBibShouldReturnErrorMessage() { + $this->logged_user->setBib(null)->save(); + $this->_html = $this->_helper->renderAlbum($this->book); + $this->assertXPathContentContains($this->_html, + '//p', utf8_encode('Vous devez être inscrit dans une bibliothèque pour accéder à la consultation en ligne')); + + } + /** @test */ public function withHttpsPreviewSrcShouldBeHttps() { $_SERVER['HTTPS'] = 'on';