Bugzilla – Attachment 56236 Details for
Bug 16850
Move IsMemberBlocked to Koha::Patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16850: Remove C4::Members::IsMemberBlocked
Bug-16850-Remove-C4MembersIsMemberBlocked.patch (text/plain), 4.99 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-10-12 09:06:54 UTC
(
hide
)
Description:
Bug 16850: Remove C4::Members::IsMemberBlocked
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-10-12 09:06:54 UTC
Size:
4.99 KB
patch
obsolete
>From 674facb4fc04f99ad547c31c269fd398c1074878 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 4 Jul 2016 12:21:19 +0100 >Subject: [PATCH] Bug 16850: Remove C4::Members::IsMemberBlocked > >This subroutine is only called once and can be replaced with a call to >is_debarred and has_overdues. >Note that prior to this patch, IsMemberBlocked copy/paste code from >HasOverdues, which did not make sense. > >Test plan: >Debar a patron and make sure he is not able to checkout (the librarian >is asked to overwrite if OverduesBlockCirc is set to 'confirmation') >Remove the debarment and add overdues to this patron, same as >previously, the checkout should be blocked > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Circulation.pm | 31 +++++++++++++++---------------- > C4/Members.pm | 44 -------------------------------------------- > 2 files changed, 15 insertions(+), 60 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e2c2ec5..40928be 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -801,26 +801,25 @@ sub CanBookBeIssued { > $alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); > } > >- my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'}); >- if ($blocktype == -1) { >- ## patron has outstanding overdue loans >- if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ >- $issuingimpossible{USERBLOCKEDOVERDUE} = $count; >- } >- elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ >- $needsconfirmation{USERBLOCKEDOVERDUE} = $count; >- } >- } elsif($blocktype == 1) { >- # patron has accrued fine days or has a restriction. $count is a date >- if ($count eq '9999-12-31') { >- $issuingimpossible{USERBLOCKEDNOENDDATE} = $count; >+ my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); >+ if ( my $debarred_date = $patron->is_debarred ) { >+ # patron has accrued fine days or has a restriction. $count is a date >+ if ($debarred_date eq '9999-12-31') { >+ $issuingimpossible{USERBLOCKEDNOENDDATE} = $debarred_date; > } > else { >- $issuingimpossible{USERBLOCKEDWITHENDDATE} = $count; >+ $issuingimpossible{USERBLOCKEDWITHENDDATE} = $debarred_date; >+ } >+ } elsif ( my $num_overdues = $patron->has_overdues ) { >+ ## patron has outstanding overdue loans >+ if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ >+ $issuingimpossible{USERBLOCKEDOVERDUE} = $num_overdues; >+ } >+ elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ >+ $needsconfirmation{USERBLOCKEDOVERDUE} = $num_overdues; > } > } > >-# > # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS > # > my $switch_onsite_checkout = >@@ -848,7 +847,7 @@ sub CanBookBeIssued { > # > # CHECKPREVCHECKOUT: CHECK IF ITEM HAS EVER BEEN LENT TO PATRON > # >- my $patron = Koha::Patrons->find($borrower->{borrowernumber}); >+ $patron = Koha::Patrons->find($borrower->{borrowernumber}); > my $wants_check = $patron->wants_check_for_previous_checkout; > $needsconfirmation{PREVISSUE} = 1 > if ($wants_check and $patron->do_check_for_previous_checkout($item)); >diff --git a/C4/Members.pm b/C4/Members.pm >index 4b2d7ff..4f00453 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -75,7 +75,6 @@ BEGIN { > > &GetHideLostItemsPreference > >- &IsMemberBlocked > &GetMemberAccountRecords > &GetBorNotifyAcctRecord > >@@ -461,49 +460,6 @@ sub GetMember { > return; > } > >-=head2 IsMemberBlocked >- >- my ($block_status, $count) = IsMemberBlocked( $borrowernumber ); >- >-Returns whether a patron is restricted or has overdue items that may result >-in a block of circulation privileges. >- >-C<$block_status> can have the following values: >- >-1 if the patron is currently restricted, in which case >-C<$count> is the expiration date (9999-12-31 for indefinite) >- >--1 if the patron has overdue items, in which case C<$count> is the number of them >- >-0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0 >- >-Existing active restrictions are checked before current overdue items. >- >-=cut >- >-sub IsMemberBlocked { >- my $borrowernumber = shift; >- my $dbh = C4::Context->dbh; >- >- my $blockeddate = Koha::Patrons->find( $borrowernumber )->is_debarred; >- >- return ( 1, $blockeddate ) if $blockeddate; >- >- # if he have late issues >- my $sth = $dbh->prepare( >- "SELECT COUNT(*) as latedocs >- FROM issues >- WHERE borrowernumber = ? >- AND date_due < now()" >- ); >- $sth->execute($borrowernumber); >- my $latedocs = $sth->fetchrow_hashref->{'latedocs'}; >- >- return ( -1, $latedocs ) if $latedocs > 0; >- >- return ( 0, 0 ); >-} >- > =head2 GetMemberIssuesAndFines > > ($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber); >-- >2.10.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16850
:
53095
|
53096
|
53247
|
53512
|
53513
|
54005
|
54006
|
55686
|
55687
|
56235
| 56236 |
56743