From c49fb53a4546eae0c6cc4d5d8ee5b1443dc687ee Mon Sep 17 00:00:00 2001 From: btoumi Date: Fri, 11 May 2007 14:49:54 +0000 Subject: [PATCH] add security for the item barcode --- C4/Circulation.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 34691246c2..7fb11e79b9 100755 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -855,7 +855,8 @@ sub AddIssue { my ( $borrower, $barcode, $date, $cancelreserve ) = @_; my $dbh = C4::Context->dbh; -if ($borrower and $barcode){ +my $barcodecheck=CheckValidBarcode($barcode); +if ($borrower and $barcode and $barcodecheck ne '0'){ # my ($borrower, $flags) = &GetMemberDetails($borrowernumber, 0); # find which item we issue my $item = GetItem('', $barcode); @@ -2002,6 +2003,20 @@ $sth->finish; return $countspecial; } +sub CheckValidBarcode{ +my ($barcode) = @_; +my $dbh = C4::Context->dbh; +my $query=qq|SELECT count(*) + FROM items + WHERE barcode=? + |; +my $sth = $dbh->prepare($query); +$sth->execute($barcode); +my $exist=$sth->fetchrow ; +$sth->finish; +return $exist; +} + 1; __END__ -- 2.39.2