From 5a0a2ce584dec74808f471b0f92b2114c3d6029e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Nov 2016 18:14:49 +0100 Subject: [PATCH] Bug 17578: GetMemberDetails - Remove is_expired The is_expired value is used in 2 places, let's use Koha::Patron->is_expired instead. Test plan: Depending on the different value of BlockExpiredPatronOpacActions for the patron category, a patron must be blocked if he has expired. Confirm that behavior from opac-renew and opac-reserve scripts Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Members.pm | 7 ------- opac/opac-renew.pl | 3 +-- opac/opac-reserve.pl | 2 +- t/db_dependent/Members.t | 5 ----- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index c7fac6ff19..b64ccb8741 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -173,13 +173,6 @@ sub GetMemberDetails { my $borrower = $sth->fetchrow_hashref; return unless $borrower; - $borrower->{'is_expired'} = 0; - $borrower->{'is_expired'} = 1 if - defined($borrower->{dateexpiry}) && - $borrower->{'dateexpiry'} ne '0000-00-00' && - Date_to_Days( Today() ) > - Date_to_Days( split /-/, $borrower->{'dateexpiry'} ); - return ($borrower); } diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl index b1dcf572d6..64e95aa1ac 100755 --- a/opac/opac-renew.pl +++ b/opac/opac-renew.pl @@ -51,10 +51,9 @@ my $errorstring = q{}; my $renewed = q{}; my $patron = Koha::Patrons->find( $borrowernumber ); -my $member_details = GetMemberDetails($borrowernumber); if ( $patron->category->effective_BlockExpiredPatronOpacActions - && $member_details->{'is_expired'} ) + && $patron->is_expired ) { $errorstring = 'card_expired'; } diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 85426ab60c..a725730a1a 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -76,7 +76,7 @@ my $patron = Koha::Patrons->find( $borrowernumber ); # check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block if ( $patron->category->effective_BlockExpiredPatronOpacActions ) { - if ( $borr->{'is_expired'} ) { + if ( $patron->is_expired ) { # cannot reserve, their card has expired and the rules set mean this is not allowed $template->param( message => 1, expired_patron => 1 ); diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index d293cbce6f..8e5218ecd2 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -150,11 +150,6 @@ C4::Context->clear_syspref_cache(); $notice_email = GetNoticeEmailAddress($member->{'borrowernumber'}); is ($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when AutoEmailPrimaryAddress is emailpro"); -ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired"); -ModMember(borrowernumber => $member->{'borrowernumber'}, dateexpiry => '2001-01-1'); -$member = GetMemberDetails($member->{'borrowernumber'}); -ok($member->{is_expired}, "GetMemberDetails() indicates that patron is expired"); - # Check_Userid tests %data = ( cardnumber => "123456789", -- 2.39.5