[Koha-patches] [PATCH] 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.

Peter Lorimer peter at oslo.ie
Thu Jun 30 16:38:47 CEST 2011


Bug # 6539

On Wed, Jun 29, 2011 at 5:44 PM, Peter Lorimer <peter at oslo.ie> wrote:

> 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.
> ---
>  C4/Search.pm |   34 +++++++++++++++++++++++++++++-----
>  1 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/C4/Search.pm b/C4/Search.pm
> index c3cff65..5648faa 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,15 @@ 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;
> +              if ( C4::Context->preference("searchMyLibraryOnly")  )
> +           {
> +            $bsth =$dbh->prepare("SELECT branchcode,branchname FROM
> branches WHERE branchcode = '". C4::Branch::mybranch() ."' "); # FIXME : use
> C4::Branch::GetBranches
> +            }
> +            else
> +            {
> +             $bsth =$dbh->prepare("SELECT branchcode,branchname FROM
> branches ");
> +            }
>     $bsth->execute();
>     while ( my $bdata = $bsth->fetchrow_hashref ) {
>         $branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'};
> @@ -1671,7 +1680,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 +1695,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 +1704,7 @@ sub searchResults {
>                         $can_place_holds = 1;
>                     }
>
> +
>                     $other_count++;
>
>                     my $key = $prefix . $item->{status};
> @@ -2599,9 +2609,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 +2662,9 @@ OR adds a new authority record
>  =cut
>
>
> +
> +
> +
>  sub BiblioAddAuthorities{
>   my ( $record, $frameworkcode ) = @_;
>   my $dbh=C4::Context->dbh;
> --
> 1.7.4.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20110630/fec98edf/attachment.htm>


More information about the Koha-patches mailing list