Skip to content
Snippets Groups Projects
Commit 9e682443 authored by efalcy's avatar efalcy
Browse files

dev #24867 : display pnb button if user is not logged and add authentication popup to login

parent 8fae930e
Branches
Tags 6.31
4 merge requests!1132Hotline#29412 images des articles dans le resultat de recherche,!1120Master,!1114Dev #24867 pnb remove loan button,!1109Dev #24867 pnb remove loan button
...@@ -255,9 +255,35 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { ...@@ -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(); $client_ip = (new Class_RemoteClient($this->_request))->getIpAddress();
$response = (new Class_WebService_BibNumerique_Dilicom_Hub())->consultBook($album, $response = (new Class_WebService_BibNumerique_Dilicom_Hub())->consultBook($album,
...@@ -274,6 +300,11 @@ class BibNumeriqueController extends ZendAfi_Controller_Action { ...@@ -274,6 +300,11 @@ class BibNumeriqueController extends ZendAfi_Controller_Action {
public function loanBookAction() { public function loanBookAction() {
if ($this->redirectToLogin())
return ;
if (!$this->_user->hasRightAccessDilicom())
return;
if(!$album = Class_Album::find($this->_getParam('id'))) if(!$album = Class_Album::find($this->_getParam('id')))
return $this->_redirectToReferer(); return $this->_redirectToReferer();
......
...@@ -36,9 +36,9 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement ...@@ -36,9 +36,9 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
'width' => '100%', 'width' => '100%',
'height' => '600px']); '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 $links = $infos
. $this->getConsultBookAnchor() . $this->getConsultBookAnchor()
. $this->getLoanBookAnchor(); . $this->getLoanBookAnchor();
...@@ -49,15 +49,17 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement ...@@ -49,15 +49,17 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
protected function getConsultBookAnchor() { protected function getConsultBookAnchor() {
return $this->getDilicomAnchor(['controller' => 'bib-numerique', return $this->getDilicomAnchor(['controller' => 'bib-numerique',
'action' => 'consult-book', 'action' => 'consult-book-ajax',
'id' => $this->_album->getId()], '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() { protected function getLoanBookAnchor() {
return $this->getDilicomAnchor(['controller' => 'bib-numerique', return $this->getDilicomAnchor(['controller' => 'bib-numerique',
'action' => 'loan-book', 'action' => 'loan-book-ajax',
'id' => $this->_album->getId(),], 'id' => $this->_album->getId(),],
$this->view->_('Emprunter le livre au format EPUB')); $this->view->_('Emprunter le livre au format EPUB'));
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment