(bug #3674) allow users creation with disabled password
[koha.git] / C4 / Matcher.pm
index a0f1a98..ae6fb7d 100644 (file)
@@ -18,6 +18,8 @@ package C4::Matcher;
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use warnings;
+
 use C4::Context;
 use MARC::Record;
 use C4::Search;
@@ -661,7 +663,7 @@ sub get_matches {
         # build query
         my $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
         # FIXME only searching biblio index at the moment
-        my ($error, $searchresults, $total_hits) = SimpleSearch($query);
+        my ($error, $searchresults, $total_hits) = SimpleSearch($query, 0, $max_matches);
 
         warn "search failed ($query) $error" if $error;
         foreach my $matched (@$searchresults) {
@@ -772,21 +774,23 @@ sub _get_match_keys {
             last FIELD if $j > 0 and $check_only_first_repeat;
             last FIELD if $i > 0 and $j > $#keys;
             my $key = "";
+                       my $string;
             if ($field->is_control_field()) {
-                if ($component->{'length'}) {
-                    $key = _normalize(substr($field->data(), $component->{'offset'}, $component->{'length'}))
-                            # FIXME normalize, substr
-                } else {
-                    $key = _normalize($field->data());
-                }
+                               $string=$field->data();
             } else {
                 foreach my $subfield ($field->subfields()) {
                     if (exists $component->{'subfields'}->{$subfield->[0]}) {
-                        $key .= " " . $subfield->[1];
+                        $string .= " " . $subfield->[1];
                     }
                 }
-                $key = _normalize($key);
+                       }
+            if ($component->{'length'}>0) {
+                    $string= substr($string, $component->{'offset'}, $component->{'length'});
+                            # FIXME normalize, substr
+            } elsif ($component->{'offset'}) {
+                    $string= substr($string, $component->{'offset'});
             }
+            $key = _normalize($string);
             if ($i == 0) {
                 push @keys, $key if $key;
             } else {
@@ -795,7 +799,6 @@ sub _get_match_keys {
         }
     }
     return @keys;
-    
 }
 
 
@@ -815,10 +818,12 @@ sub _parse_match_component {
 # FIXME - default normalizer
 sub _normalize {
     my $value = uc shift;
+    $value =~ s/[.;:,\]\[\)\(\/'"]//g;
     $value =~ s/^\s+//;
-    $value =~ s/^\s+$//;
+    #$value =~ s/^\s+$//;
+    $value =~ s/\s+$//;
     $value =~ s/\s+/ /g;
-    $value =~ s/[.;,\]\[\)\(\/"']//g;
+    #$value =~ s/[.;,\]\[\)\(\/"']//g;
     return $value;
 }