From 3495634661767e0148fc50fa6ef607a6600b3384 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 29 Jan 2014 09:37:18 +0200 Subject: [PATCH] Improve AgeRestrictionMarker to consider the case where the marker is immediately followed by the age, eg. "K16" in Finland. --- C4/Circulation.pm | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f8b204a..f4989a9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -981,30 +981,29 @@ sub CanBookBeIssued { if (($markers)&&($bibvalues)) { # Split $bibvalues to something like FSK 16 or PEGI 6 - my @values = split ' ', $bibvalues; + my @values = split ' ', uc($bibvalues); # Search first occurence of one of the markers - my @markers = split /\|/, $markers; + my @markers = split /\|/, uc($markers); my $index = 0; - my $take = -1; + my $restrictionyear = 0; for my $value (@values) { $index ++; for my $marker (@markers) { $marker =~ s/^\s+//; #remove leading spaces $marker =~ s/\s+$//; #remove trailing spaces - if (uc($marker) eq uc($value)) { - $take = $index; + if ($marker eq $value) { + if ($index <= $#values) { + $restrictionyear += $values[$index]; + } + last; + } elsif ($value =~ /^\Q$marker\E(\d+)$/) { + # Perhaps it is something like "K16" (as in Finland) + $restrictionyear += $1; last; } } - if ($take > -1) { - last; - } - } - # Index points to the next value - my $restrictionyear = 0; - if (($take <= $#values) && ($take >= 0)){ - $restrictionyear += $values[$take]; + last if ($restrictionyear > 0); } if ($restrictionyear > 0) { -- 1.8.3.2