From dcfdb463ad1397e8e25ee6f43fe9b38338f3f785 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 --- 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 4360375..a7536f0 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -176,13 +176,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 b1dcf57..64e95aa 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 85426ab..a725730 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 188e388..27c3c63 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -149,11 +149,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.1.4