From 1afda1218e1ba7d881d93b34e7449123005f8e15 Mon Sep 17 00:00:00 2001 From: Peter Lorimer Date: Thu, 30 Jun 2011 09:47:55 +0100 Subject: [PATCH] [SIGNED-OFF] When searching the catalogue, if I get no results then hit the Z39.50 search the title field in the pop up window is populated with what I searched for. Content-Type: text/plain; charset="utf-8" If I search for a valid ISBN number and hit the Z39.50 search, the title field is populated with the ISBN number I searched for. This number should populate the ISBN field and not the title field. http://bugs.koha-community.org/show_bug.cgi?id=6539 Signed-off-by: Katrin Fischer To test: - Search new ISBN using ISBN search from advanced search page - 0 results - click on Z39.50 search - Z30.50 form will have your ISBN in ISBN search option I am signing off on this, because it's an improvement over the current behaviour. I see some problems though that should perhaps be addressed in a separate bug or as a follow-up: If you use th catalog search field and search for an ISBN or a keyword the right fields of the Z39.50 search form will be populated, but the search index will be put in front: ISBN: kw,wrdl: 9783492251495 or Title: kw,wrdl: koha testing If you search for ISBN as keyword on the advanced search page, it will still populate the Title search. --- C4/Search.pm | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index c3cff65..d8d2ec5 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -33,6 +33,7 @@ use C4::Debug; use C4::Items; use YAML; use URI::Escape; +use Business::ISBN; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); @@ -1423,7 +1424,7 @@ sub searchResults { #find branchname #get branch information..... my %branches; - my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches"); # FIXME : use C4::Branch::GetBranches + my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches "); $bsth->execute(); while ( my $bdata = $bsth->fetchrow_hashref ) { $branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'}; @@ -1671,7 +1672,7 @@ sub searchResults { ($reservestatus, $reserveitem) = C4::Reserves::CheckReserves($item->{itemnumber}); } - # item is withdrawn, lost, damaged, not for loan, reserved or in transit + # item is withdrawn, lost or damaged if ( $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} @@ -1686,8 +1687,8 @@ sub searchResults { $item_in_transit_count++ if $transfertwhen ne ''; $item_onhold_count++ if $reservestatus eq 'Waiting'; $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; - - # can place hold on item ? + + # can place hold on item ? if ((!$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems')) && !$item->{itemlost} && !$item->{withdrawn} @@ -1695,6 +1696,7 @@ sub searchResults { $can_place_holds = 1; } + $other_count++; my $key = $prefix . $item->{status}; @@ -2599,9 +2601,20 @@ $template->param ( MYLOOP => C4::Search::z3950_search_args($searchscalar) ) =cut + + + sub z3950_search_args { my $bibrec = shift; - $bibrec = { title => $bibrec } if !ref $bibrec; + my $isbn = Business::ISBN->new($bibrec); + + if (defined $isbn && $isbn->is_valid) + { + $bibrec = { isbn => $bibrec } if !ref $bibrec; +} +else { + $bibrec = { title => $bibrec } if !ref $bibrec; +} my $array = []; for my $field (qw/ lccn isbn issn title author dewey subject /) { @@ -2641,6 +2654,9 @@ OR adds a new authority record =cut + + + sub BiblioAddAuthorities{ my ( $record, $frameworkcode ) = @_; my $dbh=C4::Context->dbh; -- 1.7.4.1