From 679281e4ef4553c23612a399edfa3801b64e9433 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 26 Mar 2024 17:12:49 +0000 Subject: [PATCH] Bug 36453: effective_BlockExpiredPatronOpacActions_contains method effective_BlockExpiredPatronOpacActions is now effective_BlockExpiredPatronOpacActions_contains This method has been updated to now consider an action param. Returns true if the given action is to be blocked to expired patrons or not. Signed-off-by: Arthur Suzuki Signed-off-by: Martin Renvoize --- Koha/Patron/Category.pm | 56 +++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm index 2967abe039..a7358c2acc 100644 --- a/Koha/Patron/Category.pm +++ b/Koha/Patron/Category.pm @@ -36,18 +36,60 @@ Koha::Patron;;Category - Koha Patron;;Category Object class =cut -=head3 effective_BlockExpiredPatronOpacActions +=head3 effective_BlockExpiredPatronOpacActions_contains -my $BlockExpiredPatronOpacActions = $category->effective_BlockExpiredPatronOpacActions +my $actionBlocked = $category->effective_BlockExpiredPatronOpacActions_contains('hold'); -Return the effective BlockExpiredPatronOpacActions value. +Return if the provided action is blocked by BlockExpiredPatronOpacActions, accounting for the syspref. + +=over + +=item action + +Action, can be one of: ['hold', 'renew'] + +=back =cut -sub effective_BlockExpiredPatronOpacActions { - my( $self) = @_; - return C4::Context->preference('BlockExpiredPatronOpacActions') if $self->BlockExpiredPatronOpacActions == -1; - return $self->BlockExpiredPatronOpacActions +sub effective_BlockExpiredPatronOpacActions_contains { + my ( $self, $action ) = @_; + + my $blocked_actions = { + map { ( $_, 1 ); } split /\s*\,\s*/, + C4::Context->preference('BlockExpiredPatronOpacActions') + }; + + return $blocked_actions->{$action} if $self->BlockExpiredPatronOpacActions_contains('follow_syspref_BlockExpiredPatronOpacActions'); + return $self->BlockExpiredPatronOpacActions_contains($action) +} + +=head3 BlockExpiredPatronOpacActions_contains + +my $actionBlocked = $self->BlockExpiredPatronOpacActions_contains('hold'); + +Return if the provided action is blocked by this category's BlockExpiredPatronOpacActions value. + +=over + +=item action + +Action, can be one of: ['hold', 'renew'] + +=back + +=cut + +sub BlockExpiredPatronOpacActions_contains { + my ( $self, $action ) = @_; + + my $blocked_actions = { + map { ( $_, 1 ); } split /\s*\,\s*/, + $self->BlockExpiredPatronOpacActions + }; + + return unless $blocked_actions->{$action}; + return 1; } =head3 store -- 2.39.5