diff --git a/application/modules/opac/controllers/BibNumeriqueController.php b/application/modules/opac/controllers/BibNumeriqueController.php index 3b90ccbfaaee198464684bb08fc886a1a53e0a73..5f2c9d3137c6bbbf607b2f91f251fd70655b162a 100644 --- a/application/modules/opac/controllers/BibNumeriqueController.php +++ b/application/modules/opac/controllers/BibNumeriqueController.php @@ -255,9 +255,35 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { } + public function consultBookAjaxAction() { + if ($this->redirectToLogin()) + return ; + $this->_redirect($this->view->url(['action' => 'consult-book'])); + } + + public function redirectToLogin() { + if (!$this->_user = Class_Users::getLoader()->getIdentity()) { + $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]); + return true; + } + return false; + } + + + public function loanBookAjaxAction() { + if ($this->redirectToLogin()) + return ; + $this->_redirect($this->view->url(['action' => 'loan-book'])); + } - public function consultBookAction() { - $album = Class_Album::find($this->_getParam('id')); + + public function consultBookAction() { + if ($this->redirectToLogin()) + return ; + if (!$this->_user->hasRightAccessDilicom()) + return; + + $album = Class_Album::find($this->_getParam('id')); $client_ip = (new Class_RemoteClient($this->_request))->getIpAddress(); $response = (new Class_WebService_BibNumerique_Dilicom_Hub())->consultBook($album, @@ -274,6 +300,11 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { public function loanBookAction() { + if ($this->redirectToLogin()) + return ; + if (!$this->_user->hasRightAccessDilicom()) + return; + if(!$album = Class_Album::find($this->_getParam('id'))) return $this->_redirectToReferer(); diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index fa5a569189dab930db9531171f3c4ec74fc7709f..489e261ed9ba5e150f1535ededf122d82e88d5ce 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -36,9 +36,9 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement 'width' => '100%', 'height' => '600px']); - $links = $this->view->tag('p', $this->view->_('Vous devez vous connecter pour accéder à la consultation en ligne.')); + $links = $this->view->tag('p', $this->view->_('Vous n\'avez pas le droit d\'accéder à la consultation en ligne.')); - if(($this->_user = Class_Users::getIdentity()) && ($this->_user->hasRightAccessDilicom())) + if(!Class_Users::getIdentity() || ($this->_user = Class_Users::getIdentity()) && ($this->_user->hasRightAccessDilicom())) $links = $infos . $this->getConsultBookAnchor() . $this->getLoanBookAnchor(); @@ -49,15 +49,17 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement protected function getConsultBookAnchor() { return $this->getDilicomAnchor(['controller' => 'bib-numerique', - 'action' => 'consult-book', + 'action' => 'consult-book-ajax', 'id' => $this->_album->getId()], - $this->view->_('Consulter le livre en ligne'), ['target' => '_blank']); + $this->view->_('Consulter le livre en ligne'), [ + 'data-popup' => true + ]); } protected function getLoanBookAnchor() { return $this->getDilicomAnchor(['controller' => 'bib-numerique', - 'action' => 'loan-book', + 'action' => 'loan-book-ajax', 'id' => $this->_album->getId(),], $this->view->_('Emprunter le livre au format EPUB')); }