Bugzilla – Attachment 4511 Details for
Bug 6521
Editing a patron fails with blank cardnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6521 - allow blank cardnumbers to not trigger "already in use"
Bug-6521---allow-blank-cardnumbers-to-not-trigger-.patch (text/plain), 3.76 KB, created by
Robin Sheat
on 2011-06-21 04:42:46 UTC
(
hide
)
Description:
Bug 6521 - allow blank cardnumbers to not trigger "already in use"
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2011-06-21 04:42:46 UTC
Size:
3.76 KB
patch
obsolete
>From 014f5827f49dd8b69f3a685e404d7ef3de864910 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Tue, 21 Jun 2011 16:40:38 +1200 >Subject: [PATCH] Bug 6521 - allow blank cardnumbers to not trigger "already in use" > >Now a blank cardnumber will get stored as a null in the database, which >is a value that allows duplicates. As such, if cardnumbers aren't >mandatory, then you can actually save a user with it being blank. >--- > C4/Members.pm | 3 +++ > members/memberentry.pl | 28 +++++++++++++++------------- > 2 files changed, 18 insertions(+), 13 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index e03b40b..c6c6985 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -900,6 +900,7 @@ sub fixup_cardnumber ($) { > > # if ($cardnumber !~ /\S/ && $autonumber_members) { > ($autonumber_members) or return $cardnumber; >+ defined($cardnumber) or return $cardnumber; > my $checkdigit = C4::Context->preference('checkdigit'); > my $dbh = C4::Context->dbh; > if ( $checkdigit and $checkdigit eq 'katipo' ) { >@@ -1261,6 +1262,8 @@ sub checkuniquemember { > > sub checkcardnumber { > my ($cardnumber,$borrowernumber) = @_; >+ # If cardnumber is null, we assume they're allowed. >+ return 0 if !defined($cardnumber); > my $dbh = C4::Context->dbh; > my $query = "SELECT * FROM borrowers WHERE cardnumber=?"; > $query .= " AND borrowernumber <> ?" if ($borrowernumber); >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 61c3c2c..be34cc4 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -236,19 +236,22 @@ if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){ > $debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry); > my $extended_patron_attributes = (); > if ($op eq 'save' || $op eq 'insert'){ >- if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ >- push @errors, 'ERROR_cardnumber'; >- } >- my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0; >- if ($newdata{dateofbirth} && $dateofbirthmandatory) { >- my $age = GetAge($newdata{dateofbirth}); >- my $borrowercategory=GetBorrowercategory($newdata{'categorycode'}); >- my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'}); >- if (($high && ($age > $high)) or ($age < $low)) { >- push @errors, 'ERROR_age_limitations'; >- $template->param('ERROR_age_limitations' => "$low to $high"); >+ # If the cardnumber is blank, treat it as null. >+ $newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; >+ >+ if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ >+ push @errors, 'ERROR_cardnumber'; >+ } >+ my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0; >+ if ($newdata{dateofbirth} && $dateofbirthmandatory) { >+ my $age = GetAge($newdata{dateofbirth}); >+ my $borrowercategory=GetBorrowercategory($newdata{'categorycode'}); >+ my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'}); >+ if (($high && ($age > $high)) or ($age < $low)) { >+ push @errors, 'ERROR_age_limitations'; >+ $template->param('ERROR_age_limitations' => "$low to $high"); >+ } > } >- } > > if($newdata{surname} && C4::Context->preference('uppercasesurnames')) { > $newdata{'surname'} = uc($newdata{'surname'}); >@@ -396,7 +399,6 @@ if ( $op eq "duplicate" ) { > $template->param( step_1 => 1, step_2 => 1, step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1 ) unless $step; > } > >-# my $cardnumber=$data{'cardnumber'}; > $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add'; > if(!defined($data{'sex'})){ > $template->param( none => 1); >-- >1.7.4.1
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 6521
: 4511 |
4681