[Koha-cvs] koha/C4 Search.pm

Henri-Damien LAURENT laurenthdl at alinto.com
Mon Jul 16 17:44:32 CEST 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Changes by:	Henri-Damien LAURENT <hdl>	07/07/16 15:44:32

Modified files:
	C4             : Search.pm 

Log message:
	FindDuplicate works for an title itemtype author key.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&r1=1.150&r2=1.151

Patches:
Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- Search.pm	2 Jul 2007 08:50:56 -0000	1.150
+++ Search.pm	16 Jul 2007 15:44:31 -0000	1.151
@@ -25,7 +25,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.150 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.151 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -91,7 +91,6 @@
 
 sub FindDuplicate {
     my ($record) = @_;
-    return;
     my $dbh = C4::Context->dbh;
     my $result = TransformMarcToKoha( $dbh, $record, '' );
     my $sth;
@@ -111,19 +110,30 @@
         $result->{title} =~ s /\(//g;
         $result->{title} =~ s /\)//g;
         $query = "ti,ext=$result->{title}";
+        $query .= " and mt=$result->{itemtype}" if ($result->{itemtype});    
+        if ($result->{author}){
+          $result->{author} =~ s /\\//g;
+          $result->{author} =~ s /\"//g;
+          $result->{author} =~ s /\(//g;
+          $result->{author} =~ s /\)//g;
+          $query .= " and au,ext=$result->{author}";
     }
-    my ($possible_duplicate_record) =
-      C4::Biblio::getRecord( "biblioserver", $query, "usmarc" ); # FIXME :: hardcoded !
-    if ($possible_duplicate_record) {
+    }
+    my ($error,$searchresults) =
+      SimpleSearch($query); # FIXME :: hardcoded !
+    my @results;
+    foreach my $possible_duplicate_record (@$searchresults) {
         my $marcrecord =
           MARC::Record->new_from_usmarc($possible_duplicate_record);
         my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
         
         # FIXME :: why 2 $biblionumber ?
-        return $result->{'biblionumber'}, $result->{'biblionumber'},
-          $result->{'title'}
-          if $result;
+        if ($result){
+          push @results, $result->{'biblionumber'};
+          push @results, $result->{'title'};
+        }
     }
+    return @results;  
 }
 
 =head2 SimpleSearch





More information about the Koha-cvs mailing list