From 2f80d8c03b1f33845960a9e6a99d1c831724ee54 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki <arthur.suzuki@biblibre.com> Date: Tue, 18 Apr 2023 09:13:54 +0000 Subject: [PATCH] hotline#177091 : fix ILSSubscription::isValid remove minimal RoleLevel of SIGB_USER condition to allow portal subscriptor to have a valid subscrition --- VERSIONS_HOTLINE/177091 | 1 + library/Class/SearchCriteria.php | 5 +--- library/Class/User/ILSSubscription.php | 2 +- library/Class/User/SearchCriteria.php | 4 ++- .../Lekiosk/tests/LekioskTest.php | 28 +++++++++++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 VERSIONS_HOTLINE/177091 diff --git a/VERSIONS_HOTLINE/177091 b/VERSIONS_HOTLINE/177091 new file mode 100644 index 00000000000..427949180de --- /dev/null +++ b/VERSIONS_HOTLINE/177091 @@ -0,0 +1 @@ + - correctif #177091 : Administration Utilisateurs : Les abonnés portails peuvent désormais avoir un abonnement valide pour accéder aux ressources numériques. \ No newline at end of file diff --git a/library/Class/SearchCriteria.php b/library/Class/SearchCriteria.php index 52d0b398285..85e1a7fc519 100644 --- a/library/Class/SearchCriteria.php +++ b/library/Class/SearchCriteria.php @@ -200,10 +200,7 @@ abstract class Class_SearchCriteria { public function modelMatch($model) :bool { return (new Storm_Collection($this->_criteria)) - ->detect(function($each) use($model) - { - return $each->shouldFilter($this) && !$each->modelMatch($model); - }) + ->detect(fn($each) => $each->shouldFilter($this) && !$each->modelMatch($model)) ? false : true; } diff --git a/library/Class/User/ILSSubscription.php b/library/Class/User/ILSSubscription.php index f3f72a2068e..f23b4b10f2e 100644 --- a/library/Class/User/ILSSubscription.php +++ b/library/Class/User/ILSSubscription.php @@ -102,7 +102,7 @@ class Class_User_ILSSubscription { public function isValid() :bool { - if (!$this->_user->isAbonne()) + if ( ! $this->_user->isAbonne()) return false; return !$this->isExpired() && !$this->isBlocked(); diff --git a/library/Class/User/SearchCriteria.php b/library/Class/User/SearchCriteria.php index 095b6c3b193..7c0b01de92e 100644 --- a/library/Class/User/SearchCriteria.php +++ b/library/Class/User/SearchCriteria.php @@ -95,7 +95,9 @@ class Class_User_SearchCriteriaValidSubscription public function modelMatch($model) :bool { - return $model->isAbonnementValid(); + return ($date = $model->getDateFin()) + ? ($model->getCurrentDate() <= $date) + : false; } diff --git a/library/digital_resources/Lekiosk/tests/LekioskTest.php b/library/digital_resources/Lekiosk/tests/LekioskTest.php index 4177e5ad6e3..074e460698f 100644 --- a/library/digital_resources/Lekiosk/tests/LekioskTest.php +++ b/library/digital_resources/Lekiosk/tests/LekioskTest.php @@ -236,6 +236,34 @@ class LekioskModulesControllerTest extends AbstractControllerTestCase { $this->dispatch('/opac/modules/lekiosk'); $this->assertFlashMessengerContentContains('Votre abonnement ne permet pas'); } + + + /** @test */ + public function dynamicGroupWithRightsShouldAccessLekiosk() { + $group = $this->fixture(Class_UserGroup::class, + ['id' => 1, + 'filters' => json_encode(['search_role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE, + 'search_valid_subscription' => 1])]); + + $group->beDynamic()->assertSave(); + + $lekiosk_permission_id = Lekiosk_Config::getInstance()->getPermission()->getId(); + + $this->fixture(Class_UserGroup_Permission::class, + ['id' => 1, + 'id_group' => 1, + 'id_permission' => $lekiosk_permission_id, + 'id_model' => null, + 'model_class' => null + ]); + + Class_Users::getIdentity() + ->bePortalBorrowerForDays(30); + + $this->dispatch('/opac/modules/lekiosk'); + $this->assertContains('https://pros.lekiosk.com/login/accesshash', + $this->_response->getBody()); + } } -- GitLab