[interchange-cvs] interchange - racke modified 4 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Wed Jul 9 13:54:20 UTC 2008
User: racke
Date: 2008-07-09 13:54:20 GMT
Modified: . WHATSNEW-5.7 MANIFEST
Modified: lib/Vend Order.pm
Added: code/OrderCheck isbn.oc
Log:
relocate isbn order check to code/OrderCheck
Revision Changes Path
2.4 interchange/WHATSNEW-5.7
rev 2.4, prev_rev 2.3
Index: WHATSNEW-5.7
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.7,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -r2.3 -r2.4
--- WHATSNEW-5.7 7 Jul 2008 18:15:07 -0000 2.3
+++ WHATSNEW-5.7 9 Jul 2008 13:54:20 -0000 2.4
@@ -25,4 +25,9 @@
* srcliteral attribute added to [button] tag. Setting srcliteral avoids the image existence check for the src attribute.
+OrderCheck
+----------
+
+* relocate isbn order check to code/OrderCheck.
+
(end)
2.230 interchange/MANIFEST
rev 2.230, prev_rev 2.229
Index: MANIFEST
===================================================================
RCS file: /var/cvs/interchange/MANIFEST,v
retrieving revision 2.229
retrieving revision 2.230
diff -u -r2.229 -r2.230
--- MANIFEST 21 May 2008 22:21:05 -0000 2.229
+++ MANIFEST 9 Jul 2008 13:54:20 -0000 2.230
@@ -94,6 +94,7 @@
code/OrderCheck/always_pass.oc
code/OrderCheck/email_only.oc
code/OrderCheck/exists.oc
+code/OrderCheck/isbn.oc
code/OrderCheck/filter.oc
code/OrderCheck/future.oc
code/OrderCheck/length.oc
2.101 interchange/lib/Vend/Order.pm
rev 2.101, prev_rev 2.100
Index: Order.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.100
retrieving revision 2.101
diff -u -r2.100 -r2.101
--- Order.pm 25 Mar 2008 17:13:21 -0000 2.100
+++ Order.pm 9 Jul 2008 13:54:20 -0000 2.101
@@ -1,6 +1,6 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.100 2008-03-25 17:13:21 jon Exp $
+# $Id: Order.pm,v 2.101 2008-07-09 13:54:20 racke Exp $
#
# Copyright (C) 2002-2008 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -29,7 +29,7 @@
package Vend::Order;
require Exporter;
-$VERSION = substr(q$Revision: 2.100 $, 10);
+$VERSION = substr(q$Revision: 2.101 $, 10);
@ISA = qw(Exporter);
@@ -1331,45 +1331,6 @@
}
}
-# Contributed by Ton Verhagen -- April 15, 2000
-sub _isbn {
- # $ref is to $::Values hash (well, actually ref to %CGI::values)
- # $var is the passed name of the variable
- # $val is current value of checked variable
- # This routine will return 1 if isbn is ok, else returns 0
- # Rules:
- # isbn number must contain exactly 10 digits.
- # isbn number: 0 9 4 0 0 1 6 3 3 8
- # weighting factor: 10 9 8 7 6 5 4 3 2 1
- # Values (product) 0 +81 +32 + 0 + 0 + 5 +24 + 9 + 6 + 8 --> sum is: 165
- # Sum must be divisable by 11 without remainder: 165/11=15 (no remainder)
- # Result: isbn 0-940016-33-8 is a valid isbn number.
- # Note: the last "digit" could be a "X", which would be treated as 10 in the above
-
- my($ref, $var, $val) = @_;
- $val =~ s/[^\dXx]//g; # weed out non-digits
- if( $val && length($val) == 10 ) {
- my @digits = split("", $val);
- my $sum=0;
- for(my $i=10; $i > 0; $i--) {
- my $d = $digits[10 - $i];
- if ($d =~ /[Xx]/) {
- if ($i == 1) {
- $d = 10;
- }
- else {
- return (undef, $var, errmsg("'%s' not a valid isbn number", $val));
- }
- }
- $sum += $d * $i;
- }
- return ( $sum%11 ? 0 : 1, $var, '' );
- }
- else {
- return (undef, $var, errmsg("'%s' not a valid isbn number", $val));
- }
-}
-
sub _mandatory {
my($ref,$var,$val) = @_;
return (1, $var, '')
1.1 interchange/code/OrderCheck/isbn.oc
rev 1.1, prev_rev 1.0
Index: isbn.oc
===================================================================
# Copyright 2008 Interchange Development Group
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
#
# $Id: isbn.oc,v 1.1 2008-07-09 13:54:20 racke Exp $
CodeDef isbn OrderCheck 1
CodeDef isbn Description ISBN-10 check digit verification
CodeDef isbn Routine <<EOR
sub {
my($ref, $var, $val) = @_;
$val =~ s/[^\dXx]//g; # weed out non-digits
if( $val && length($val) == 10 ) {
my @digits = split("", $val);
my $sum=0;
for(my $i=10; $i > 0; $i--) {
my $d = $digits[10 - $i];
if ($d =~ /[Xx]/) {
if ($i == 1) {
$d = 10;
}
else {
return (undef, $var, errmsg("'%s' not a valid isbn number", $val));
}
}
$sum += $d * $i;
}
return ( $sum%11 ? 0 : 1, $var, '' );
}
else {
return (undef, $var, errmsg("'%s' not a valid isbn number", $val));
}
}
EOR
More information about the interchange-cvs
mailing list