From feae3136b43ed5d6f31888c2359b8ab535fbbb2e Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 18 Mar 2003 10:58:19 +0000 Subject: [PATCH] adding checkdigit parameter that choose how to check the members cardnumber. At the moment : * none = no checking * katipo = checked as before --- C4/Input.pm | 49 ++++++++++++++++++++++-------------------- updater/updatedatabase | 7 ++++++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/C4/Input.pm b/C4/Input.pm index 49955f38d4..b058d9ac6b 100644 --- a/C4/Input.pm +++ b/C4/Input.pm @@ -20,6 +20,7 @@ package C4::Input; #assumes C4/Input use strict; require Exporter; +use C4::Context; use vars qw($VERSION @ISA @EXPORT); @@ -78,29 +79,31 @@ C<$env> is ignored. =cut #' sub checkdigit { - my ($env,$infl) = @_; - $infl = uc $infl; - my @weightings = (8,4,6,3,5,2,1); - my $sum; - my $i = 1; - my $valid = 0; - # print $infl."
"; - - foreach $i (1..7) { - my $temp1 = $weightings[$i-1]; - my $temp2 = substr($infl,$i,1); - $sum += $temp1 * $temp2; -# print "$sum $temp1 $temp2
"; - } - my $rem = ($sum%11); - if ($rem == 10) { - $rem = "X"; - } - #print $rem."
"; - if ($rem eq substr($infl,8,1)) { - $valid = 1; - } - return $valid; + if (C4::Context->preference("checkdigit") eq "none") { + warn "XXcheckdigit : ".C4::Context->preference("checkdigit"); + return 1; + } else { + my ($env,$infl) = @_; + $infl = uc $infl; + my @weightings = (8,4,6,3,5,2,1); + my $sum; + my $i = 1; + my $valid = 0; + + foreach $i (1..7) { + my $temp1 = $weightings[$i-1]; + my $temp2 = substr($infl,$i,1); + $sum += $temp1 * $temp2; + } + my $rem = ($sum%11); + if ($rem == 10) { + $rem = "X"; + } + if ($rem eq substr($infl,8,1)) { + $valid = 1; + } + return $valid; + } } # sub checkdigit =item checkvalidisbn diff --git a/updater/updatedatabase b/updater/updatedatabase index 41a6c564ad..3bca09592a 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -278,6 +278,7 @@ my %tabledata=( { uniquefieldrequired => 'variable', variable => 'timeout', value => '12000000', explanation => 'login timeout' }, { uniquefieldrequired => 'variable', variable => 'marc', value => 'ON', explanation => 'MARC support (ON or OFF)' }, { uniquefieldrequired => 'variable', variable => 'marcflavour', value => 'MARC21', explanation => 'your MARC flavor (MARC21 or UNIMARC) used for character encoding' }, + { uniquefieldrequired => 'variable', variable => 'checkdigit', value => 'katipo', explanation => 'none= no check on member cardnumber. katipo= katipo check' }, ], ); @@ -543,6 +544,12 @@ $sth->finish; exit; # $Log$ +# Revision 1.38 2003/03/18 10:58:19 tipaul +# adding checkdigit parameter that choose how to check the members cardnumber. +# At the moment : +# * none = no checking +# * katipo = checked as before +# # Revision 1.37 2003/01/30 01:47:48 acli # Corrected syntax error reported by Benedict # -- 2.39.5