diff --git a/VERSIONS b/VERSIONS index 6bb9d3b4682d8e3dee862018b8821b3d04233fe6..11d07af76c0b847d46c648f2c333e48733c31c41 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,10 @@ +05/06/2020 - v8.0.62 + + - ticket #111520 : Drive : Correction de l'affichage des réservations dans l'interface administrateur lorsque l'option LOGIN_THROUGH_SIGB_ONLY est activée + + - ticket #111477 : Reservations : Affiche un message d'erreur quand on est en mode site de retrait bibliothèque utilisateur et que le SIGB est incompatible + + 04/06/2020 - v8.0.61 - ticket #108997 : Vue notice XSL : correction d'un mauvais encodage HTML diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 5e38c6469271c7aed1efad7af5a36cd150b33ea5..40a1e05d12b8e4b5604573642258d51b1a558970 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -697,8 +697,10 @@ class RechercheController extends ZendAfi_Controller_Action { $id_exemplaire = $this->_getParam('copy_id'); $code_annexe = $this->_getParam('code_annexe'); - if (Class_CosmoVar::isSiteRetraitResaPatronLibrary()) - $code_annexe = $user->getUserIdSite(); + if (Class_CosmoVar::isSiteRetraitResaPatronLibrary() && (!$code_annexe = $user->getUserIdSite())) { + return $this->renderPopupResult($this->_('Réservation'), + $this->_('Erreur de configuration : la valeur du paramètre site_retrait_resa est incompatible avec le SIGB utilisé')); + } try { $ret = Class_CommSigb::getInstance()->reserverExemplaire($id_bib, $id_exemplaire, $code_annexe); diff --git a/library/Class/WebService/SIGB/Koha/LoansPageReader.php b/library/Class/WebService/SIGB/Koha/LoansPageReader.php index 1c041690f00e613b25061f5c725834f34b066749..909d32bd732a78161505ebdb6c8e100c13d792ff 100644 --- a/library/Class/WebService/SIGB/Koha/LoansPageReader.php +++ b/library/Class/WebService/SIGB/Koha/LoansPageReader.php @@ -32,12 +32,12 @@ class Class_WebService_SIGB_Koha_LoansPageReader } - public function endLoans() { + public function endLoans($data) { //intentionnaly do nothing } - public function endLoan() { + public function endLoan($data) { $this->_loans [] = $this->_currentLoan; } diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index 06fc7bbe3d046b70a055f2fc037545dd79eb0293..168ea86d1c823f481c15f79a5894bd53629c5308 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -207,12 +207,7 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR if(!$user) return Class_WebService_SIGB_Emprunteur::nullInstance(); - $patron_id = Class_Users::isLogged($user) - ? $user->getIdSigb() - : ''; - - if(!$patron_id) - $patron_id = $this->_authenticateWebservice($user); + $patron_id = $this->_patronIdFromUser($user); if (!$patron_id) return Class_WebService_SIGB_Emprunteur::nullInstance(); @@ -222,6 +217,21 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } + protected function _patronIdFromUser($user) { + if (Class_Users::isCurrentUserCanAccesBackend() && $user->getIdSigb()) + return $user->getIdSigb(); + + $patron_id = Class_Users::isLogged($user) + ? $user->getIdSigb() + : ''; + + if (!$patron_id) + return $this->_authenticateWebservice($user); + + return $patron_id; + } + + public function getUserAnnexe($user) { return null; } diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index 6393634b405351136433b4708b876ecfc08a1946..0f5859a744e055b9ea376fe8ff5678782656c238 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -128,6 +128,9 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac protected function _patronIdFromUser($user) { + if (Class_Users::isCurrentUserCanAccesBackend() && $user->getIdSigb()) + return $user->getIdSigb(); + $patron_id = Class_Users::isLogged($user) ? $user->getIdSigb() : ''; diff --git a/library/startup.php b/library/startup.php index 3f369511975df3ee48ba3545ec49a047addb0962..2449a9f00257e6e6a66f7fceef910526dae3f33b 100644 --- a/library/startup.php +++ b/library/startup.php @@ -81,7 +81,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','8.0'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.61'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.62'); defineConstant('BOKEH_REMOTE_FILES', 'https://git.afi-sa.net/afi/opacce/'); diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php index 93766dea980766d37ce7f37d1ce7a9bc021beee0..915dff234efbc9b053a420996ba5e0867fb3e21e 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php @@ -434,6 +434,8 @@ class RechercheControllerReservationWithWebServiceKohaTest ZendAfi_Auth::getInstance()->logUser($this->jajm); $this->koha = Storm_Test_ObjectWrapper::mock(); $this->koha + ->whenCalled('getUserAnnexe') + ->answers(null) ->whenCalled('getServerRoot') ->answers($webservice); @@ -588,6 +590,21 @@ class RechercheControllerReservationWithWebServiceKohaTest public function withoutIdAbonpopupResultContentShouldContainsVousDevezVousConnecterSousVotreNumeroDeCarte() { $this->dispatchAndCheckContentEquals("Vous devez vous connecter sous votre numéro de carte pour effectuer une réservation."); } + + + /** @test */ + public function withSiteRetraitResaPatronLibraryPopupResultContentShouldConfigurationError() { + $this->fixture('Class_CosmoVar', ['id' => 'site_retrait_resa', + 'valeur' => Class_CosmoVar::PICKUP_LOCATION_PATRON]); + $item = $this->fixture('Class_Exemplaire', + ['id' => 456, + 'code_barres' => 123, + 'id_int_bib' => 1]); + + $response = $this->_prepareEmprunteurHolding($item, 'Valensole'); + $this->_dispatchWithEmprunteurAndAssertContentEquals($response, + "Erreur de configuration : la valeur du paramètre site_retrait_resa est incompatible avec le SIGB utilisé"); + } } diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index e6c78064481ef49c012d9c3f564d47ab8f804652..02d9f95a5f9c30df49435326167ddb4bf17eb382 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -32,6 +32,13 @@ class KohaGetServiceTest extends ModelTestCase { } + public function tearDown() { + Class_WebService_SIGB_Koha::reset(); + parent::tearDown(); + } + + + /** @test */ public function getServiceShouldCreateAnInstanceOfKohaService() { $this->assertInstanceOf('Class_WebService_SIGB_Koha_Service', @@ -102,6 +109,12 @@ abstract class KohaTestCase extends ModelTestCase { $this->service = Class_WebService_SIGB_Koha::getService(['url_serveur' => 'http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl']); $this->service->setWebClient($this->mock_web_client); } + + + public function tearDown() { + Class_WebService_SIGB_Koha::reset(); + parent::tearDown(); + } } @@ -722,17 +735,11 @@ class KohaGetEmprunteurLaureAfondTest extends KohaTestCase { -class KohaGetEmprunteurLisianneWithIdSIGBTest extends KohaTestCase { +abstract class KohaGetEmprunteurLisianneWithIdSIGBTestCase extends KohaTestCase { public function setUp() { parent::setUp(); $this->mock_web_client - ->whenCalled('postData') - ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl', - [ 'service' => 'AuthenticatePatron', - 'username' => 'lisianne', - 'password' => 'zork']) - ->answers(KohaFixtures::xmlLookupPatronLisianne()) ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=16186&show_contact=1&show_loans=0&show_holds=1') ->answers(file_get_contents(__DIR__ . '/holds-koha.xml')) @@ -744,15 +751,65 @@ class KohaGetEmprunteurLisianneWithIdSIGBTest extends KohaTestCase { $this->fixture('Class_CodifAnnexe', ['id' => 33, 'libelle' => 'Testing branch', 'id_origine' => 'BIB']); + + $this->lisianne_user = $this->fixture('Class_Users', + ['id' => 43, + 'login' => 'lisianne', + 'password' => 'zork', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'idabon' => 'lisianne', + 'id_site' => 3, + 'id_sigb' => 'lisianne']); + + } +} + + + + +class KohaGetEmprunteurLisianneWithUserAdminTest extends KohaGetEmprunteurLisianneWithIdSIGBTestCase { + public function setUp() { + parent::setUp(); + $this->lisianne_user + ->setPassword('') + ->setIdSigb(16186) + ->save(); + + Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY',1); + $admin = $this->fixture('Class_Users', + ['id' => 38, + 'login' => 'admin', + 'password' => '1234', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL]); + ZendAfi_Auth::getInstance()->logUser($admin); + $this->lisianne = $this->service - ->getEmprunteur($this->fixture('Class_Users', - ['id' => 43, - 'login' => 'lisianne', - 'password' => 'zork', - 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, - 'idabon' => 'lisianne', - 'id_site' => 3, - 'id_sigb' => 'lisianne'])); + ->getEmprunteur($this->lisianne_user); + } + + /** @test */ + public function nbReservationsShouldReturnFive() { + $this->assertEquals(5, $this->lisianne->getNbReservations()); + } +} + + + + +class KohaGetEmprunteurLisianneWithIdSIGBTest extends KohaGetEmprunteurLisianneWithIdSIGBTestCase { + public function setUp() { + parent::setUp(); + + $this->mock_web_client + ->whenCalled('postData') + ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl', + [ 'service' => 'AuthenticatePatron', + 'username' => 'lisianne', + 'password' => 'zork']) + ->answers(KohaFixtures::xmlLookupPatronLisianne()); + + $this->lisianne = $this->service + ->getEmprunteur($this->lisianne_user); } diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index 678e6789eed405d08e742f325dda1e1113e69bd7..7c2cec3de7f139d56b947dcc8303af8bf7d17032 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -451,7 +451,9 @@ class NanookGetUserAnnexeTest extends NanookTestCase { } -class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase { + + +abstract class NanookGetEmprunteurChristelDelpeyrouxTestCase extends NanookTestCase { /** @var Class_WebService_SIGB_Emprunteur */ protected $_emprunteur; @@ -460,9 +462,6 @@ class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase { parent::setUp(); $this->_mock_web_client - ->whenCalled('open_url') - ->with('http://localhost:8080/afi_Nanook/ilsdi/service/AuthenticatePatron/username/8765/password/2002') - ->answers(NanookFixtures::xmlAuthenticatePatronChristelDelpeyroux()) ->whenCalled('open_url') ->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/1') @@ -472,13 +471,52 @@ class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase { 'login' => 8765, 'password' => 2002, 'id_site' => 3]); - $this->_emprunteur = $this->_service->getEmprunteur($this->_chrystel); - $this->_emprunteur->updateUser($this->_chrystel); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire') ->whenCalled('findFirstBy') ->answers(null); } +} + + + + +class NanookGetEmprunteurChristelDelpeyrouxAsAdminTest extends NanookGetEmprunteurChristelDelpeyrouxTestCase { + public function setUp() { + parent::setUp(); + $this->_chrystel->setPassword(''); + Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY',1); + $admin = $this->fixture('Class_Users', + [ + 'id'=> 38, + 'login'=> 'admin', + 'password' => '1234', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL + ]); + ZendAfi_Auth::getInstance()->logUser($admin); + $this->_emprunteur = $this->_service->getEmprunteur($this->_chrystel); + } + + /** @test */ + public function nbReservationsShouldBeFour() { + $this->assertEquals(4, $this->_emprunteur->getNbReservations()); + } +} + + + + +class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookGetEmprunteurChristelDelpeyrouxTestCase { + public function setUp() { + parent::setUp(); + $this->_mock_web_client + ->whenCalled('open_url') + ->with('http://localhost:8080/afi_Nanook/ilsdi/service/AuthenticatePatron/username/8765/password/2002') + ->answers(NanookFixtures::xmlAuthenticatePatronChristelDelpeyroux()); + + $this->_emprunteur = $this->_service->getEmprunteur($this->_chrystel); + $this->_emprunteur->updateUser($this->_chrystel); + } /** @test */