Bugzilla – Attachment 67887 Details for
Bug 15494
Block renewals by arbitrary item values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15494 - Add _items_denied_renewal sub to C4:Circulation::CanBookBeRenewed
Bug-15494---Add-itemsdeniedrenewal-sub-to-C4Circul.patch (text/plain), 2.19 KB, created by
Nick Clemens (kidclamp)
on 2017-10-10 16:35:33 UTC
(
hide
)
Description:
Bug 15494 - Add _items_denied_renewal sub to C4:Circulation::CanBookBeRenewed
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-10-10 16:35:33 UTC
Size:
2.19 KB
patch
obsolete
>From a2986a1c9affad26c0b67a67add98e10c1d63cfb Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 24 May 2017 08:52:27 -0400 >Subject: [PATCH] Bug 15494 - Add _items_denied_renewal sub to > C4:Circulation::CanBookBeRenewed > >--- > C4/Circulation.pm | 38 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 37 insertions(+), 1 deletion(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index b915b34..cf09b37 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -55,7 +55,8 @@ use Koha::Holds; > use Koha::RefundLostItemFeeRule; > use Koha::RefundLostItemFeeRules; > use Carp; >-use List::MoreUtils qw( uniq ); >+use List::MoreUtils qw( uniq any ); >+use YAML qw/Load/; > use Scalar::Util qw( looks_like_number ); > use Date::Calc qw( > Today >@@ -2607,6 +2608,8 @@ sub CanBookBeRenewed { > my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); > return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; > >+ return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); >+ > $borrowernumber ||= $issue->borrowernumber; > my $patron = Koha::Patrons->find( $borrowernumber ) > or return; >@@ -4062,6 +4065,39 @@ sub _CalculateAndUpdateFine { > } > } > >+sub _item_denied_renewal { >+ my ($params) = @_; >+ >+ my $item = $params->{item}; >+ unless ($item) { carp "No item passed in!" && return } >+ >+ my $yaml = C4::Context->preference('ItemsDeniedRenewal'); >+ return () if (! $yaml =~ /\S/ ); >+ $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt >+ my $denyingrules; >+ eval { >+ $denyingrules = YAML::Load($yaml); >+ }; >+ if ($@) { >+ warn "Unable to parse ItemsDeniedRenewal syspref : $@"; >+ return (); >+ } >+ foreach my $field (keys %$denyingrules) { >+ my $val; >+ if (exists $item->{$field}) { >+ $val = $item->{$field}; >+ } >+ $val = '' unless defined $val; >+ # If the results matches the values in the yaml file >+ if (any { $val eq $_ } @{$denyingrules->{$field}}) { >+ # We return true if match found >+ return 1; >+ } >+ } >+ return 0; >+} >+ >+ > 1; > > __END__ >-- >2.1.4
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 15494
:
63700
|
63701
|
63702
|
63703
|
67886
|
67887
|
67888
|
67889
|
68146
|
68147
|
68148
|
68149
|
70295
|
70629
|
70630
|
70631
|
70632
|
71129
|
71130
|
71131
|
71132
|
71133
|
71134
|
71135
|
71136
|
71137
|
71138
|
79249
|
79250
|
79251
|
79252
|
79253
|
79254
|
79293
|
80327
|
80328
|
80329
|
80330
|
80331
|
80332
|
80333
|
81411
|
81412
|
81413
|
81414
|
81415
|
81416
|
81417