diff --git a/VERSIONS_HOTLINE/72286 b/VERSIONS_HOTLINE/72286 new file mode 100644 index 0000000000000000000000000000000000000000..59d87e3abe901a98924a1bb1d8eef0adb19eea54 --- /dev/null +++ b/VERSIONS_HOTLINE/72286 @@ -0,0 +1 @@ + - ticket #72286 : Boite Kiosque : correction de la mise en cache en affichage aléatoire. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/75544 b/VERSIONS_HOTLINE/75544 new file mode 100644 index 0000000000000000000000000000000000000000..66fd744affdde77bfafebe76623d44ea043792fb --- /dev/null +++ b/VERSIONS_HOTLINE/75544 @@ -0,0 +1,2 @@ + - ticket #75544 : Boite article : amélioration du chargement du diaporama avec navigation. + \ No newline at end of file diff --git a/VERSIONS_HOTLINE/75730 b/VERSIONS_HOTLINE/75730 new file mode 100644 index 0000000000000000000000000000000000000000..d5e21016df5abc888d21ecebf3a4ff4da77e8595 --- /dev/null +++ b/VERSIONS_HOTLINE/75730 @@ -0,0 +1 @@ + - ticket #75730 : MyBibApp: correction de la récupération des prêts PNB. \ No newline at end of file diff --git a/application/modules/api/controllers/UserController.php b/application/modules/api/controllers/UserController.php index 7688562b97a07c4168fbdc4fc421386a10a68301..d6fa2551391c76eaec1f1b537df9c8bd4dc364b7 100644 --- a/application/modules/api/controllers/UserController.php +++ b/application/modules/api/controllers/UserController.php @@ -23,7 +23,8 @@ class Api_UserController extends ZendAfi_Controller_Action { public function preDispatch() { parent::preDispatch(); - $this->_authenticate(); + if (!Class_Users::hasIdentity()) + $this->_authenticate(); } diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index e8ecbe28ddba5e5832505101cb2fe90ad558b378..16a5c093ef0bcb5652543f5f4f45836e039577d9 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -293,8 +293,15 @@ class CatalogueLoader extends Storm_Model_Loader { if (!array_key_exists("req_liste", $requetes)) return []; + $nb_par_page = (array_key_exists('aleatoire', $preferences) + && array_key_exists('nb_analyse', $preferences) + && $preferences['aleatoire'] + && $preferences['nb_analyse']) + ? $preferences['nb_analyse'] + : $preferences['nb_notices']; + return Class_Notice::findAllByRequeteRecherche($requetes['req_ids'], - $preferences['nb_notices'], + $nb_par_page, 1); } @@ -454,9 +461,14 @@ class CatalogueLoader extends Storm_Model_Loader { public function getNoticesFromCacheByPreferences($preferences) { - return (new Storm_Cache()) - ->memoize([$preferences, __CLASS__, __FUNCTION__], - function() use ($preferences) { return Class_Catalogue::getLoader()->fetchAllNoticesByPreferences($preferences);}); + $callback = function() use ($preferences) { + return Class_Catalogue::getLoader()->fetchAllNoticesByPreferences($preferences); + }; + + return (array_key_exists('aleatoire', $preferences) + && $preferences['aleatoire']) + ? $callback() + : (new Storm_Cache())->memoize([$preferences, __CLASS__, __FUNCTION__], $callback); } diff --git a/library/Class/Loan/Pnb.php b/library/Class/Loan/Pnb.php index 18f62bbbd6b3c7609073f03ae5000d12e7c3410c..ceb8f5a60df45d1a88c6e7282d1b75a1328219da 100644 --- a/library/Class/Loan/Pnb.php +++ b/library/Class/Loan/Pnb.php @@ -104,6 +104,13 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { } + public function getNoticeOPAC() { + return ($album = $this->getAlbum()) + ? $album->getNotice() + : null; + } + + public function setAlbum($album) { return $this->setRecordOriginId($album->getIdOrigine()); } @@ -144,6 +151,12 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { } + public function getDateRetourISO8601() { + return substr($this->getDateRetour(), 0, 10); + } + + + public function isRenewable() { return false; } diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php index d8deea37c330fecf4be9457aa9cdba8554338ea0..8a0047d5dda9f59a0518015b775abb29dd7f492c 100644 --- a/library/ZendAfi/View/Helper/Accueil/Base.php +++ b/library/ZendAfi/View/Helper/Accueil/Base.php @@ -408,7 +408,9 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac Class_ScriptLoader::getInstance() ->addScript(URL_JAVA . 'slider_navigation/slider_navigation.js') - ->addJQueryReady('$("#boite_'.$this->getIdModule().'").slider_navigation('. json_encode($options) .');'); + ->addInlineStyle(sprintf('#boite_%s article, .preview_button img {height: 0; width: 0;}', + $this->getIdModule())) + ->addJQueryReady('$("#boite_' . $this->getIdModule() . '").slider_navigation('. json_encode($options) .');'); } diff --git a/library/ZendAfi/View/Helper/Api/Holds.php b/library/ZendAfi/View/Helper/Api/Holds.php index ddafc3d948cd3f7122b1fbee0c5d5b1b9f8a2b43..850eba1c0b87bee6df4745c1f0bf1c614e65786c 100644 --- a/library/ZendAfi/View/Helper/Api/Holds.php +++ b/library/ZendAfi/View/Helper/Api/Holds.php @@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Holds extends Zend_View_Helper_Abstract { public function holdToArray($hold) { $datas = [ 'id' => $hold->getId(), - 'title' => $hold->getTitre(), + 'title' => strip_tags($hold->getTitre()), 'author' => $hold->getAuteur(), 'status' => $hold->getEtat(), 'held_by' => $hold->getUserFullName(), diff --git a/library/ZendAfi/View/Helper/Api/Loans.php b/library/ZendAfi/View/Helper/Api/Loans.php index d90cedf859b652827378b89951947af53c278167..566a189d7e96ec5a1e4c1f1e9970a735f52d696e 100644 --- a/library/ZendAfi/View/Helper/Api/Loans.php +++ b/library/ZendAfi/View/Helper/Api/Loans.php @@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Loans extends Zend_View_Helper_Abstract { public function loanToArray($loan) { $datas = [ 'id' => $loan->getId(), - 'title' => $loan->getTitre(), + 'title' => strip_tags($loan->getTitre()), 'author' => $loan->getAuteur(), 'date_due' => $loan->getDateRetourISO8601(), 'loaned_by' => $loan->getUserFullName(), diff --git a/public/opac/java/slider_navigation/slider.css b/public/opac/java/slider_navigation/slider.css index e4b79ac516c912a4bf8c2d62d34c64905fb569dd..902d84207e3447328ad98ec94e053eb05a654025 100644 --- a/public/opac/java/slider_navigation/slider.css +++ b/public/opac/java/slider_navigation/slider.css @@ -36,7 +36,6 @@ background: url('../../images/buttons/2rightarrow.png') no-repeat 0px 0px; } - .preview_button { border: 1px solid black; cursor: pointer; diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php index f243d5a6ac774232e8bc006be4c252ed5a526440..d151e884fa0f395794194cb04d705114532122ce 100644 --- a/tests/library/Class/CatalogueTest.php +++ b/tests/library/Class/CatalogueTest.php @@ -537,7 +537,7 @@ class CatalogueTestOAISpec extends ModelTestCase { -class CatalogueTestGetNoticesByPreferences extends ModelTestCase { +class CatalogueGetNoticesByPreferencesNotRandomTest extends ModelTestCase { public function setUp() { parent::setUp(); @@ -569,31 +569,20 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase { 'unimarc' => "01328ngm0 2200265 450 0010007000001000041000071010013000481020007000611150025000682000071000932100022001642150053001863000035002393000045002743300454003193450027007735100018008006060027008186060039008457000042008847020043009267020033009697020032010028010028010342247456 a20021213i20041975u y0frey0103 ba0 abamjfre aFR ac086baz|zba zz c1 aLa jeune fillebDVDdDen MusofSouleymane Cisse, réal., scénario cPathédcop. 2004 a1 DVD vidéo monoface zone 2 (1 h 26 min)ccoul. aDate de sortie du film : 1975. aFilm en bambara sous-titré en français aSékou est renvoyé de l'usine parce qu'il a osé demander une augmentation. Chômeur, il sort avec Ténin, une jeune fille muette ; il ignore qu'elle est la fille de son ancien patron. Ténin, qui sera violée par Sékou lors d'une sortie entre jeunes, se retrouve enceinte et subit la colère de ses parents. Elle se trouve alors confrontée brutalement à la morale de sa famille et à la lâcheté de Sékou, qui refuse de reconnaiîre l'enfant. b3388334509824d14.00 ?1 aDen Musozbam| 31070135aCinémayMali| 32243367aCinéma30076549yAfrique 131070144aCissébSouleymane43704690 132247457aCoulibalibDounamba Dani4590 132247458aDiabatebFanta4590 132247459aDiarrabOumou4590 0aFRbBNc20011120gAFNOR"]); - $this->old_sql = Zend_Registry::get('sql'); - $this->mock_sql = Storm_Test_ObjectWrapper::mock(); - Zend_Registry::set('sql', $this->mock_sql); + Zend_Registry::set('sql', + $this->mock() + ->whenCalled('fetchAllByColumn') + ->with("select notices.id_notice from notices Where notices.type_doc='1' order by alpha_titre LIMIT 0,40") + ->answers([23]) - $this->mock_sql - ->whenCalled('fetchAllByColumn') - ->with("select notices.id_notice from notices Where notices.type_doc='1' order by alpha_titre LIMIT 0,25") - ->answers([23]) + ->beStrict()); - ->whenCalled('query') - ->with([0 => 'update notices set facettes = clean_spaces(replace(facettes,"HCCCC0030","")) where notices.type_doc not in (\'8\',\'9\',\'10\') and match(facettes) against("+HCCCC0030" in boolean mode)']) - ->answers(true) - ->beStrict(); + $prefs = ['id_catalogue' => 666, + 'aleatoire' => '0', + 'nb_analyse' => 25, + 'nb_notices' => 40]; - - $this->_notices = Class_Catalogue::getNoticesByPreferences(['id_catalogue' => 666, - 'aleatoire' => '1', - 'nb_analyse' => 25, - 'nb_notices' => 40]); - } - - - public function tearDown() { - Zend_Registry::set('sql', $this->old_sql); - parent::tearDown(); + $this->_notices = Class_Catalogue::getNoticesByPreferences($prefs); } @@ -617,7 +606,7 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase { /** @test */ public function saveInCacheShouldHaveBeenCalledWithSerializedNotices() { - $cached_record = unserialize($this->_cache->load('d7c046ce443b5097ce0cd3ec7023ca72'))[0]; + $cached_record = unserialize($this->_cache->load('535ea089525b59be7f5c7b0eebcd52b0'))[0]; $this->assertEquals('La jeune fille', $cached_record->getTitrePrincipal()); } @@ -625,12 +614,12 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase { /** @test */ public function getNoticesWithCachePresentShouldNotCallThem() { $preferences = ['id_catalogue' => 666, - 'aleatoire' => 1, + 'aleatoire' => '0', 'nb_analyse' => 25, 'nb_notices' => 40]; /* this test will fail when Class_Catalogue::_default_attribute_values change */ - $this->_cache->save(serialize(['test']), '6e2593bad86780aeba3c5b5b6cd4d5b5'); + $this->_cache->save(serialize(['test']), '535ea089525b59be7f5c7b0eebcd52b0'); $notices = Class_Catalogue::getNoticesByPreferences($preferences); @@ -651,7 +640,7 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase { Class_Users::getLoader()->newInstanceWithId($account->ID_USER)->setRoleLevel($account->ROLE_LEVEL); $notices = Class_Catalogue::getNoticesByPreferences(['id_catalogue' => 666, - 'aleatoire' => 1, + 'aleatoire' => '0', 'nb_analyse' => 25, 'nb_notices' => 40]); $this->assertEquals(23, $notices[0]->getId()); @@ -1186,4 +1175,33 @@ class CatalogueWithNoveltyTest extends ModelTestCase { $this->assertSame('select * from notices Where MATCH(facettes) AGAINST(\' +(B10 B11) +(YROUB YISTR) +(HNNNN0001 HNNNN0002 HNANA0001 HNANA0002)\' IN BOOLEAN MODE) and date_creation >= \'2016-05-11\' order by alpha_titre LIMIT 5000', $this->_domain_request['req_liste']); } +} + + + +/** @see #72286 */ +class CatalogueFetchAllNoticeByPrefWithRandomTest extends ModelTestCase { + protected $_storm_default_to_volatile = true; + + /** @test */ + public function withRandomShouldUseNbAnalyseAsLimit() { + $this->fixture('Class_Catalogue', + ['id' => 42, + 'libelle' => 'Super domain', + 'auteur' => '344']); + + $this->onLoaderOfModel('Class_Notice') + ->whenCalled('findAllByRequeteRecherche') + ->with("select notices.id_notice from notices Where MATCH(facettes) AGAINST(' +( A344)' IN BOOLEAN MODE) order by alpha_titre LIMIT 0,1000", + 1000, + 1) + ->beStrict(); + + $preferences = ['id_catalogue' => 42, + 'nb_notices' => 10, + 'nb_analyse' => 1000, + 'aleatoire' => 1]; + + Class_Catalogue::fetchAllNoticesByPreferences($preferences); + } } \ No newline at end of file diff --git a/tests/scenarios/MobileApplication/UserAccountTest.php b/tests/scenarios/MobileApplication/UserAccountTest.php index 935ef9517a35a14cc70864501c4d5ad257b0f684..2dfea117b92be210d40178ac2b5b0802f6afd9ab 100644 --- a/tests/scenarios/MobileApplication/UserAccountTest.php +++ b/tests/scenarios/MobileApplication/UserAccountTest.php @@ -55,7 +55,7 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo ->setNoticeOPAC($this->fixture('Class_Notice', ['id' => 34, 'url_vignette' => 'http://img.com/potter.jpg', - 'titre_principal' => 'Potter', + 'titre_principal' => 'Harry Potter<br /> La chambre des secrets', 'auteur_principal' => 'J.K.R' ])); $alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456)); @@ -82,12 +82,32 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo ->reservationsAddAll([$afrodeezia])]) ->assertSave(); + + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($this->mock() + ->whenCalled('open_url') + ->answers('')); + $this->fixture('Class_Loan_Pnb', + ['id' => 5, + 'subscriber_id' => $puppy->getIdabon(), + 'ongoing' => true, + 'expected_return_date' => '2022-05-02T18:14:14+02:00', + 'loan_date' => '2016-06-13T15:10:02+02:00', + 'album' => $this->fixture('Class_Album', + ['id' => 4, + 'notice_id' => 5, + 'id_origine' => 'Dilicom-88817216', + 'titre' => 'Pinocchio'])->addAuthor('Collodi') + ]); + + + ZendAfi_Auth::getInstance()->clearIdentity(); } public function tearDown() { unset($_SERVER['HTTPS']); + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null); parent::tearDown(); } } @@ -114,7 +134,7 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_ /** @test */ public function responseShouldContainsPotterLoan() { $this->assertEquals(['id' => '345_12', - 'title' => 'Potter', + 'title' => 'Harry Potter La chambre des secrets', 'author' => 'J.K.R', 'date_due' => '1974-01-01', 'loaned_by' => 'puppy', @@ -126,6 +146,19 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_ } + /** @test */ + public function responseShouldContainsPinocchioPnbLoan() { + $this->assertEquals(['id' => '345_5', + 'title' => 'Pinocchio', + 'author' => 'Collodi', + 'date_due' => '2022-05-02', + 'loaned_by' => 'puppy', + 'library' => '' + ], + $this->_json['loans'][2]); + } + + /** @test */ public function responseHeaderContentTypeShouldBeApplicationJson() { $this->assertArraySubset(['name' => 'Content-Type', @@ -280,7 +313,25 @@ class Scenario_MobileApplication_UserAccountLoansWithoutTokenTest extends Scenar "Content-Type" => "application/json"]); $loans = json_decode($this->_response->getBody(), true); - $this->assertArraySubset(['title' => 'Potter', + $this->assertArraySubset(['title' => 'Harry Potter La chambre des secrets', + 'author' => 'J.K.R', + 'date_due' => '1974-01-01', + 'loaned_by' => 'puppy', + 'library' => 'Annecy' + ], + $loans['loans'][0]); + } + + + /** @test */ + public function withSessionOpenedShouldAnswerLoans() { + ZendAfi_Auth::getInstance()->logUser(Class_Users::find(345)); + $this->dispatch('/api/user/loans', + true, + ["Content-Type" => "application/json"]); + + $loans = json_decode($this->_response->getBody(), true); + $this->assertArraySubset(['title' => 'Harry Potter La chambre des secrets', 'author' => 'J.K.R', 'date_due' => '1974-01-01', 'loaned_by' => 'puppy',