Bugzilla – Attachment 10866 Details for
Bug 7621
Circulation: Match age restriction of title with borrower's age without using categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7621 . Circulation: Match age restriction of title with borrower's age without using categories
Bug-7621--Circulation-Match-age-restriction-of-tit.patch (text/plain), 3.51 KB, created by
Marc Véron
on 2012-07-16 05:23:22 UTC
(
hide
)
Description:
Bug 7621 . Circulation: Match age restriction of title with borrower's age without using categories
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2012-07-16 05:23:22 UTC
Size:
3.51 KB
patch
obsolete
>From bcad390a72e70867316d8c7d2fca38003b0d1a66 Mon Sep 17 00:00:00 2001 >From: Marc Veron <veron@veron.ch> >Date: Mon, 16 Jul 2012 07:11:06 +0200 >Subject: [PATCH] Bug 7621 . Circulation: Match age restriction of title with borrower's age without using categories >Content-Type: text/plain; charset="utf-8" > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >New version implementing Paul's advice. > >Usage see >http://wiki.koha-community.org/wiki/Age_restriction > >Changes in C4/Circulation.pm; > >- skip age restriciton part as well if no age restriction info in biblio record >- more robust string comparision part (nested for... loops instead of grep and better handling of superfluous white space) >- display whole age restriction string as information (e.g. FSK 16 instead of 16) >--- > C4/Circulation.pm | 30 +++++++++++++++++++----------- > 1 files changed, 19 insertions(+), 11 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 55f8988..d826161 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -944,21 +944,28 @@ sub CanBookBeIssued { > # > > # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" >- my $marker = C4::Context->preference('AgeRestrictionMarker' ); > >- if ($marker) >+ my $markers = C4::Context->preference('AgeRestrictionMarker' ); >+ my $agerestriction = $biblioitem->{'agerestriction'}; >+ if ($markers && $agerestriction) > { > # Split $value to something like FSK 16 or PEGI 6 >- my @marker = split /\|/, $marker; >- my @values = split ' ', $biblioitem->{'agerestriction'} ; >- >+ my @markers = split /\|/, $markers; >+ my @values = split ' ', $agerestriction; > # Search first occurence of one of the markers > my $index = 0; > my $take = -1; > for my $value (@values) { >- $index ++; >- if (grep {uc($_) eq $value} @marker) { >- $take = $index; >+ $index = $index +1 ; >+ for my $marker (@markers) { >+ $marker =~ s/^\s+//; #remove leading spaces >+ $marker =~ s/\s+$//; #remove trailing spaces >+ if ($marker eq $value) { >+ $take = $index; >+ last; >+ } >+ } >+ if ($take > -1) { > last; > } > } >@@ -972,7 +979,7 @@ sub CanBookBeIssued { > if ( $borrower->{'dateofbirth'} ) { > my @alloweddate = split /-/,$borrower->{'dateofbirth'} ; > @alloweddate[0] += $restrictionyear; >- #Prevent runime eror on leap year (invalid date) >+ #Prevent runtime eror on leap year (invalid date) > if ((@alloweddate[1] == 2) && (@alloweddate[2] == 29)) { > @alloweddate[2] = 28; > } >@@ -982,15 +989,16 @@ sub CanBookBeIssued { > > if ( Date_to_Days(Today) < Date_to_Days(@alloweddate) -1 ) { > if (C4::Context->preference('AgeRestrictionOverride ' )) { >- $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear"; >+ $needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; > } > else { >- $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear"; >+ $issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; > } > } > } > } > } >+ > return ( \%issuingimpossible, \%needsconfirmation, \%alerts ); > } > >-- >1.7.2.5
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 7621
:
9176
|
9219
|
9979
|
10072
|
10136
|
10141
|
10142
|
10143
|
10144
|
10395
|
10550
|
10650
|
10657
|
10658
|
10859
|
10866
|
10896
|
11130
|
11550
|
11938
|
11939
|
12132
|
12133
|
12547
|
12558
|
12559
|
12563