Bug 8761 Dont inadvertantly use slices
[koha.git] / C4 / Members.pm
index ce54952..2e315aa 100644 (file)
@@ -38,11 +38,12 @@ use C4::NewsChannels; #get slip news
 use DateTime;
 use DateTime::Format::DateParse;
 use Koha::DateUtils;
+use Text::Unaccent qw( unac_string );
 
 our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
 
 BEGIN {
-    $VERSION = 3.02;
+    $VERSION = 3.07.00.049;
     $debug = $ENV{DEBUG} || 0;
     require Exporter;
     @ISA = qw(Exporter);
@@ -800,6 +801,7 @@ sub Generate_Userid {
     $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
     $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g;
     $newuid = lc(($firstname)? "$firstname.$surname" : $surname);
+    $newuid = unac_string('utf-8',$newuid);
     $newuid .= $offset unless $offset == 0;
     $offset++;
 
@@ -897,11 +899,8 @@ sub fixup_cardnumber {
         return "V$cardnumber$rem";
      } else {
 
-     # MODIFIED BY JF: mysql4.1 allows casting as an integer, which is probably
-     # better. I'll leave the original in in case it needs to be changed for you
-     # my $sth=$dbh->prepare("select max(borrowers.cardnumber) from borrowers");
         my $sth = $dbh->prepare(
-            "select max(cast(cardnumber as signed)) from borrowers"
+            'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
         );
         $sth->execute;
         my ($result) = $sth->fetchrow;