Bug 11630: improve parsing of age restriction markers
This patch makes the parsing of AgeRestrictionMarker values consider the case where the marker is immediately followed by the age, e.g. "K16" in Finland. How I tested: [1] Configure Age Restricition (see Syspref AgeRestrictionMarker) and have a biblio record with e.g. PEGI 99 in age restriction field. [2] Try to check out to a patron with age < 99 [3] Check out should be blocked [4] Change entry in age restriction field to PEGI99 [5] Checkout should be possible [6] Apply patch [7] Checkout schould now be blocked Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
e28dbbf76c
commit
19badb2db4
|
|
@ -982,30 +982,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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue