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

(-)a/C4/Biblio.pm (-2 / +15 lines)
Lines 511-517 sub BiblioAutoLink { Link Here
511
511
512
=head2 LinkBibHeadingsToAuthorities
512
=head2 LinkBibHeadingsToAuthorities
513
513
514
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose]);
514
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose, $dont_auto_create]);
515
515
516
Links bib headings to authority records by checking
516
Links bib headings to authority records by checking
517
each authority-controlled field in the C<MARC::Record>
517
each authority-controlled field in the C<MARC::Record>
Lines 534-540 sub LinkBibHeadingsToAuthorities { Link Here
534
    my $frameworkcode = shift;
534
    my $frameworkcode = shift;
535
    my $allowrelink = shift;
535
    my $allowrelink = shift;
536
    my $verbose = shift;
536
    my $verbose = shift;
537
    my $dont_auto_create = shift;
537
    my %results;
538
    my %results;
539
    my $linker_default='C4::Linker::Default';
538
    if (!$bib) {
540
    if (!$bib) {
539
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
541
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
540
        return ( 0, {});
542
        return ( 0, {});
Lines 559-564 sub LinkBibHeadingsToAuthorities { Link Here
559
        }
561
        }
560
562
561
        my ( $authid, $fuzzy, $status ) = $linker->get_link($heading);
563
        my ( $authid, $fuzzy, $status ) = $linker->get_link($heading);
564
        if(defined $status){
565
            if ($status eq 'NO_CONNECTION' or $status eq 'SERVER_NOT_FOUND') {
566
                return 0, { error => $status };
567
            }
568
            elsif($status eq 'Z3950_SEARCH_EMPTY'){
569
                ( $authid, $fuzzy, $status ) = $linker_default->get_link($heading);
570
            }
571
        }
562
        if ($authid) {
572
        if ($authid) {
563
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
573
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
564
              ->{ $heading->display_form() }++;
574
              ->{ $heading->display_form() }++;
Lines 579-587 sub LinkBibHeadingsToAuthorities { Link Here
579
                $results{'fuzzy'}->{ $heading->display_form() }++;
589
                $results{'fuzzy'}->{ $heading->display_form() }++;
580
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
590
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
581
            }
591
            }
582
            elsif ( C4::Context->preference('AutoCreateAuthorities') ) {
592
            elsif ( !$dont_auto_create && C4::Context->preference('AutoCreateAuthorities') ) {
583
                if ( _check_valid_auth_link( $current_link, $field ) ) {
593
                if ( _check_valid_auth_link( $current_link, $field ) ) {
584
                    $results{'linked'}->{ $heading->display_form() }++;
594
                    $results{'linked'}->{ $heading->display_form() }++;
595
                    push(@{$results{'details'}}, { tag => $field->tag(), authid => $authid, status => 'UNCHANGED'}) if $verbose;
585
                }
596
                }
586
                else {
597
                else {
587
                    my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
598
                    my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
Lines 700-705 sub AddAuthorityFromHeading { Link Here
700
    my $heading = shift;
711
    my $heading = shift;
701
    my $field = shift;
712
    my $field = shift;
702
    my $bib = shift;
713
    my $bib = shift;
714
    my $current_link = $field->subfield('9');
703
715
704
    if(!defined $heading || !defined $field || !defined $bib){
716
    if(!defined $heading || !defined $field || !defined $bib){
705
       return 0;
717
       return 0;
Lines 711-716 sub AddAuthorityFromHeading { Link Here
711
        $marcrecordauth->leader('     nz  a22     o  4500');
723
        $marcrecordauth->leader('     nz  a22     o  4500');
712
        SetMarcUnicodeFlag( $marcrecordauth, 'MARC21' );
724
        SetMarcUnicodeFlag( $marcrecordauth, 'MARC21' );
713
    }
725
    }
726
    $field->delete_subfield( code => '9' ) if defined $current_link;
714
    my $authfield =
727
    my $authfield =
715
      MARC::Field->new( $authtypedata->{auth_tag_to_report},
728
      MARC::Field->new( $authtypedata->{auth_tag_to_report},
716
        '', '', "a" => "" . $field->subfield('a') );
729
        '', '', "a" => "" . $field->subfield('a') );
(-)a/C4/Breeding.pm (+36 lines)
Lines 219-225 sub Z3950Search { Link Here
219
        $oResult[$_]->destroy();
219
        $oResult[$_]->destroy();
220
        $oConnection[$_]->destroy();
220
        $oConnection[$_]->destroy();
221
    }
221
    }
222
    @servers = ();
223
    foreach my $id (@id) {
224
        push @servers, {id => $id};
225
    }
222
226
227
    my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
228
    $pref_addnumber =~ s/\s+//g;
229
    if ($pref_addnumber){
230
        $template->param(
231
            additionalFields => '1',
232
        );
233
    }
223
    $template->param(
234
    $template->param(
224
        breeding_loop => \@breeding_loop,
235
        breeding_loop => \@breeding_loop,
225
        servers => \@servers,
236
        servers => \@servers,
Lines 338-343 sub _add_rowdata { Link Here
338
    }
349
    }
339
    $row->{date}//= $row->{date2};
350
    $row->{date}//= $row->{date2};
340
    $row->{isbn}=_isbn_replace($row->{isbn});
351
    $row->{isbn}=_isbn_replace($row->{isbn});
352
353
    my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
354
    $pref_addnumber =~ s/\s+//g;
355
    my @addnumber_array = split /;/, $pref_addnumber;
356
    my @addnumberfields;
357
    foreach (@addnumber_array) {
358
        my $length = length($_);
359
        my $adTag = substr($_, 0, 3);
360
        my $row_field = 'field_'.$adTag;
361
        if ($record->field($adTag)) {
362
           my $field = $record->field($adTag);
363
           my $fieldContent='';
364
           if ($length > 3){
365
               my $adSubfield;
366
               for (my $i=0; $i<$length-3; $i++){
367
                  $adSubfield = substr($_, 3+$i, 1);
368
                  $fieldContent = $fieldContent.$field->subfield($adSubfield).' ';
369
               }
370
               push(@addnumberfields, $_);
371
               $row->{$_} = $fieldContent;
372
           }
373
        }
374
    }
375
376
    $row->{'addnumberfields'} = \@addnumberfields;
341
    return $row;
377
    return $row;
342
}
378
}
343
379
(-)a/C4/Linker/Z3950Server.pm (+313 lines)
Line 0 Link Here
1
package C4::Linker::Z3950Server;
2
3
# Copyright 2012 Frédérick Capovilla - Libéo
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use strict;
19
use warnings;
20
use Carp;
21
use MARC::Field;
22
use MARC::Record;
23
use C4::Context;
24
use C4::Heading;
25
use ZOOM; # For Z39.50 Searches
26
use C4::AuthoritiesMarc; # For Authority addition
27
use C4::Log; # logaction
28
29
use base qw(C4::Linker);
30
31
32
sub get_link {
33
    my $self        = shift;
34
    my $heading     = shift;
35
    my $behavior    = shift || 'default';
36
    my $search_form = $heading->search_form();
37
    my $authid;
38
    my $fuzzy = 0;
39
    my $status = '';
40
41
    if ( $self->{'cache'}->{$search_form}->{'cached'} ) {
42
        $authid = $self->{'cache'}->{$search_form}->{'authid'};
43
        $fuzzy  = $self->{'cache'}->{$search_form}->{'fuzzy'};
44
    }
45
    else {
46
        # Look for matching authorities on the Z39.50 server
47
        unless($self->{'local_first'}) {
48
            ($authid, undef, $status) = $self->getZ3950Authority($heading);
49
            if($status eq 'Z3950_SEARCH_ERROR' or
50
               $status eq 'Z3950_QUERY_ERROR' or
51
               $status eq 'NO_CONNECTION' or
52
               $status eq 'SERVER_NOT_FOUND') {
53
                return $authid, $fuzzy, $status;
54
            }
55
        }
56
        if(!$authid) {
57
            # look for matching authorities
58
            my $authorities = $heading->authorities(1);    # $skipmetadata = true
59
60
            if ( $behavior eq 'default' && $#{$authorities} == 0 ) {
61
                $authid = $authorities->[0]->{'authid'};
62
            }
63
            elsif ( $behavior eq 'first' && $#{$authorities} >= 0 ) {
64
                $authid = $authorities->[0]->{'authid'};
65
                $fuzzy  = $#{$authorities} > 0;
66
            }
67
            elsif ( $behavior eq 'last' && $#{$authorities} >= 0 ) {
68
                $authid = $authorities->[ $#{$authorities} ]->{'authid'};
69
                $fuzzy  = $#{$authorities} > 0;
70
            }
71
72
            if ( !defined $authid && $self->{'broader_headings'} ) {
73
                my $field     = $heading->field();
74
                my @subfields = $field->subfields();
75
                if ( scalar @subfields > 1 ) {
76
                    pop @subfields;
77
                    $field->replace_with(
78
                        MARC::Field->new(
79
                            $field->tag,
80
                            $field->indicator(1),
81
                            $field->indicator(2),
82
                            map { $_[0] => $_[1] } @subfields
83
                        )
84
                    );
85
                    ( $authid, $fuzzy ) =
86
                      $self->get_link( C4::Heading->new_from_bib_field($field),
87
                        $behavior );
88
                }
89
            }
90
        }
91
        if($self->{'local_first'} && !$authid) {
92
            ($authid, undef, $status) = $self->getZ3950Authority($heading);
93
        }
94
95
        $self->{'cache'}->{$search_form}->{'cached'} = 1;
96
        $self->{'cache'}->{$search_form}->{'authid'} = $authid;
97
        $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
98
    }
99
    return $self->SUPER::_handle_auth_limit($authid), $fuzzy, $status;
100
}
101
sub update_cache {
102
    my $self        = shift;
103
    my $heading     = shift;
104
    my $authid      = shift;
105
    my $search_form = $heading->search_form();
106
    my $fuzzy = 0;
107
108
    $self->{'cache'}->{$search_form}->{'cached'} = 1;
109
    $self->{'cache'}->{$search_form}->{'authid'} = $authid;
110
    $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
111
}
112
sub flip_heading {
113
    my $self    = shift;
114
    my $heading = shift;
115
116
    # TODO: implement
117
}
118
119
120
=head1 getZ3950Authority
121
122
  ($authid, $record, $status) = $self->getZ3950Authority($heading);
123
124
  Do a Z39.50 search for the heading using the $conn ZOOM::Connection object and the $heading Heading.
125
  The column origincode is used to check for duplicates.
126
  FIXME: Use thesaurus in search? As of Koha 3.8, the community stopped using them.
127
128
  RETURNS :
129
  $authid = the ID of the local copy of the authority record that was found. undef if nothing was found.
130
  $record = the MARC record of the found authority.
131
  $status = A string with additional informations on the search status (Z3950_CREATED, Z3950_UPDATED, Z3950_QUERY_ERROR, Z3950_SEARCH_ERROR)
132
133
=cut
134
135
sub getZ3950Authority {
136
    my $self = shift;
137
    my $heading = shift;
138
139
    # Try to find a match on the Z39.50 server if LinkerZ3950Server is set
140
    if(C4::Context->preference('LinkerZ3950Server')) {
141
        unless($self->{'conn'}) {
142
            my $sth = C4::Context->dbh->prepare("select * from z3950servers where servername=?");
143
            $sth->execute(C4::Context->preference('LinkerZ3950Server'));
144
            my $server = $sth->fetchrow_hashref or undef;
145
            $sth->finish;
146
            if($server) {
147
                my $options = new ZOOM::Options();
148
                $options->option('cclfile' => C4::Context->ModZebrations('authorityserver')->{"ccl2rpn"});
149
                $options->option('elementSetName', 'F');
150
                $options->option('async', 0);
151
                $options->option('databaseName', $server->{db});
152
                $options->option('user',         $server->{userid}  ) if $server->{userid};
153
                $options->option('password',     $server->{password}) if $server->{password};
154
                $options->option('preferredRecordSyntax', $server->{syntax});
155
                $self->{'conn'} = create ZOOM::Connection($options);
156
                eval{ $self->{'conn'}->connect( $server->{host}, $server->{port} ) };
157
                if($@) {
158
                    return (undef, undef, 'NO_CONNECTION');
159
                }
160
            }
161
            else {
162
                return (undef, undef, 'SERVER_NOT_FOUND');
163
            }
164
        }
165
    }
166
    else {
167
        return;
168
    }
169
        my $query =qq(Personal-name,do-not-truncate,ext="$heading->{'search_form'}");
170
    my $zquery = eval{ new ZOOM::Query::CCL2RPN($query, $self->{'conn'}) };
171
    if($@) {
172
        warn $query . "\n" . $@;
173
        return (undef, undef, 'Z3950_QUERY_ERROR');
174
    }
175
176
    # Try to send the search query to the server.
177
    my $rs = eval{ $self->{'conn'}->search($zquery) };
178
    if($@){
179
        warn $query . "\n" . $@;
180
        return (undef, undef, 'Z3950_SEARCH_EMPTY');
181
    }
182
183
    # If authorities are found, select the first valid one for addition in the local authority table.
184
    my $record;
185
    if($rs->size() != 0) {
186
        $record = MARC::Record::new_from_usmarc($rs->record(0)->raw());
187
    }else{
188
        return (undef, undef, 'Z3950_SEARCH_ERROR');
189
    }
190
    $rs->destroy();
191
    $zquery->destroy();
192
193
    # If a valid authority was found, add it in the local authority database.
194
    if($record) {
195
        my $dbh=C4::Context->dbh;
196
197
        my $authtypecode = C4::AuthoritiesMarc::GuessAuthTypeCode($record);
198
        my $authId;
199
200
        # Use the control number to prevent the creation of duplicate authorities.
201
        my $controlNumber = $record->field('970')->subfield('0');
202
        my $sthExist=$dbh->prepare("SELECT authid FROM auth_header WHERE origincode =?");
203
        $sthExist->execute($controlNumber) or die $sthExist->errstr;
204
        ($authId) = $sthExist->fetchrow;
205
        $sthExist->finish;
206
207
        #------------------------------------------------------------------------------------------
208
        # Corrections and verifications before insertion
209
        my $format;
210
        my $leader='     nz  a22     o  4500';# Leader for incomplete MARC21 record
211
212
        if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC') {
213
            $format= 'UNIMARCAUTH';
214
        }
215
        else {
216
            $format= 'MARC21';
217
        }
218
219
        if ($format eq "MARC21") {
220
            if (!$record->leader) {
221
                $record->leader($leader);
222
            }
223
            if (!$record->field('003')) {
224
                $record->insert_fields_ordered(
225
                        MARC::Field->new('003',C4::Context->preference('MARCOrgCode'))
226
                        );
227
            }
228
            my $time=POSIX::strftime("%Y%m%d%H%M%S",localtime);
229
            if (!$record->field('005')) {
230
                $record->insert_fields_ordered(
231
                        MARC::Field->new('005',$time.".0")
232
                        );
233
            }
234
            my $date=POSIX::strftime("%y%m%d",localtime);
235
            if (!$record->field('008')) {
236
                # Get a valid default value for field 008
237
                my $default_008 = C4::Context->preference('MARCAuthorityControlField008');
238
                if(!$default_008 or length($default_008)<34) {
239
                    $default_008 = '|| aca||aabn           | a|a     d';
240
                }
241
                else {
242
                    $default_008 = substr($default_008,0,34);
243
                }
244
                $record->insert_fields_ordered( MARC::Field->new('008',$date.$default_008) );
245
            }
246
            if (!$record->field('040')) {
247
                $record->insert_fields_ordered(
248
                    MARC::Field->new('040','','',
249
                        'a' => C4::Context->preference('MARCOrgCode'),
250
                        'c' => C4::Context->preference('MARCOrgCode')
251
                    )
252
                );
253
            }
254
        }
255
        if ($format eq "UNIMARCAUTH") {
256
            $record->leader("     nx  j22             ") unless ($record->leader());
257
            my $date=POSIX::strftime("%Y%m%d",localtime);
258
            if (my $string=$record->subfield('100',"a")){
259
                $string=~s/fre50/frey50/;
260
                $record->field('100')->update('a'=>$string);
261
            }
262
            elsif ($record->field('100')){
263
                $record->field('100')->update('a'=>$date."afrey50      ba0");
264
            } else {
265
                $record->append_fields(
266
                    MARC::Field->new('100',' ',' '
267
                        ,'a'=>$date."afrey50      ba0")
268
                );
269
            }
270
        }
271
        my ($auth_type_tag, $auth_type_subfield) = C4::AuthoritiesMarc::get_auth_type_location($authtypecode);
272
        if (!$authId and $format eq "MARC21") {
273
        # only need to do this fix when modifying an existing authority
274
            C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($record, $auth_type_tag, $auth_type_subfield);
275
        }
276
        if (my $field=$record->field($auth_type_tag)){
277
            $field->update($auth_type_subfield=>$authtypecode);
278
        }
279
        else {
280
            $record->add_fields($auth_type_tag,'','', $auth_type_subfield=>$authtypecode);
281
        }
282
        #------------------------------------------------------------------------------------------
283
        if ($authId) {
284
            my $oldRecord=C4::AuthoritiesMarc::GetAuthority($authId);
285
286
            my $sth=$dbh->prepare("UPDATE auth_header SET authtypecode=?,marc=?,marcxml=? WHERE origincode =?");
287
            eval { $sth->execute($authtypecode,$record->as_usmarc,$record->as_xml_record($format),$controlNumber) or die $sth->errstr; };
288
            $sth->finish;
289
            warn "Problem with authority $controlNumber : Cannot update" if $@;
290
            $dbh->commit unless $dbh->{AutoCommit};
291
            return if $@;
292
293
            C4::Biblio::ModZebra($authId,'linkerUpdate',"authorityserver",$oldRecord,$record);
294
            return ($authId, $record, 'Z3950_UPDATED');
295
        }
296
        else {
297
            my $sth=$dbh->prepare("INSERT INTO auth_header (datecreated,authtypecode,marc,marcxml,origincode) VALUES (NOW(),?,?,?,?)");
298
            eval { $sth->execute($authtypecode,$record->as_usmarc,$record->as_xml_record($format),$controlNumber) or die $sth->errstr; };
299
            $sth->finish;
300
            warn "Problem with authority $controlNumber : Cannot insert" if $@;
301
            my $id = $dbh->{'mysql_insertid'};
302
            $dbh->commit unless $dbh->{AutoCommit};
303
            return if $@;
304
305
            logaction( "AUTHORITIES", "ADD", $id, "authority" ) if C4::Context->preference("AuthoritiesLog");
306
            C4::Biblio::ModZebra($id,'linkerUpdate',"authorityserver",undef,$record);
307
            return ($id, $record, 'Z3950_CREATED');
308
        }
309
    }
310
    return ;
311
}
312
313
1;
(-)a/C4/Search.pm (-1 lines)
Lines 352-358 sub getRecords { Link Here
352
# perform the search, create the results objects
352
# perform the search, create the results objects
353
# if this is a local search, use the $koha-query, if it's a federated one, use the federated-query
353
# if this is a local search, use the $koha-query, if it's a federated one, use the federated-query
354
        my $query_to_use = ($servers[$i] =~ /biblioserver/) ? $koha_query : $simple_query;
354
        my $query_to_use = ($servers[$i] =~ /biblioserver/) ? $koha_query : $simple_query;
355
356
        #$query_to_use = $simple_query if $scan;
355
        #$query_to_use = $simple_query if $scan;
357
        warn $simple_query if ( $scan and $DEBUG );
356
        warn $simple_query if ( $scan and $DEBUG );
358
357
(-)a/Koha/Logger.pm (-4 / +4 lines)
Lines 36-49 Koha::Logger Link Here
36
36
37
use Modern::Perl;
37
use Modern::Perl;
38
38
39
use Log::Log4perl;
39
#use Log::Log4perl;
40
use Carp;
40
use Carp;
41
41
42
use C4::Context;
42
use C4::Context;
43
43
44
BEGIN {
44
#BEGIN {
45
    Log::Log4perl->wrapper_register(__PACKAGE__);
45
#   Log::Log4perl->wrapper_register(__PACKAGE__);
46
}
46
#}
47
47
48
=head2 get
48
=head2 get
49
49
(-)a/authorities/blinddetail-biblio-search.pl (-7 / +9 lines)
Lines 83-95 if ($authid) { Link Here
83
83
84
    # Get all values for each distinct subfield
84
    # Get all values for each distinct subfield
85
    my %subfields;
85
    my %subfields;
86
    for ( $field->subfields ) {
86
    if(defined $field){
87
        next if $_->[0] eq '9'; # $9 will be set with authid value
87
        for ( $field->subfields ) {
88
        my $letter = $_->[0];
88
            next if $_->[0] eq '9'; # $9 will be set with authid value
89
        next if defined $subfields{$letter};
89
            my $letter = $_->[0];
90
        my @values = $field->subfield($letter);
90
            next if defined $subfields{$letter};
91
        $subfields{$letter} = \@values;
91
            my @values = $field->subfield($letter);
92
    }
92
            $subfields{$letter} = \@values;
93
        }
93
94
94
    # Add all subfields to the subfield_loop
95
    # Add all subfields to the subfield_loop
95
    for( keys %subfields ) {
96
    for( keys %subfields ) {
Lines 139-144 if ($authid) { Link Here
139
        }
140
        }
140
    }
141
    }
141
}
142
}
143
}
142
else {
144
else {
143
    # authid is empty => the user want to empty the entry.
145
    # authid is empty => the user want to empty the entry.
144
    $template->param( "clear" => 1 );
146
    $template->param( "clear" => 1 );
(-)a/cataloguing/automatic_linker.pl (-4 / +11 lines)
Lines 43-49 if ( $auth_status ne "ok" ) { Link Here
43
#
43
#
44
# tag = the tag number of the field
44
# tag = the tag number of the field
45
# authid = the value of the $9 subfield for this tag
45
# authid = the value of the $9 subfield for this tag
46
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED)
46
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED,3950_CREATED, Z3950_UPDATED)
47
47
48
my $json;
48
my $json;
49
49
Lines 51-56 my $record = TransformHtmlToMarc($input,1); Link Here
51
51
52
my $linker_module =
52
my $linker_module =
53
  "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
53
  "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
54
my $linker_default='C4::Linker::Default';
54
eval { eval "require $linker_module"; };
55
eval { eval "require $linker_module"; };
55
if ($@) {
56
if ($@) {
56
    $linker_module = 'C4::Linker::Default';
57
    $linker_module = 'C4::Linker::Default';
Lines 65-74 my $linker = $linker_module->new( Link Here
65
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities(
66
my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities(
66
    $linker, $record,
67
    $linker, $record,
67
    $input->param('frameworkcode'),
68
    $input->param('frameworkcode'),
68
    C4::Context->preference("CatalogModuleRelink") || '', 1
69
    C4::Context->preference("CatalogModuleRelink") || '', 1, 1
69
);
70
);
70
71
71
$json->{status} = 'OK';
72
if(defined $results->{error}) {
72
$json->{links} = $results->{details} || '';
73
    $json->{links} = $results->{details} || '';
74
    $json->{status} = $results->{error};
73
75
76
}
77
else {
78
    $json->{status} = 'OK';
79
    $json->{links} = $results->{details} || '';
80
}
74
print to_json($json);
81
print to_json($json);
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
10
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
9
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
11
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
12
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
13
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt (-1 / +15 lines)
Lines 134-139 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
134
        <th>Author</th>
134
        <th>Author</th>
135
        <th>ISBN</th>
135
        <th>ISBN</th>
136
        <th>LCCN</th>
136
        <th>LCCN</th>
137
        [% IF additionalFields %]
138
        <th>Additional fields</th>
139
        [% END %]
137
        <th>Preview</th>
140
        <th>Preview</th>
138
		<th>&nbsp;</th>
141
		<th>&nbsp;</th>
139
    </tr></thead>
142
    </tr></thead>
Lines 148-154 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
148
            <td>[% breeding_loo.lccn %]</td>
151
            <td>[% breeding_loo.lccn %]</td>
149
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
152
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
150
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
153
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
151
154
            [% IF additionalFields %]
155
            <td>
156
               <dl>
157
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
158
                  <dt>[% addnumberfield %]:</dt>
159
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
160
                  [% END %]
161
               </dl>
162
            </td>
163
            [% END %]
164
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" rel="gb_page_center[600,500]">Card</a></td>
165
			<td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Order</a></td>
152
        </tr>
166
        </tr>
153
        [% END %]
167
        [% END %]
154
    [% END %]</tbody>
168
    [% END %]</tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (+5 lines)
Lines 58-63 Authorities: Link Here
58
                  Default: Default
58
                  Default: Default
59
                  FirstMatch: "First Match"
59
                  FirstMatch: "First Match"
60
                  LastMatch: "Last Match"
60
                  LastMatch: "Last Match"
61
                  Z3950Server: "Z39.50 Server"
61
            - linker module for matching headings to authority records.
62
            - linker module for matching headings to authority records.
62
        -
63
        -
63
            - Set the following options for the authority linker
64
            - Set the following options for the authority linker
Lines 85-87 Authorities: Link Here
85
                  yes: Do
86
                  yes: Do
86
                  no: "Do not"
87
                  no: "Do not"
87
            - automatically relink headings that have previously been linked when saving records in the cataloging module.
88
            - automatically relink headings that have previously been linked when saving records in the cataloging module.
89
        -
90
            - pref: LinkerZ3950Server
91
            - class: multi
92
            - Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module :
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 224-229 Cataloging: Link Here
224
                  yes: "do"
224
                  yes: "do"
225
                  no: "don't"
225
                  no: "don't"
226
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
226
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
227
        -
228
            - Determines the MARC field/subfields
229
            - pref: AdditionalFieldsInZ3950ResultSearch
230
            - "are displayed in 'Additional fields' column in the result of a search Z3950 (use semicolon as delimiter ex: <code>082ab</code>;<code>090ab</code>)"
227
    Exporting:
231
    Exporting:
228
        -
232
        -
229
            - Include following fields when exporting BibTeX,
233
            - Include following fields when exporting BibTeX,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-1 / +16 lines)
Lines 257-262 function updateHeadingLinks(links) { Link Here
257
        var message = '';
257
        var message = '';
258
        var field_color = '#FFAAAA';
258
        var field_color = '#FFAAAA';
259
        switch(heading.status) {
259
        switch(heading.status) {
260
            case 'Z3950_CREATED':
261
                image = 'approve.gif';
262
                message = _("A matching authority record was found on the Z39.50 server and was imported locally.");
263
                field_color = '#99FF99';
264
                break;
265
            case 'Z3950_UPDATED':
266
                image = 'approve.gif';
267
                message = _("A matching authority record was found on the Z39.50 server and a local authority was updated.");
268
                field_color = '#99FF99';
269
                break;
260
            case 'LOCAL_FOUND':
270
            case 'LOCAL_FOUND':
261
                image = 'approve.gif';
271
                image = 'approve.gif';
262
                message = _("A matching authority was found in the local database.");
272
                message = _("A matching authority was found in the local database.");
Lines 323-329 function AutomaticLinker() { Link Here
323
        form_data[this.name] = $(this).val();
333
        form_data[this.name] = $(this).val();
324
    });
334
    });
325
    delete form_data[''];
335
    delete form_data[''];
326
327
    // Send the data to automatic_linker.pl
336
    // Send the data to automatic_linker.pl
328
    $.ajax({
337
    $.ajax({
329
        url:'/cgi-bin/koha/cataloguing/automatic_linker.pl',
338
        url:'/cgi-bin/koha/cataloguing/automatic_linker.pl',
Lines 338-343 function AutomaticLinker() { Link Here
338
                case 'UNAUTHORIZED':
347
                case 'UNAUTHORIZED':
339
                    alert(_("Error : You do not have the permissions necessary to use this functionality."));
348
                    alert(_("Error : You do not have the permissions necessary to use this functionality."));
340
                    break;
349
                    break;
350
                case 'SERVER_NOT_FOUND':
351
                    alert(_("Error : The Z39.50 server configured in the 'LinkerZ3950Server' preference was not found in the Z39.50 servers list."));
352
                    break;
353
                case 'NO_CONNECTION':
354
                    alert(_("Error : Could not connect to the Z39.50 server."));
355
                    break;
341
                case 'OK':
356
                case 'OK':
342
                    updateHeadingLinks(json.links);
357
                    updateHeadingLinks(json.links);
343
                    break;
358
                    break;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (-1 / +16 lines)
Lines 143-148 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
143
        <th>Edition</th>
143
        <th>Edition</th>
144
        <th>ISBN</th>
144
        <th>ISBN</th>
145
        <th>LCCN</th>
145
        <th>LCCN</th>
146
        % IF additionalFields %]
147
        <th>Additional fields</th>
148
        [% END %]
146
        <th>MARC</th>
149
        <th>MARC</th>
147
        <th>Card</th>
150
        <th>Card</th>
148
		<th>&nbsp;</th>
151
		<th>&nbsp;</th>
Lines 161-166 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
161
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
164
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
162
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
165
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
163
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
166
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
167
            [% IF additionalFields %]
168
            <td>
169
               <dl>
170
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
171
                  <dt>[% addnumberfield %]:</dt>
172
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
173
                  [% END %]
174
               </dl>
175
            </td>
176
            [% END %]
177
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
178
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
179
            <td><a href="#" onclick="Import([% breeding_loo.breedingid %],[% breeding_loo.biblionumber %]); return false">Import</a></td> 
164
        </tr>
180
        </tr>
165
        [% END %]
181
        [% END %]
166
    [% END %]</tbody>
182
    [% END %]</tbody>
167
- 

Return to bug 11300