View | Details | Raw Unified | Return to bug 7430
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-28 / +4 lines)
Lines 27-32 use C4::AuthoritiesMarc::MARC21; Link Here
27
use C4::AuthoritiesMarc::UNIMARC;
27
use C4::AuthoritiesMarc::UNIMARC;
28
use C4::Charset;
28
use C4::Charset;
29
use C4::Log;
29
use C4::Log;
30
use Koha::Utils;
31
use Koha::Search;
30
32
31
use vars qw($VERSION @ISA @EXPORT);
33
use vars qw($VERSION @ISA @EXPORT);
32
34
Lines 38-44 BEGIN { Link Here
38
	@ISA = qw(Exporter);
40
	@ISA = qw(Exporter);
39
	@EXPORT = qw(
41
	@EXPORT = qw(
40
	    &GetTagsLabels
42
	    &GetTagsLabels
41
	    &GetAuthType
42
	    &GetAuthTypeCode
43
	    &GetAuthTypeCode
43
    	&GetAuthMARCFromKohaField 
44
    	&GetAuthMARCFromKohaField 
44
    	&AUTHhtml2marc
45
    	&AUTHhtml2marc
Lines 718-724 sub AddAuthority { Link Here
718
    $sth->finish;
719
    $sth->finish;
719
    logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
720
    logaction( "AUTHORITIES", "ADD", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
720
  }
721
  }
721
  ModZebra($authid,'specialUpdate',"authorityserver",$oldRecord,$record);
722
  AddToIndexQueue($authid,'specialUpdate',"authorityserver",$oldRecord,$record);
722
  return ($authid);
723
  return ($authid);
723
}
724
}
724
725
Lines 736-742 sub DelAuthority { Link Here
736
    my $dbh=C4::Context->dbh;
737
    my $dbh=C4::Context->dbh;
737
738
738
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
739
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
739
    ModZebra($authid,"recordDelete","authorityserver",GetAuthority($authid),undef);
740
    AddToIndexQueue($authid,"recordDelete","authorityserver",GetAuthority($authid),undef);
740
    my $sth = $dbh->prepare("DELETE FROM auth_header WHERE authid=?");
741
    my $sth = $dbh->prepare("DELETE FROM auth_header WHERE authid=?");
741
    $sth->execute($authid);
742
    $sth->execute($authid);
742
}
743
}
Lines 828-858 sub GetAuthority { Link Here
828
    return ($record);
829
    return ($record);
829
}
830
}
830
831
831
=head2 GetAuthType 
832
833
  $result = &GetAuthType($authtypecode)
834
835
If the authority type specified by C<$authtypecode> exists,
836
returns a hashref of the type's fields.  If the type
837
does not exist, returns undef.
838
839
=cut
840
841
sub GetAuthType {
842
    my ($authtypecode) = @_;
843
    my $dbh=C4::Context->dbh;
844
    my $sth;
845
    if (defined $authtypecode){ # NOTE - in MARC21 framework, '' is a valid authority 
846
                                # type (FIXME but why?)
847
        $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
848
        $sth->execute($authtypecode);
849
        if (my $res = $sth->fetchrow_hashref) {
850
            return $res; 
851
        }
852
    }
853
    return;
854
}
855
856
832
857
sub AUTHhtml2marc {
833
sub AUTHhtml2marc {
858
    my ($rtags,$rsubfields,$rvalues,%indicators) = @_;
834
    my ($rtags,$rsubfields,$rvalues,%indicators) = @_;
(-)a/C4/Biblio.pm (-409 / +8 lines)
Lines 38-43 use C4::Charset; Link Here
38
require C4::Heading;
38
require C4::Heading;
39
require C4::Serials;
39
require C4::Serials;
40
require C4::Items;
40
require C4::Items;
41
use Koha::Search;
42
use Koha::Utils;
41
43
42
use vars qw($VERSION @ISA @EXPORT);
44
use vars qw($VERSION @ISA @EXPORT);
43
45
Lines 88-94 BEGIN { Link Here
88
90
89
      &GetAuthorisedValueDesc
91
      &GetAuthorisedValueDesc
90
      &GetMarcStructure
92
      &GetMarcStructure
91
      &GetMarcFromKohaField
92
      &GetFrameworkCode
93
      &GetFrameworkCode
93
      &TransformKohaToMarc
94
      &TransformKohaToMarc
94
      &PrepHostMarcField
95
      &PrepHostMarcField
Lines 132-138 BEGIN { Link Here
132
      &TransformHtmlToMarc
133
      &TransformHtmlToMarc
133
      &TransformHtmlToXml
134
      &TransformHtmlToXml
134
      &PrepareItemrecordDisplay
135
      &PrepareItemrecordDisplay
135
      &GetNoZebraIndexes
136
    );
136
    );
137
}
137
}
138
138
Lines 434-440 sub DelBiblio { Link Here
434
        # the previous version of the record
434
        # the previous version of the record
435
        $oldRecord = GetMarcBiblio($biblionumber);
435
        $oldRecord = GetMarcBiblio($biblionumber);
436
    }
436
    }
437
    ModZebra( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef );
437
    AddToIndexQueue( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef );
438
438
439
    # delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems
439
    # delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems
440
    $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
440
    $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?");
Lines 1032-1053 sub GetUsedMarcStructure($) { Link Here
1032
    return $sth->fetchall_arrayref( {} );
1032
    return $sth->fetchall_arrayref( {} );
1033
}
1033
}
1034
1034
1035
=head2 GetMarcFromKohaField
1036
1037
  ($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode);
1038
1039
Returns the MARC fields & subfields mapped to the koha field 
1040
for the given frameworkcode
1041
1042
=cut
1043
1044
sub GetMarcFromKohaField {
1045
    my ( $kohafield, $frameworkcode ) = @_;
1046
    return 0, 0 unless $kohafield and defined $frameworkcode;
1047
    my $relations = C4::Context->marcfromkohafield;
1048
    return ( $relations->{$frameworkcode}->{$kohafield}->[0], $relations->{$frameworkcode}->{$kohafield}->[1] );
1049
}
1050
1051
=head2 GetMarcBiblio
1035
=head2 GetMarcBiblio
1052
1036
1053
  my $record = GetMarcBiblio($biblionumber, [$embeditems]);
1037
  my $record = GetMarcBiblio($biblionumber, [$embeditems]);
Lines 2690-2831 sub PrepareItemrecordDisplay { Link Here
2690
    };
2674
    };
2691
}
2675
}
2692
2676
2693
#"
2694
2695
#
2696
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
2697
# at the same time
2698
# replaced by a zebraqueue table, that is filled with ModZebra to run.
2699
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script
2700
# =head2 ModZebrafiles
2701
#
2702
# &ModZebrafiles( $dbh, $biblionumber, $record, $folder, $server );
2703
#
2704
# =cut
2705
#
2706
# sub ModZebrafiles {
2707
#
2708
#     my ( $dbh, $biblionumber, $record, $folder, $server ) = @_;
2709
#
2710
#     my $op;
2711
#     my $zebradir =
2712
#       C4::Context->zebraconfig($server)->{directory} . "/" . $folder . "/";
2713
#     unless ( opendir( DIR, "$zebradir" ) ) {
2714
#         warn "$zebradir not found";
2715
#         return;
2716
#     }
2717
#     closedir DIR;
2718
#     my $filename = $zebradir . $biblionumber;
2719
#
2720
#     if ($record) {
2721
#         open( OUTPUT, ">", $filename . ".xml" );
2722
#         print OUTPUT $record;
2723
#         close OUTPUT;
2724
#     }
2725
# }
2726
2677
2727
=head2 ModZebra
2678
=head2 ModZebra
2728
2679
2729
  ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord );
2680
  ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord );
2730
2681
2731
$biblionumber is the biblionumber we want to index
2682
This method should not be used. The functionality has been moved to
2732
2683
Koha::Search::AddToIndexQueue. It is left here as a temporary wrapper
2733
$op is specialUpdate or delete, and is used to know what we want to do
2684
to simplify the migration of custom scripts.
2734
2735
$server is the server that we want to update
2736
2737
$oldRecord is the MARC::Record containing the previous version of the record.  This is used only when 
2738
NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to
2739
do an update.
2740
2741
$newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one.
2742
2685
2743
=cut
2686
=cut
2744
2687
2745
sub ModZebra {
2688
sub ModZebra {
2746
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs
2689
    AddToIndexQueue(@_)
2747
    my ( $biblionumber, $op, $server, $oldRecord, $newRecord ) = @_;
2748
    my $dbh = C4::Context->dbh;
2749
2750
    # true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates
2751
    # at the same time
2752
    # replaced by a zebraqueue table, that is filled with ModZebra to run.
2753
    # the table is emptied by misc/cronjobs/zebraqueue_start.pl script
2754
2755
    if ( C4::Context->preference("NoZebra") ) {
2756
2757
        # lock the nozebra table : we will read index lines, update them in Perl process
2758
        # and write everything in 1 transaction.
2759
        # lock the table to avoid someone else overwriting what we are doing
2760
        $dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE, auth_subfield_structure READ');
2761
        my %result;    # the result hash that will be built by deletion / add, and written on mySQL at the end, to improve speed
2762
        if ( $op eq 'specialUpdate' ) {
2763
2764
            # OK, we have to add or update the record
2765
            # 1st delete (virtually, in indexes), if record actually exists
2766
            if ($oldRecord) {
2767
                %result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server );
2768
            }
2769
2770
            # ... add the record
2771
            %result = _AddBiblioNoZebra( $biblionumber, $newRecord, $server, %result );
2772
        } else {
2773
2774
            # it's a deletion, delete the record...
2775
            # warn "DELETE the record $biblionumber on $server".$record->as_formatted;
2776
            %result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server );
2777
        }
2778
2779
        # ok, now update the database...
2780
        my $sth = $dbh->prepare("UPDATE nozebra SET biblionumbers=? WHERE server=? AND indexname=? AND value=?");
2781
        foreach my $key ( keys %result ) {
2782
            foreach my $index ( keys %{ $result{$key} } ) {
2783
                $sth->execute( $result{$key}->{$index}, $server, $key, $index );
2784
            }
2785
        }
2786
        $dbh->do('UNLOCK TABLES');
2787
    } else {
2788
2789
        #
2790
        # we use zebra, just fill zebraqueue table
2791
        #
2792
        my $check_sql = "SELECT COUNT(*) FROM zebraqueue 
2793
                         WHERE server = ?
2794
                         AND   biblio_auth_number = ?
2795
                         AND   operation = ?
2796
                         AND   done = 0";
2797
        my $check_sth = $dbh->prepare_cached($check_sql);
2798
        $check_sth->execute( $server, $biblionumber, $op );
2799
        my ($count) = $check_sth->fetchrow_array;
2800
        $check_sth->finish();
2801
        if ( $count == 0 ) {
2802
            my $sth = $dbh->prepare("INSERT INTO zebraqueue  (biblio_auth_number,server,operation) VALUES(?,?,?)");
2803
            $sth->execute( $biblionumber, $server, $op );
2804
            $sth->finish;
2805
        }
2806
    }
2807
}
2808
2809
=head2 GetNoZebraIndexes
2810
2811
  %indexes = GetNoZebraIndexes;
2812
2813
return the data from NoZebraIndexes syspref.
2814
2815
=cut
2816
2817
sub GetNoZebraIndexes {
2818
    my $no_zebra_indexes = C4::Context->preference('NoZebraIndexes');
2819
    my %indexes;
2820
  INDEX: foreach my $line ( split /['"],[\n\r]*/, $no_zebra_indexes ) {
2821
        $line =~ /(.*)=>(.*)/;
2822
        my $index  = $1;    # initial ' or " is removed afterwards
2823
        my $fields = $2;
2824
        $index  =~ s/'|"|\s//g;
2825
        $fields =~ s/'|"|\s//g;
2826
        $indexes{$index} = $fields;
2827
    }
2828
    return %indexes;
2829
}
2690
}
2830
2691
2831
=head2 EmbedItemsInMarcBiblio
2692
=head2 EmbedItemsInMarcBiblio
Lines 2860-3127 sub EmbedItemsInMarcBiblio { Link Here
2860
2721
2861
=head1 INTERNAL FUNCTIONS
2722
=head1 INTERNAL FUNCTIONS
2862
2723
2863
=head2 _DelBiblioNoZebra($biblionumber,$record,$server);
2864
2865
function to delete a biblio in NoZebra indexes
2866
This function does NOT delete anything in database : it reads all the indexes entries
2867
that have to be deleted & delete them in the hash
2868
2869
The SQL part is done either :
2870
 - after the Add if we are modifying a biblio (delete + add again)
2871
 - immediatly after this sub if we are doing a true deletion.
2872
2873
$server can be 'biblioserver' or 'authorityserver' : it indexes biblios or authorities (in the same table, $server being part of the table itself
2874
2875
=cut
2876
2877
sub _DelBiblioNoZebra {
2878
    my ( $biblionumber, $record, $server ) = @_;
2879
2880
    # Get the indexes
2881
    my $dbh = C4::Context->dbh;
2882
2883
    # Get the indexes
2884
    my %index;
2885
    my $title;
2886
    if ( $server eq 'biblioserver' ) {
2887
        %index = GetNoZebraIndexes;
2888
2889
        # get title of the record (to store the 10 first letters with the index)
2890
        my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' );    # FIXME: should be GetFrameworkCode($biblionumber) ??
2891
        $title = lc( $record->subfield( $titletag, $titlesubfield ) );
2892
    } else {
2893
2894
        # for authorities, the "title" is the $a mainentry
2895
        my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location();
2896
        my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) );
2897
        warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref;
2898
        $title = $record->subfield( $authref->{auth_tag_to_report}, 'a' );
2899
        $index{'mainmainentry'} = $authref->{'auth_tag_to_report'} . 'a';
2900
        $index{'mainentry'}     = $authref->{'auth_tag_to_report'} . '*';
2901
        $index{'auth_type'}     = "${auth_type_tag}${auth_type_sf}";
2902
    }
2903
2904
    my %result;
2905
2906
    # remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values
2907
    $title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g;
2908
2909
    # limit to 10 char, should be enough, and limit the DB size
2910
    $title = substr( $title, 0, 10 );
2911
2912
    #parse each field
2913
    my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?');
2914
    foreach my $field ( $record->fields() ) {
2915
2916
        #parse each subfield
2917
        next if $field->tag < 10;
2918
        foreach my $subfield ( $field->subfields() ) {
2919
            my $tag          = $field->tag();
2920
            my $subfieldcode = $subfield->[0];
2921
            my $indexed      = 0;
2922
2923
            # check each index to see if the subfield is stored somewhere
2924
            # otherwise, store it in __RAW__ index
2925
            foreach my $key ( keys %index ) {
2926
2927
                #                 warn "examining $key index : ".$index{$key}." for $tag $subfieldcode";
2928
                if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) {
2929
                    $indexed = 1;
2930
                    my $line = lc $subfield->[1];
2931
2932
                    # remove meaningless value in the field...
2933
                    $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g;
2934
2935
                    # ... and split in words
2936
                    foreach ( split / /, $line ) {
2937
                        next unless $_;    # skip  empty values (multiple spaces)
2938
                                           # if the entry is already here, do nothing, the biblionumber has already be removed
2939
                        unless ( defined( $result{$key}->{$_} ) && ( $result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/ ) ) {
2940
2941
                            # get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing
2942
                            $sth2->execute( $server, $key, $_ );
2943
                            my $existing_biblionumbers = $sth2->fetchrow;
2944
2945
                            # it exists
2946
                            if ($existing_biblionumbers) {
2947
2948
                                #                                 warn " existing for $key $_: $existing_biblionumbers";
2949
                                $result{$key}->{$_} = $existing_biblionumbers;
2950
                                $result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//;
2951
                            }
2952
                        }
2953
                    }
2954
                }
2955
            }
2956
2957
            # the subfield is not indexed, store it in __RAW__ index anyway
2958
            unless ($indexed) {
2959
                my $line = lc $subfield->[1];
2960
                $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g;
2961
2962
                # ... and split in words
2963
                foreach ( split / /, $line ) {
2964
                    next unless $_;    # skip  empty values (multiple spaces)
2965
                                       # if the entry is already here, do nothing, the biblionumber has already be removed
2966
                    unless ( $result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/ ) {
2967
2968
                        # get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing
2969
                        $sth2->execute( $server, '__RAW__', $_ );
2970
                        my $existing_biblionumbers = $sth2->fetchrow;
2971
2972
                        # it exists
2973
                        if ($existing_biblionumbers) {
2974
                            $result{'__RAW__'}->{$_} = $existing_biblionumbers;
2975
                            $result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//;
2976
                        }
2977
                    }
2978
                }
2979
            }
2980
        }
2981
    }
2982
    return %result;
2983
}
2984
2985
=head2 _AddBiblioNoZebra
2986
2987
  _AddBiblioNoZebra($biblionumber, $record, $server, %result);
2988
2989
function to add a biblio in NoZebra indexes
2990
2991
=cut
2992
2993
sub _AddBiblioNoZebra {
2994
    my ( $biblionumber, $record, $server, %result ) = @_;
2995
    my $dbh = C4::Context->dbh;
2996
2997
    # Get the indexes
2998
    my %index;
2999
    my $title;
3000
    if ( $server eq 'biblioserver' ) {
3001
        %index = GetNoZebraIndexes;
3002
3003
        # get title of the record (to store the 10 first letters with the index)
3004
        my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' );    # FIXME: should be GetFrameworkCode($biblionumber) ??
3005
        $title = lc( $record->subfield( $titletag, $titlesubfield ) );
3006
    } else {
3007
3008
        # warn "server : $server";
3009
        # for authorities, the "title" is the $a mainentry
3010
        my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location();
3011
        my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) );
3012
        warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref;
3013
        $title = $record->subfield( $authref->{auth_tag_to_report}, 'a' );
3014
        $index{'mainmainentry'} = $authref->{auth_tag_to_report} . 'a';
3015
        $index{'mainentry'}     = $authref->{auth_tag_to_report} . '*';
3016
        $index{'auth_type'}     = "${auth_type_tag}${auth_type_sf}";
3017
    }
3018
3019
    # remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values
3020
    $title =~ s/ |\.|,|;|\[|\]|\(|\)|\*|-|'|:|=|\r|\n//g;
3021
3022
    # limit to 10 char, should be enough, and limit the DB size
3023
    $title = substr( $title, 0, 10 );
3024
3025
    #parse each field
3026
    my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?');
3027
    foreach my $field ( $record->fields() ) {
3028
3029
        #parse each subfield
3030
        ###FIXME: impossible to index a 001-009 value with NoZebra
3031
        next if $field->tag < 10;
3032
        foreach my $subfield ( $field->subfields() ) {
3033
            my $tag          = $field->tag();
3034
            my $subfieldcode = $subfield->[0];
3035
            my $indexed      = 0;
3036
3037
            #             warn "INDEXING :".$subfield->[1];
3038
            # check each index to see if the subfield is stored somewhere
3039
            # otherwise, store it in __RAW__ index
3040
            foreach my $key ( keys %index ) {
3041
3042
                #                 warn "examining $key index : ".$index{$key}." for $tag $subfieldcode";
3043
                if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) {
3044
                    $indexed = 1;
3045
                    my $line = lc $subfield->[1];
3046
3047
                    # remove meaningless value in the field...
3048
                    $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g;
3049
3050
                    # ... and split in words
3051
                    foreach ( split / /, $line ) {
3052
                        next unless $_;    # skip  empty values (multiple spaces)
3053
                                           # if the entry is already here, improve weight
3054
3055
                        #                         warn "managing $_";
3056
                        if ( exists $result{$key}->{$_} && $result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/ ) {
3057
                            my $weight = $1 + 1;
3058
                            $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g;
3059
                            $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;";
3060
                        } else {
3061
3062
                            # get the value if it exist in the nozebra table, otherwise, create it
3063
                            $sth2->execute( $server, $key, $_ );
3064
                            my $existing_biblionumbers = $sth2->fetchrow;
3065
3066
                            # it exists
3067
                            if ($existing_biblionumbers) {
3068
                                $result{$key}->{"$_"} = $existing_biblionumbers;
3069
                                my $weight = defined $1 ? $1 + 1 : 1;
3070
                                $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g;
3071
                                $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;";
3072
3073
                                # create a new ligne for this entry
3074
                            } else {
3075
3076
                                #                             warn "INSERT : $server / $key / $_";
3077
                                $dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname=' . $dbh->quote($key) . ',value=' . $dbh->quote($_) );
3078
                                $result{$key}->{"$_"} .= "$biblionumber,$title-1;";
3079
                            }
3080
                        }
3081
                    }
3082
                }
3083
            }
3084
3085
            # the subfield is not indexed, store it in __RAW__ index anyway
3086
            unless ($indexed) {
3087
                my $line = lc $subfield->[1];
3088
                $line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g;
3089
3090
                # ... and split in words
3091
                foreach ( split / /, $line ) {
3092
                    next unless $_;    # skip  empty values (multiple spaces)
3093
                                       # if the entry is already here, improve weight
3094
                    my $tmpstr = $result{'__RAW__'}->{"$_"} || "";
3095
                    if ( $tmpstr =~ /$biblionumber,\Q$title\E\-(\d+);/ ) {
3096
                        my $weight = $1 + 1;
3097
                        $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//;
3098
                        $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;";
3099
                    } else {
3100
3101
                        # get the value if it exist in the nozebra table, otherwise, create it
3102
                        $sth2->execute( $server, '__RAW__', $_ );
3103
                        my $existing_biblionumbers = $sth2->fetchrow;
3104
3105
                        # it exists
3106
                        if ($existing_biblionumbers) {
3107
                            $result{'__RAW__'}->{"$_"} = $existing_biblionumbers;
3108
                            my $weight = ( $1 ? $1 : 0 ) + 1;
3109
                            $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//;
3110
                            $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;";
3111
3112
                            # create a new ligne for this entry
3113
                        } else {
3114
                            $dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ',  indexname="__RAW__",value=' . $dbh->quote($_) );
3115
                            $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-1;";
3116
                        }
3117
                    }
3118
                }
3119
            }
3120
        }
3121
    }
3122
    return %result;
3123
}
3124
3125
=head2 _find_value
2724
=head2 _find_value
3126
2725
3127
  ($indicators, $value) = _find_value($tag, $subfield, $record,$encoding);
2726
  ($indicators, $value) = _find_value($tag, $subfield, $record,$encoding);
Lines 3640-3646 sub ModBiblioMarc { Link Here
3640
    $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?");
3239
    $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?");
3641
    $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber );
3240
    $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber );
3642
    $sth->finish;
3241
    $sth->finish;
3643
    ModZebra( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record );
3242
    AddToIndexQueue( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record );
3644
    return $biblionumber;
3243
    return $biblionumber;
3645
}
3244
}
3646
3245
(-)a/C4/ImportBatch.pm (+1 lines)
Lines 25-30 use C4::Koha; Link Here
25
use C4::Biblio;
25
use C4::Biblio;
26
use C4::Items;
26
use C4::Items;
27
use C4::Charset;
27
use C4::Charset;
28
use Koha::Utils;
28
29
29
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
30
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
30
31
(-)a/C4/Items.pm (-5 / +7 lines)
Lines 34-39 require C4::Reserves; Link Here
34
use C4::Charset;
34
use C4::Charset;
35
use C4::Acquisition;
35
use C4::Acquisition;
36
use List::MoreUtils qw/any/;
36
use List::MoreUtils qw/any/;
37
use Koha::Utils;
38
use Koha::Search;
37
use Data::Dumper; # used as part of logging item record changes, not just for
39
use Data::Dumper; # used as part of logging item record changes, not just for
38
                  # debugging; so please don't remove this
40
                  # debugging; so please don't remove this
39
41
Lines 268-274 sub AddItem { Link Here
268
	my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
270
	my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
269
    $item->{'itemnumber'} = $itemnumber;
271
    $item->{'itemnumber'} = $itemnumber;
270
272
271
    ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver", undef, undef );
273
    AddToIndexQueue( $item->{biblionumber}, "specialUpdate", "biblioserver", undef, undef );
272
   
274
   
273
    logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
275
    logaction("CATALOGUING", "ADD", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
274
    
276
    
Lines 519-525 sub ModItem { Link Here
519
521
520
    # request that bib be reindexed so that searching on current
522
    # request that bib be reindexed so that searching on current
521
    # item status is possible
523
    # item status is possible
522
    ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
524
    AddToIndexQueue( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
523
525
524
    logaction("CATALOGUING", "MODIFY", $itemnumber, Dumper($item)) if C4::Context->preference("CataloguingLog");
526
    logaction("CATALOGUING", "MODIFY", $itemnumber, Dumper($item)) if C4::Context->preference("CataloguingLog");
525
}
527
}
Lines 582-588 sub DelItem { Link Here
582
584
583
    # get the MARC record
585
    # get the MARC record
584
    my $record = GetMarcBiblio($biblionumber);
586
    my $record = GetMarcBiblio($biblionumber);
585
    ModZebra( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
587
    AddToIndexQueue( $biblionumber, "specialUpdate", "biblioserver", undef, undef );
586
588
587
    # backup the record
589
    # backup the record
588
    my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?");
590
    my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?");
Lines 2172-2179 sub MoveItemFromBiblio { Link Here
2172
    $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?");
2174
    $sth = $dbh->prepare("UPDATE items SET biblioitemnumber = ?, biblionumber = ? WHERE itemnumber = ? AND biblionumber = ?");
2173
    my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio);
2175
    my $return = $sth->execute($tobiblioitem, $tobiblio, $itemnumber, $frombiblio);
2174
    if ($return == 1) {
2176
    if ($return == 1) {
2175
        ModZebra( $tobiblio, "specialUpdate", "biblioserver", undef, undef );
2177
        AddToIndexQueue( $tobiblio, "specialUpdate", "biblioserver", undef, undef );
2176
        ModZebra( $frombiblio, "specialUpdate", "biblioserver", undef, undef );
2178
        AddToIndexQueue( $frombiblio, "specialUpdate", "biblioserver", undef, undef );
2177
	    # Checking if the item we want to move is in an order 
2179
	    # Checking if the item we want to move is in an order 
2178
        my $order = GetOrderFromItemnumber($itemnumber);
2180
        my $order = GetOrderFromItemnumber($itemnumber);
2179
	    if ($order) {
2181
	    if ($order) {
(-)a/C4/Labels/Label.pm (+1 lines)
Lines 11-16 use Data::Dumper; Link Here
11
use C4::Context;
11
use C4::Context;
12
use C4::Debug;
12
use C4::Debug;
13
use C4::Biblio;
13
use C4::Biblio;
14
use Koha::Utils;
14
15
15
BEGIN {
16
BEGIN {
16
    use version; our $VERSION = qv('1.0.0_1');
17
    use version; our $VERSION = qv('1.0.0_1');
(-)a/C4/Search.pm (-203 / +3 lines)
Lines 33-38 use C4::Debug; Link Here
33
use C4::Items;
33
use C4::Items;
34
use YAML;
34
use YAML;
35
use URI::Escape;
35
use URI::Escape;
36
use Koha::Search;
37
use Koha::Utils;
36
38
37
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
39
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
38
40
Lines 814-1021 sub _build_weighted_query { Link Here
814
    return $weighted_query;
816
    return $weighted_query;
815
}
817
}
816
818
817
=head2 getIndexes
818
819
Return an array with available indexes.
820
821
=cut
822
823
sub getIndexes{
824
    my @indexes = (
825
                    # biblio indexes
826
                    'ab',
827
                    'Abstract',
828
                    'acqdate',
829
                    'allrecords',
830
                    'an',
831
                    'Any',
832
                    'at',
833
                    'au',
834
                    'aub',
835
                    'aud',
836
                    'audience',
837
                    'auo',
838
                    'aut',
839
                    'Author',
840
                    'Author-in-order ',
841
                    'Author-personal-bibliography',
842
                    'Authority-Number',
843
                    'authtype',
844
                    'bc',
845
		    'Bib-level',
846
                    'biblionumber',
847
                    'bio',
848
                    'biography',
849
                    'callnum',
850
                    'cfn',
851
                    'Chronological-subdivision',
852
                    'cn-bib-source',
853
                    'cn-bib-sort',
854
                    'cn-class',
855
                    'cn-item',
856
                    'cn-prefix',
857
                    'cn-suffix',
858
                    'cpn',
859
                    'Code-institution',
860
                    'Conference-name',
861
                    'Conference-name-heading',
862
                    'Conference-name-see',
863
                    'Conference-name-seealso',
864
                    'Content-type',
865
                    'Control-number',
866
                    'copydate',
867
                    'Corporate-name',
868
                    'Corporate-name-heading',
869
                    'Corporate-name-see',
870
                    'Corporate-name-seealso',
871
                    'ctype',
872
                    'date-entered-on-file',
873
                    'Date-of-acquisition',
874
                    'Date-of-publication',
875
                    'Dewey-classification',
876
                    'EAN',
877
                    'extent',
878
                    'fic',
879
                    'fiction',
880
                    'Form-subdivision',
881
                    'format',
882
                    'Geographic-subdivision',
883
                    'he',
884
                    'Heading',
885
                    'Heading-use-main-or-added-entry',
886
                    'Heading-use-series-added-entry ',
887
                    'Heading-use-subject-added-entry',
888
                    'Host-item',
889
                    'id-other',
890
                    'Illustration-code',
891
                    'ISBN',
892
                    'isbn',
893
                    'ISSN',
894
                    'issn',
895
                    'itemtype',
896
                    'kw',
897
                    'Koha-Auth-Number',
898
                    'l-format',
899
                    'language',
900
                    'lc-card',
901
                    'LC-card-number',
902
                    'lcn',
903
                    'llength',
904
                    'ln',
905
                    'Local-classification',
906
                    'Local-number',
907
                    'Match-heading',
908
                    'Match-heading-see-from',
909
                    'Material-type',
910
                    'mc-itemtype',
911
                    'mc-rtype',
912
                    'mus',
913
                    'name',
914
                    'Music-number',
915
                    'Name-geographic',
916
                    'Name-geographic-heading',
917
                    'Name-geographic-see',
918
                    'Name-geographic-seealso',
919
                    'nb',
920
                    'Note',
921
                    'notes',
922
                    'ns',
923
                    'nt',
924
                    'pb',
925
                    'Personal-name',
926
                    'Personal-name-heading',
927
                    'Personal-name-see',
928
                    'Personal-name-seealso',
929
                    'pl',
930
                    'Place-publication',
931
                    'pn',
932
                    'popularity',
933
                    'pubdate',
934
                    'Publisher',
935
                    'Record-control-number',
936
                    'rcn',
937
                    'Record-type',
938
                    'rtype',
939
                    'se',
940
                    'See',
941
                    'See-also',
942
                    'sn',
943
                    'Stock-number',
944
                    'su',
945
                    'Subject',
946
                    'Subject-heading-thesaurus',
947
                    'Subject-name-personal',
948
                    'Subject-subdivision',
949
                    'Summary',
950
                    'Suppress',
951
                    'su-geo',
952
                    'su-na',
953
                    'su-to',
954
                    'su-ut',
955
                    'ut',
956
                    'UPC',
957
                    'Term-genre-form',
958
                    'Term-genre-form-heading',
959
                    'Term-genre-form-see',
960
                    'Term-genre-form-seealso',
961
                    'ti',
962
                    'Title',
963
                    'Title-cover',
964
                    'Title-series',
965
                    'Title-host',
966
                    'Title-uniform',
967
                    'Title-uniform-heading',
968
                    'Title-uniform-see',
969
                    'Title-uniform-seealso',
970
                    'totalissues',
971
                    'yr',
972
973
                    # items indexes
974
                    'acqsource',
975
                    'barcode',
976
                    'bc',
977
                    'branch',
978
                    'ccode',
979
                    'classification-source',
980
                    'cn-sort',
981
                    'coded-location-qualifier',
982
                    'copynumber',
983
                    'damaged',
984
                    'datelastborrowed',
985
                    'datelastseen',
986
                    'holdingbranch',
987
                    'homebranch',
988
                    'issues',
989
                    'item',
990
                    'itemnumber',
991
                    'itype',
992
                    'Local-classification',
993
                    'location',
994
                    'lost',
995
                    'materials-specified',
996
                    'mc-ccode',
997
                    'mc-itype',
998
                    'mc-loc',
999
                    'notforloan',
1000
                    'onloan',
1001
                    'price',
1002
                    'renewals',
1003
                    'replacementprice',
1004
                    'replacementpricedate',
1005
                    'reserves',
1006
                    'restricted',
1007
                    'stack',
1008
                    'stocknumber',
1009
                    'inv',
1010
                    'uri',
1011
                    'withdrawn',
1012
1013
                    # subject related
1014
                  );
1015
1016
    return \@indexes;
1017
}
1018
1019
=head2 buildQuery
819
=head2 buildQuery
1020
820
1021
( $error, $query,
821
( $error, $query,
Lines 1073-1079 sub buildQuery { Link Here
1073
    my $stopwords_removed;    # flag to determine if stopwords have been removed
873
    my $stopwords_removed;    # flag to determine if stopwords have been removed
1074
874
1075
    my $cclq       = 0;
875
    my $cclq       = 0;
1076
    my $cclindexes = getIndexes();
876
    my $cclindexes = GetIndexes();
1077
    if ( $query !~ /\s*ccl=/ ) {
877
    if ( $query !~ /\s*ccl=/ ) {
1078
        while ( !$cclq && $query =~ /(?:^|\W)([\w-]+)(,[\w-]+)*[:=]/g ) {
878
        while ( !$cclq && $query =~ /(?:^|\W)([\w-]+)(,[\w-]+)*[:=]/g ) {
1079
            my $dx = lc($1);
879
            my $dx = lc($1);
(-)a/C4/Serials.pm (+1 lines)
Lines 32-37 use C4::Search; Link Here
32
use C4::Letters;
32
use C4::Letters;
33
use C4::Log;    # logaction
33
use C4::Log;    # logaction
34
use C4::Debug;
34
use C4::Debug;
35
use Koha::Utils;
35
36
36
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
37
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
37
38
(-)a/Koha/Search.pm (+113 lines)
Line 0 Link Here
1
package Koha::Search;
2
3
# Copyright 2011 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::Search - Interface to bibliographic/authority record searching
23
24
=head1 SYNOPSIS
25
26
  use Koha::Search;
27
28
=head1 DESCRIPTION
29
30
Interface to Koha::Search::Engine functionality for bibliographic and authority
31
record searching.
32
33
=head1 FUNCTIONS
34
35
=cut
36
37
use strict;
38
use warnings;
39
require Exporter;
40
use C4::Context;
41
use Koha::Search::Engine;
42
43
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
44
45
46
BEGIN {
47
    $VERSION = 3.01;
48
    $DEBUG = ($ENV{DEBUG}) ? 1 : 0;
49
    our $search_engine = Koha::Search::Engine->new();
50
}
51
52
=head1 NAME
53
54
Koha::Search - Functions for searching the Koha catalog.
55
56
=head1 SYNOPSIS
57
58
See opac/opac-search.pl or catalogue/search.pl for example of usage
59
60
=head1 DESCRIPTION
61
62
This module provides searching functions for Koha's bibliographic databases
63
64
=head1 FUNCTIONS
65
66
=cut
67
68
69
@ISA    = qw(Exporter);
70
@EXPORT = qw(
71
    &AddToIndexQueue
72
    &GetIndexes
73
);
74
75
our $search_engine;
76
77
sub AddToIndexQueue {
78
    if (!(C4::Context->preference('SearchEngine')=~/IndexOff/i)){ # solr allows disabling indexing
79
        return $search_engine->add_to_index_queue( @_ );
80
    }
81
    return undef;
82
}
83
84
=head2 GetIndexes
85
86
  @indexes = GetIndexes;
87
88
Return a list of indexes provided by the active search engine
89
90
=cut
91
92
sub GetIndexes {
93
    return $search_engine->get_indexes( @_ );
94
}
95
96
=head2 EXPORT
97
98
AddToIndexQueue
99
GetIndexes
100
101
=head1 SEE ALSO
102
103
Koha::Search::Engine::Zebra
104
105
=head1 AUTHOR
106
107
Jared Camins-Esakov, C & P Bibliography Services, E<lt>jcamins@cpbibliography.comE<gt>
108
109
=cut
110
111
1;
112
113
__END__
(-)a/Koha/Search/Engine.pm (+114 lines)
Line 0 Link Here
1
package Koha::Search::Engine;
2
3
# Copyright 2011 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::Search::Engine - Base class for Koha search engine interfaces
23
24
=head1 SYNOPSIS
25
26
  use Koha::Search::Engine;
27
28
=head1 DESCRIPTION
29
30
Base class for Koha::Search::Engine::X. Subclasses need to provide the
31
following methods:
32
33
B<add_to_index_queue> - add the specified object to the index queue
34
35
B<get_indexes> - get a list of indexes provided by the search engine
36
37
=head1 FUNCTIONS
38
39
=cut
40
41
use strict;
42
use warnings;
43
use C4::Context;
44
45
BEGIN {
46
    our $VERSION = 3.01;
47
48
    my $engine_module = "Koha::Search::Engine::" . (C4::Context->preference("SearchEngine") || 'Zebra');
49
    eval "require $engine_module";
50
}
51
52
sub new {
53
    my $class = shift;
54
55
    my $self = { };
56
57
    my $engine_module = "Koha::Search::Engine::" . (C4::Context->preference("SearchEngine") || 'Zebra');
58
59
    $self->{'engine'} = $engine_module->new();
60
    bless $self, $class;
61
    return $self;
62
}
63
64
=head2 add_to_index_queue
65
66
  $search_engine->add_to_index_queue( $indexnumber, $op, $server);
67
68
$indexnumber is the id number of the object we want to index
69
70
$op is specialUpdate or delete, and is used to know what we want to do
71
72
$server is the server that we want to update
73
74
=cut
75
76
sub add_to_index_queue {
77
    my $self = shift;
78
79
    return $self->{'engine'}->add_to_index_queue(@_);
80
}
81
82
=head2 get_indexes
83
84
  @indexes = $search_engine->get_indexes;
85
86
Return a list of indexes provided by the active search engine
87
88
=cut
89
90
91
sub get_indexes {
92
    my $self = shift;
93
94
    return $self->{'engine'}->get_indexes(@_);
95
}
96
97
=head2 EXPORT
98
99
None by default.
100
101
=head1 SEE ALSO
102
103
Koha::Search
104
Koha::Search::Engine::Zebra
105
106
=head1 AUTHOR
107
108
Jared Camins-Esakov, C & P Bibliography Services, E<lt>jcamins@cpbibliography.comE<gt>
109
110
=cut
111
112
1;
113
114
__END__
(-)a/Koha/Search/Engine/Zebra.pm (+257 lines)
Line 0 Link Here
1
package Koha::Search::Engine::Zebra;
2
3
# Copyright 2011 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
23
use base qw(Koha::Search::Engine);
24
25
sub new {
26
    my $class = shift;
27
28
    my $self = { };
29
    bless $self, $class;
30
    return $self;
31
}
32
33
sub add_to_index_queue {
34
    my ( $self, $indexnumber, $op, $server) = @_;
35
    my $dbh = C4::Context->dbh;
36
#
37
# we use zebra, just fill zebraqueue table
38
#
39
    my $check_sql = "SELECT COUNT(*) FROM zebraqueue 
40
        WHERE server = ?
41
        AND   biblio_auth_number = ?
42
        AND   operation = ?
43
        AND   done = 0";
44
    my $check_sth = $dbh->prepare_cached($check_sql);
45
    $check_sth->execute( $server, $indexnumber, $op );
46
    my ($count) = $check_sth->fetchrow_array;
47
    $check_sth->finish();
48
    if ( $count == 0 ) {
49
        my $sth = $dbh->prepare("INSERT INTO zebraqueue  (biblio_auth_number,server,operation) VALUES(?,?,?)");
50
        $sth->execute( $indexnumber, $server, $op );
51
        $sth->finish;
52
    }
53
}
54
55
sub get_indexes {
56
    my @indexes = (
57
                    # biblio indexes
58
                    'ab',
59
                    'Abstract',
60
                    'acqdate',
61
                    'allrecords',
62
                    'an',
63
                    'Any',
64
                    'at',
65
                    'au',
66
                    'aub',
67
                    'aud',
68
                    'audience',
69
                    'auo',
70
                    'aut',
71
                    'Author',
72
                    'Author-in-order ',
73
                    'Author-personal-bibliography',
74
                    'Authority-Number',
75
                    'authtype',
76
                    'bc',
77
		    'Bib-level',
78
                    'biblionumber',
79
                    'bio',
80
                    'biography',
81
                    'callnum',
82
                    'cfn',
83
                    'Chronological-subdivision',
84
                    'cn-bib-source',
85
                    'cn-bib-sort',
86
                    'cn-class',
87
                    'cn-item',
88
                    'cn-prefix',
89
                    'cn-suffix',
90
                    'cpn',
91
                    'Code-institution',
92
                    'Conference-name',
93
                    'Conference-name-heading',
94
                    'Conference-name-see',
95
                    'Conference-name-seealso',
96
                    'Content-type',
97
                    'Control-number',
98
                    'copydate',
99
                    'Corporate-name',
100
                    'Corporate-name-heading',
101
                    'Corporate-name-see',
102
                    'Corporate-name-seealso',
103
                    'ctype',
104
                    'date-entered-on-file',
105
                    'Date-of-acquisition',
106
                    'Date-of-publication',
107
                    'Dewey-classification',
108
                    'EAN',
109
                    'extent',
110
                    'fic',
111
                    'fiction',
112
                    'Form-subdivision',
113
                    'format',
114
                    'Geographic-subdivision',
115
                    'he',
116
                    'Heading',
117
                    'Heading-use-main-or-added-entry',
118
                    'Heading-use-series-added-entry ',
119
                    'Heading-use-subject-added-entry',
120
                    'Host-item',
121
                    'id-other',
122
                    'Illustration-code',
123
                    'ISBN',
124
                    'isbn',
125
                    'ISSN',
126
                    'issn',
127
                    'itemtype',
128
                    'kw',
129
                    'Koha-Auth-Number',
130
                    'l-format',
131
                    'language',
132
                    'lc-card',
133
                    'LC-card-number',
134
                    'lcn',
135
                    'llength',
136
                    'ln',
137
                    'Local-classification',
138
                    'Local-number',
139
                    'Match-heading',
140
                    'Match-heading-see-from',
141
                    'Material-type',
142
                    'mc-itemtype',
143
                    'mc-rtype',
144
                    'mus',
145
                    'name',
146
                    'Music-number',
147
                    'Name-geographic',
148
                    'Name-geographic-heading',
149
                    'Name-geographic-see',
150
                    'Name-geographic-seealso',
151
                    'nb',
152
                    'Note',
153
                    'notes',
154
                    'ns',
155
                    'nt',
156
                    'pb',
157
                    'Personal-name',
158
                    'Personal-name-heading',
159
                    'Personal-name-see',
160
                    'Personal-name-seealso',
161
                    'pl',
162
                    'Place-publication',
163
                    'pn',
164
                    'popularity',
165
                    'pubdate',
166
                    'Publisher',
167
                    'Record-control-number',
168
                    'rcn',
169
                    'Record-type',
170
                    'rtype',
171
                    'se',
172
                    'See',
173
                    'See-also',
174
                    'sn',
175
                    'Stock-number',
176
                    'su',
177
                    'Subject',
178
                    'Subject-heading-thesaurus',
179
                    'Subject-name-personal',
180
                    'Subject-subdivision',
181
                    'Summary',
182
                    'Suppress',
183
                    'su-geo',
184
                    'su-na',
185
                    'su-to',
186
                    'su-ut',
187
                    'ut',
188
                    'UPC',
189
                    'Term-genre-form',
190
                    'Term-genre-form-heading',
191
                    'Term-genre-form-see',
192
                    'Term-genre-form-seealso',
193
                    'ti',
194
                    'Title',
195
                    'Title-cover',
196
                    'Title-series',
197
                    'Title-host',
198
                    'Title-uniform',
199
                    'Title-uniform-heading',
200
                    'Title-uniform-see',
201
                    'Title-uniform-seealso',
202
                    'totalissues',
203
                    'yr',
204
205
                    # items indexes
206
                    'acqsource',
207
                    'barcode',
208
                    'bc',
209
                    'branch',
210
                    'ccode',
211
                    'classification-source',
212
                    'cn-sort',
213
                    'coded-location-qualifier',
214
                    'copynumber',
215
                    'damaged',
216
                    'datelastborrowed',
217
                    'datelastseen',
218
                    'holdingbranch',
219
                    'homebranch',
220
                    'issues',
221
                    'item',
222
                    'itemnumber',
223
                    'itype',
224
                    'Local-classification',
225
                    'location',
226
                    'lost',
227
                    'materials-specified',
228
                    'mc-ccode',
229
                    'mc-itype',
230
                    'mc-loc',
231
                    'notforloan',
232
                    'onloan',
233
                    'price',
234
                    'renewals',
235
                    'replacementprice',
236
                    'replacementpricedate',
237
                    'reserves',
238
                    'restricted',
239
                    'stack',
240
                    'stocknumber',
241
                    'inv',
242
                    'uri',
243
                    'withdrawn',
244
245
                    # subject related
246
                  );
247
    return \@indexes;
248
}
249
250
1;
251
__END__
252
253
=head1 NAME
254
255
Koha::Search::Engine::Zebra - interface to Zebra as the search engine for Koha
256
257
=cut
(-)a/Koha/Utils.pm (+119 lines)
Line 0 Link Here
1
package Koha::Utils;
2
3
# Copyright 2011 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
use C4::Context;
23
24
use vars qw($VERSION @ISA @EXPORT);
25
26
BEGIN {
27
    our $VERSION = 3.01;
28
    our $DEBUG = ($ENV{DEBUG}) ? 1 : 0;
29
}
30
31
=head1 NAME
32
33
Koha::Utils - Various utility functions for accessing a Koha instance's
34
configuration
35
36
=head1 SYNOPSIS
37
38
  use Koha::Utils;
39
40
=head1 DESCRIPTION
41
42
Various high-level utility functions for getting information about a Koha
43
instance's configuration options, to complement the low-level functions in
44
Koha::Context.
45
46
47
=head1 FUNCTIONS
48
49
=cut
50
51
require Exporter;
52
@ISA = qw( Exporter );
53
@EXPORT = qw(
54
    &GetMarcFromKohaField
55
    &GetAuthType
56
);
57
58
59
60
=head2 GetMarcFromKohaField
61
62
  ($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode);
63
64
Returns the MARC fields & subfields mapped to the koha field 
65
for the given frameworkcode
66
67
=cut
68
69
sub GetMarcFromKohaField {
70
    my ( $kohafield, $frameworkcode ) = @_;
71
    return 0, 0 unless $kohafield and defined $frameworkcode;
72
    my $relations = C4::Context->marcfromkohafield;
73
    return ( $relations->{$frameworkcode}->{$kohafield}->[0], $relations->{$frameworkcode}->{$kohafield}->[1] );
74
}
75
76
=head2 GetAuthType 
77
78
  $result = &GetAuthType($authtypecode)
79
80
If the authority type specified by C<$authtypecode> exists,
81
returns a hashref of the type's fields.  If the type
82
does not exist, returns undef.
83
84
=cut
85
86
sub GetAuthType {
87
    my ($authtypecode) = @_;
88
    my $dbh=C4::Context->dbh;
89
    my $sth;
90
    if (defined $authtypecode){ # NOTE - in MARC21 framework, '' is a valid authority 
91
                                # type (FIXME but why?)
92
        $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
93
        $sth->execute($authtypecode);
94
        if (my $res = $sth->fetchrow_hashref) {
95
            return $res; 
96
        }
97
    }
98
    return;
99
}
100
101
102
=head2 EXPORT
103
104
GetMarcFromKohaField
105
GetAuthType
106
107
=head1 SEE ALSO
108
109
Koha::Context
110
111
=head1 AUTHOR
112
113
Jared Camins-Esakov, C & P Bibliography Services, E<lt>jcamins@cpbibliography.comE<gt>
114
115
=cut
116
117
1;
118
119
__END__
(-)a/acqui/addorderiso2709.pl (+1 lines)
Lines 45-50 use C4::Dates; Link Here
45
use C4::Suggestions;    # GetSuggestion
45
use C4::Suggestions;    # GetSuggestion
46
use C4::Branch;         # GetBranches
46
use C4::Branch;         # GetBranches
47
use C4::Members;
47
use C4::Members;
48
use Koha::Utils;
48
49
49
my $input = new CGI;
50
my $input = new CGI;
50
my ($template, $loggedinuser, $cookie) = get_template_and_user({
51
my ($template, $loggedinuser, $cookie) = get_template_and_user({
(-)a/acqui/neworderempty.pl (+1 lines)
Lines 87-92 use C4::Koha; Link Here
87
use C4::Branch;			# GetBranches
87
use C4::Branch;			# GetBranches
88
use C4::Members;
88
use C4::Members;
89
use C4::Search qw/FindDuplicate BiblioAddAuthorities/;
89
use C4::Search qw/FindDuplicate BiblioAddAuthorities/;
90
use Koha::Utils;
90
91
91
#needed for z3950 import:
92
#needed for z3950 import:
92
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
93
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
(-)a/authorities/authorities.pl (+1 lines)
Lines 30-35 use Date::Calc qw(Today); Link Here
30
use MARC::File::USMARC;
30
use MARC::File::USMARC;
31
use MARC::File::XML;
31
use MARC::File::XML;
32
use C4::Biblio;
32
use C4::Biblio;
33
use Koha::Utils;
33
use vars qw( $tagslib);
34
use vars qw( $tagslib);
34
use vars qw( $authorised_values_sth);
35
use vars qw( $authorised_values_sth);
35
use vars qw( $is_a_modif );
36
use vars qw( $is_a_modif );
(-)a/authorities/blinddetail-biblio-search.pl (+1 lines)
Lines 46-51 use C4::Output; Link Here
46
use CGI;
46
use CGI;
47
use MARC::Record;
47
use MARC::Record;
48
use C4::Koha;
48
use C4::Koha;
49
use Koha::Utils;
49
50
50
my $query = new CGI;
51
my $query = new CGI;
51
52
(-)a/authorities/detail-biblio-search.pl (+1 lines)
Lines 47-52 use C4::Output; Link Here
47
use CGI;
47
use CGI;
48
use MARC::Record;
48
use MARC::Record;
49
use C4::Koha;
49
use C4::Koha;
50
use Koha::Utils;
50
# use C4::Biblio;
51
# use C4::Biblio;
51
# use C4::Catalogue;
52
# use C4::Catalogue;
52
53
(-)a/catalogue/MARCdetail.pl (+1 lines)
Lines 58-63 use C4::Acquisition; Link Here
58
use C4::Members; # to use GetMember
58
use C4::Members; # to use GetMember
59
use C4::Serials;    #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
59
use C4::Serials;    #uses getsubscriptionsfrombiblionumber GetSubscriptionsFromBiblionumber
60
use C4::Search;		# enabled_staff_search_views
60
use C4::Search;		# enabled_staff_search_views
61
use Koha::Utils;
61
62
62
63
63
my $query        = new CGI;
64
my $query        = new CGI;
(-)a/cataloguing/addbiblio.pl (+1 lines)
Lines 35-40 use C4::Branch; # XXX subfield_is_koha_internal_p Link Here
35
use C4::ClassSource;
35
use C4::ClassSource;
36
use C4::ImportBatch;
36
use C4::ImportBatch;
37
use C4::Charset;
37
use C4::Charset;
38
use Koha::Utils;
38
39
39
use Date::Calc qw(Today);
40
use Date::Calc qw(Today);
40
use MARC::File::USMARC;
41
use MARC::File::USMARC;
(-)a/cataloguing/additem.pl (+1 lines)
Lines 31-36 use C4::Koha; # XXX subfield_is_koha_internal_p Link Here
31
use C4::Branch; # XXX subfield_is_koha_internal_p
31
use C4::Branch; # XXX subfield_is_koha_internal_p
32
use C4::ClassSource;
32
use C4::ClassSource;
33
use C4::Dates;
33
use C4::Dates;
34
use Koha::Utils;
34
use List::MoreUtils qw/any/;
35
use List::MoreUtils qw/any/;
35
36
36
use MARC::File::XML;
37
use MARC::File::XML;
(-)a/cataloguing/value_builder/barcode.pl (+1 lines)
Lines 22-27 use warnings; Link Here
22
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
22
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
23
23
24
use C4::Context;
24
use C4::Context;
25
use Koha::Utils;
25
require C4::Dates;
26
require C4::Dates;
26
27
27
my $DEBUG = 0;
28
my $DEBUG = 0;
(-)a/cataloguing/value_builder/dateaccessioned.pl (+1 lines)
Lines 19-24 Link Here
19
19
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
#use warnings; FIXME - Bug 2505
22
use Koha::Utils;
22
23
23
=head1
24
=head1
24
25
(-)a/circ/branchoverdues.pl (+1 lines)
Lines 28-33 use C4::Biblio; Link Here
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Debug;
29
use C4::Debug;
30
use C4::Branch;
30
use C4::Branch;
31
use Koha::Utils;
31
32
32
=head1 branchoverdues.pl
33
=head1 branchoverdues.pl
33
34
(-)a/installer/data/mysql/atomicupdate/bug_7430_add_searchengine_syspref (+8 lines)
Line 0 Link Here
1
#! /usr/bin/perl
2
use strict;
3
use warnings;
4
use C4::Context;
5
my $dbh=C4::Context->dbh;
6
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SearchEngine','Zebra','Chooses which search engine to use in Koha.','Zebra','Choice');");
7
$dbh->do("DELETE FROM systempreferences WHERE variable = 'NoZebra';");
8
print "Upgrade done (Configured bug 7430, added new SearchEngine syspref, removed NoZebra)\n";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 1-6 Link Here
1
Searching:
1
Searching:
2
    Features:
2
    Features:
3
        -
3
        -
4
            - pref: SearchEngine
5
            - Use the
6
              choices:
7
                  Zebra: Zebra
8
                  NoZebra: NoZebra
9
            - search engine in Koha.
10
        -
4
            - pref: NoZebra
11
            - pref: NoZebra
5
              choices:
12
              choices:
6
                  yes: "Don't use"
13
                  yes: "Don't use"
(-)a/misc/batchImportMARCWithBiblionumbers.pl (+1 lines)
Lines 14-19 BEGIN { Link Here
14
14
15
use C4::Context;
15
use C4::Context;
16
use C4::Biblio;
16
use C4::Biblio;
17
use Koha::Utils;
17
use MARC::Record;
18
use MARC::Record;
18
use MARC::File::USMARC;
19
use MARC::File::USMARC;
19
use MARC::File::XML;
20
use MARC::File::XML;
(-)a/misc/batchRebuildBiblioTables.pl (+1 lines)
Lines 16-21 BEGIN { Link Here
16
use MARC::Record;
16
use MARC::Record;
17
use C4::Context;
17
use C4::Context;
18
use C4::Biblio;
18
use C4::Biblio;
19
use Koha::Utils;
19
use Time::HiRes qw(gettimeofday);
20
use Time::HiRes qw(gettimeofday);
20
21
21
use Getopt::Long;
22
use Getopt::Long;
(-)a/misc/migration_tools/22_to_30/missing090field.pl (+1 lines)
Lines 15-20 BEGIN { Link Here
15
15
16
use C4::Context;
16
use C4::Context;
17
use C4::Biblio;
17
use C4::Biblio;
18
use Koha::Utils;
18
use MARC::Record;
19
use MARC::Record;
19
use MARC::File::USMARC;
20
use MARC::File::USMARC;
20
21
(-)a/misc/migration_tools/bulkmarcimport.pl (+1 lines)
Lines 17-22 use MARC::File::XML; Link Here
17
use MARC::Record;
17
use MARC::Record;
18
use MARC::Batch;
18
use MARC::Batch;
19
use MARC::Charset;
19
use MARC::Charset;
20
use Koha::Utils;
20
21
21
use C4::Context;
22
use C4::Context;
22
use C4::Biblio;
23
use C4::Biblio;
(-)a/misc/migration_tools/merge_authority.pl (+1 lines)
Lines 15-20 use C4::Context; Link Here
15
use C4::Search;
15
use C4::Search;
16
use C4::Biblio;
16
use C4::Biblio;
17
use C4::AuthoritiesMarc;
17
use C4::AuthoritiesMarc;
18
use Koha::Utils;
18
use Time::HiRes qw(gettimeofday);
19
use Time::HiRes qw(gettimeofday);
19
20
20
use Getopt::Long;
21
use Getopt::Long;
(-)a/misc/migration_tools/rebuild_nozebra.pl (-4 / +6 lines)
Lines 2-9 Link Here
2
2
3
use C4::Context;
3
use C4::Context;
4
use Getopt::Long;
4
use Getopt::Long;
5
use C4::Search;
5
use C4::Biblio;
6
use C4::Biblio;
6
use C4::AuthoritiesMarc;
7
use C4::AuthoritiesMarc;
8
use Koha::Utils;
7
9
8
use strict;
10
use strict;
9
#use warnings; FIXME - Bug 2505
11
#use warnings; FIXME - Bug 2505
Lines 76-82 $dbh->do("update systempreferences set value=1 where variable='NoZebra'"); Link Here
76
78
77
$dbh->do("truncate nozebra");
79
$dbh->do("truncate nozebra");
78
80
79
my %index = GetNoZebraIndexes();
81
my %index = GetIndexes();
80
82
81
if  (!%index || $sysprefs ) {
83
if  (!%index || $sysprefs ) {
82
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
84
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
Lines 94-100 if (!%index || $sysprefs ) { Link Here
94
        'subject' => '600*,601*,606*,610*',
96
        'subject' => '600*,601*,606*,610*',
95
        'dewey' => '676a',
97
        'dewey' => '676a',
96
        'host-item' => '995a,995c',\" where variable='NoZebraIndexes'");
98
        'host-item' => '995a,995c',\" where variable='NoZebraIndexes'");
97
        %index = GetNoZebraIndexes();
99
        %index = GetIndexes();
98
    } elsif (C4::Context->preference('marcflavour') eq 'MARC21') {
100
    } elsif (C4::Context->preference('marcflavour') eq 'MARC21') {
99
        $dbh->do("UPDATE systempreferences SET value=\"
101
        $dbh->do("UPDATE systempreferences SET value=\"
100
'title' => '130a,210a,222a,240a,243a,245a,245b,246a,246b,247a,247b,250a,250b,440a,830a',
102
'title' => '130a,210a,222a,240a,243a,245a,245b,246a,246b,247a,247b,250a,250b,440a,830a',
Lines 118-124 if (!%index || $sysprefs ) { Link Here
118
'collection' => '9528',
120
'collection' => '9528',
119
\"WHERE variable='NoZebraIndexes'");
121
\"WHERE variable='NoZebraIndexes'");
120
122
121
        %index = GetNoZebraIndexes();
123
        %index = GetIndexes();
122
    }
124
    }
123
}
125
}
124
$|=1;
126
$|=1;
Lines 254-260 while (my ($authid) = $sth->fetchrow) { Link Here
254
    
256
    
255
    my %index;
257
    my %index;
256
    # for authorities, the "title" is the $a mainentry
258
    # for authorities, the "title" is the $a mainentry
257
    my $authref = C4::AuthoritiesMarc::GetAuthType(C4::AuthoritiesMarc::GetAuthTypeCode($authid));
259
    my $authref = GetAuthType(C4::AuthoritiesMarc::GetAuthTypeCode($authid));
258
260
259
    warn "ERROR : authtype undefined for ".$record->as_formatted unless $authref;
261
    warn "ERROR : authtype undefined for ".$record->as_formatted unless $authref;
260
    my $title = $record->subfield($authref->{auth_tag_to_report},'a');
262
    my $title = $record->subfield($authref->{auth_tag_to_report},'a');
(-)a/misc/migration_tools/rebuild_zebra.pl (+1 lines)
Lines 10-15 use File::Path; Link Here
10
use C4::Biblio;
10
use C4::Biblio;
11
use C4::AuthoritiesMarc;
11
use C4::AuthoritiesMarc;
12
use C4::Items;
12
use C4::Items;
13
use Koha::Utils;
13
14
14
# 
15
# 
15
# script that checks zebradir structure & create directories & mandatory files if needed
16
# script that checks zebradir structure & create directories & mandatory files if needed
(-)a/opac/opac-MARCdetail.pl (+1 lines)
Lines 52-57 use MARC::Record; Link Here
52
use C4::Biblio;
52
use C4::Biblio;
53
use C4::Acquisition;
53
use C4::Acquisition;
54
use C4::Koha;
54
use C4::Koha;
55
use Koha::Utils;
55
56
56
my $query = new CGI;
57
my $query = new CGI;
57
58
(-)a/opac/opac-authoritiesdetail.pl (+1 lines)
Lines 46-51 use C4::Output; Link Here
46
use CGI;
46
use CGI;
47
use MARC::Record;
47
use MARC::Record;
48
use C4::Koha;
48
use C4::Koha;
49
use Koha::Utils;
49
50
50
51
51
my $query = new CGI;
52
my $query = new CGI;
(-)a/serials/serials-edit.pl (+1 lines)
Lines 72-77 use C4::Koha; Link Here
72
use C4::Output;
72
use C4::Output;
73
use C4::Context;
73
use C4::Context;
74
use C4::Serials;
74
use C4::Serials;
75
use Koha::Utils;
75
use List::MoreUtils qw/uniq/;
76
use List::MoreUtils qw/uniq/;
76
77
77
my $query           = CGI->new();
78
my $query           = CGI->new();
(-)a/svc/bib (+1 lines)
Lines 24-29 use warnings; Link Here
24
use CGI;
24
use CGI;
25
use C4::Auth qw/check_api_auth/;
25
use C4::Auth qw/check_api_auth/;
26
use C4::Biblio;
26
use C4::Biblio;
27
use Koha::Utils;
27
use XML::Simple;
28
use XML::Simple;
28
29
29
my $query = new CGI;
30
my $query = new CGI;
(-)a/svc/new_bib (+1 lines)
Lines 26-31 use C4::Auth qw/check_api_auth/; Link Here
26
use C4::Biblio;
26
use C4::Biblio;
27
use XML::Simple;
27
use XML::Simple;
28
use C4::Charset;
28
use C4::Charset;
29
use Koha::Utils;
29
30
30
my $query = new CGI;
31
my $query = new CGI;
31
binmode STDOUT, ":utf8";
32
binmode STDOUT, ":utf8";
(-)a/t/Koha_Search.t (+20 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!  
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
9
use Test::More tests => 1;
10
11
BEGIN {
12
        use_ok('Koha::Search');
13
}
14
15
my @indexes = GetIndexes();
16
# We should probably check that GetIndexes returns 'Subject' or some other
17
# similarly crucial index
18
19
# We should probably check that AddRecordToIndexingQueue works somehow or
20
# other
(-)a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm (-2 lines)
Lines 23-30 sub methods : Test( 1 ) { Link Here
23
                      ModAuthority 
23
                      ModAuthority 
24
                      GetAuthorityXML 
24
                      GetAuthorityXML 
25
                      GetAuthority 
25
                      GetAuthority 
26
                      GetAuthType 
27
                      AUTHhtml2marc 
28
                      FindDuplicateAuthority 
26
                      FindDuplicateAuthority 
29
                      BuildSummary
27
                      BuildSummary
30
                      BuildUnimarcHierarchies
28
                      BuildUnimarcHierarchies
(-)a/t/db_dependent/lib/KohaTest/Biblio/ModBiblio.pm (+1 lines)
Lines 8-13 use Test::More; Link Here
8
8
9
use C4::Biblio;
9
use C4::Biblio;
10
use C4::Items;
10
use C4::Items;
11
use Koha::Utils;
11
12
12
=head2 STARTUP METHODS
13
=head2 STARTUP METHODS
13
14
(-)a/t/db_dependent/lib/KohaTest/ImportBatch/BatchStageCommitRevert.pm (+1 lines)
Lines 9-14 use Test::More; Link Here
9
use C4::ImportBatch;
9
use C4::ImportBatch;
10
use C4::Matcher;
10
use C4::Matcher;
11
use C4::Biblio;
11
use C4::Biblio;
12
use Koha::Utils;
12
13
13
# define test records for various batches
14
# define test records for various batches
14
sub startup_60_make_test_records : Test( startup ) {
15
sub startup_60_make_test_records : Test( startup ) {
(-)a/tools/batchMod.pl (+1 lines)
Lines 33-38 use C4::BackgroundJob; Link Here
33
use C4::ClassSource;
33
use C4::ClassSource;
34
use C4::Dates;
34
use C4::Dates;
35
use C4::Debug;
35
use C4::Debug;
36
use Koha::Utils;
36
use MARC::File::XML;
37
use MARC::File::XML;
37
38
38
my $input = new CGI;
39
my $input = new CGI;
(-)a/tools/export.pl (-1 / +1 lines)
Lines 25-30 use C4::Biblio; # GetMarcBiblio GetXmlBiblio Link Here
25
use CGI;
25
use CGI;
26
use C4::Koha;    # GetItemTypes
26
use C4::Koha;    # GetItemTypes
27
use C4::Branch;  # GetBranches
27
use C4::Branch;  # GetBranches
28
use Koha::Utils;
28
29
29
my $query = new CGI;
30
my $query = new CGI;
30
my $op=$query->param("op") || '';
31
my $op=$query->param("op") || '';
31
- 

Return to bug 7430