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

(-)a/C4/Biblio.pm (-2 / +15 lines)
Lines 506-512 sub BiblioAutoLink { Link Here
506
506
507
=head2 LinkBibHeadingsToAuthorities
507
=head2 LinkBibHeadingsToAuthorities
508
508
509
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose]);
509
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose, $dont_auto_create]);
510
510
511
Links bib headings to authority records by checking
511
Links bib headings to authority records by checking
512
each authority-controlled field in the C<MARC::Record>
512
each authority-controlled field in the C<MARC::Record>
Lines 529-535 sub LinkBibHeadingsToAuthorities { Link Here
529
    my $frameworkcode = shift;
529
    my $frameworkcode = shift;
530
    my $allowrelink = shift;
530
    my $allowrelink = shift;
531
    my $verbose = shift;
531
    my $verbose = shift;
532
    my $dont_auto_create = shift;
532
    my %results;
533
    my %results;
534
    my $linker_default='C4::Linker::Default';
533
    if (!$bib) {
535
    if (!$bib) {
534
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
536
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
535
        return ( 0, {});
537
        return ( 0, {});
Lines 554-559 sub LinkBibHeadingsToAuthorities { Link Here
554
        }
556
        }
555
557
556
        my ( $authid, $fuzzy, $status ) = $linker->get_link($heading);
558
        my ( $authid, $fuzzy, $status ) = $linker->get_link($heading);
559
        if(defined $status){
560
            if ($status eq 'NO_CONNECTION' or $status eq 'SERVER_NOT_FOUND') {
561
                return 0, { error => $status };
562
            }
563
            elsif($status eq 'Z3950_SEARCH_EMPTY'){
564
                ( $authid, $fuzzy, $status ) = $linker_default->get_link($heading); 
565
            }
566
        }
557
        if ($authid) {
567
        if ($authid) {
558
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
568
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
559
              ->{ $heading->display_form() }++;
569
              ->{ $heading->display_form() }++;
Lines 574-582 sub LinkBibHeadingsToAuthorities { Link Here
574
                $results{'fuzzy'}->{ $heading->display_form() }++;
584
                $results{'fuzzy'}->{ $heading->display_form() }++;
575
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
585
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
576
            }
586
            }
577
            elsif ( C4::Context->preference('AutoCreateAuthorities') ) {
587
            elsif ( !$dont_auto_create && C4::Context->preference('AutoCreateAuthorities') ) {
578
                if ( _check_valid_auth_link( $current_link, $field ) ) {
588
                if ( _check_valid_auth_link( $current_link, $field ) ) {
579
                    $results{'linked'}->{ $heading->display_form() }++;
589
                    $results{'linked'}->{ $heading->display_form() }++;
590
                    push(@{$results{'details'}}, { tag => $field->tag(), authid => $authid, status => 'UNCHANGED'}) if $verbose;
580
                }
591
                }
581
                else {
592
                else {
582
                    $authid = AddAuthorityFromHeading($heading, $field, $bib);
593
                    $authid = AddAuthorityFromHeading($heading, $field, $bib);
Lines 648-653 sub AddAuthorityFromHeading { Link Here
648
    my $heading = shift;
659
    my $heading = shift;
649
    my $field = shift;
660
    my $field = shift;
650
    my $bib = shift;
661
    my $bib = shift;
662
    my $current_link = $field->subfield('9');
651
663
652
    if(!defined $heading || !defined $field || !defined $bib){
664
    if(!defined $heading || !defined $field || !defined $bib){
653
       return 0;
665
       return 0;
Lines 659-664 sub AddAuthorityFromHeading { Link Here
659
        $marcrecordauth->leader('     nz  a22     o  4500');
671
        $marcrecordauth->leader('     nz  a22     o  4500');
660
        SetMarcUnicodeFlag( $marcrecordauth, 'MARC21' );
672
        SetMarcUnicodeFlag( $marcrecordauth, 'MARC21' );
661
    }
673
    }
674
    $field->delete_subfield( code => '9' ) if defined $current_link;
662
    my $authfield =
675
    my $authfield =
663
      MARC::Field->new( $authtypedata->{auth_tag_to_report},
676
      MARC::Field->new( $authtypedata->{auth_tag_to_report},
664
        '', '', "a" => "" . $field->subfield('a') );
677
        '', '', "a" => "" . $field->subfield('a') );
(-)a/C4/Breeding.pm (+36 lines)
Lines 221-227 sub Z3950Search { Link Here
221
        $oResult[$_]->destroy();
221
        $oResult[$_]->destroy();
222
        $oConnection[$_]->destroy();
222
        $oConnection[$_]->destroy();
223
    }
223
    }
224
    @servers = ();
225
    foreach my $id (@id) {
226
        push @servers, {id => $id};
227
    }
224
228
229
    my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
230
    $pref_addnumber =~ s/\s+//g;
231
    if ($pref_addnumber){
232
        $template->param(
233
            additionalFields => '1',
234
        );
235
    }
225
    $template->param(
236
    $template->param(
226
        breeding_loop => \@breeding_loop,
237
        breeding_loop => \@breeding_loop,
227
        servers => \@servers,
238
        servers => \@servers,
Lines 340-345 sub _add_rowdata { Link Here
340
    }
351
    }
341
    $row->{date}//= $row->{date2};
352
    $row->{date}//= $row->{date2};
342
    $row->{isbn}=_isbn_replace($row->{isbn});
353
    $row->{isbn}=_isbn_replace($row->{isbn});
354
355
    my $pref_addnumber = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
356
    $pref_addnumber =~ s/\s+//g;
357
    my @addnumber_array = split /;/, $pref_addnumber;
358
    my @addnumberfields;
359
    foreach (@addnumber_array) {
360
        my $length = length($_);
361
        my $adTag = substr($_, 0, 3);
362
        my $row_field = 'field_'.$adTag;
363
        if ($record->field($adTag)) {
364
           my $field = $record->field($adTag);
365
           my $fieldContent='';
366
           if ($length > 3){
367
               my $adSubfield;
368
               for (my $i=0; $i<$length-3; $i++){
369
                  $adSubfield = substr($_, 3+$i, 1);
370
                  $fieldContent = $fieldContent.$field->subfield($adSubfield).' ';
371
               }
372
               push(@addnumberfields, $_);
373
               $row->{$_} = $fieldContent;
374
           }
375
        }
376
    }
377
378
    $row->{'addnumberfields'} = \@addnumberfields;
343
    return $row;
379
    return $row;
344
}
380
}
345
381
(-)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 351-357 sub getRecords { Link Here
351
# perform the search, create the results objects
351
# perform the search, create the results objects
352
# if this is a local search, use the $koha-query, if it's a federated one, use the federated-query
352
# if this is a local search, use the $koha-query, if it's a federated one, use the federated-query
353
        my $query_to_use = ($servers[$i] =~ /biblioserver/) ? $koha_query : $simple_query;
353
        my $query_to_use = ($servers[$i] =~ /biblioserver/) ? $koha_query : $simple_query;
354
355
        #$query_to_use = $simple_query if $scan;
354
        #$query_to_use = $simple_query if $scan;
356
        warn $simple_query if ( $scan and $DEBUG );
355
        warn $simple_query if ( $scan and $DEBUG );
357
356
(-)a/Koha/Logger.pm (-4 / +4 lines)
Lines 32-45 Koha::Log Link Here
32
32
33
use Modern::Perl;
33
use Modern::Perl;
34
34
35
use Log::Log4perl;
35
#use Log::Log4perl;
36
use Carp;
36
use Carp;
37
37
38
use C4::Context;
38
use C4::Context;
39
39
40
BEGIN {
40
#BEGIN {
41
    Log::Log4perl->wrapper_register(__PACKAGE__);
41
#   Log::Log4perl->wrapper_register(__PACKAGE__);
42
}
42
#}
43
43
44
=head2 get
44
=head2 get
45
45
(-)a/authorities/blinddetail-biblio-search.pl (-7 / +9 lines)
Lines 85-97 if ($authid) { Link Here
85
85
86
    # Get all values for each distinct subfield
86
    # Get all values for each distinct subfield
87
    my %subfields;
87
    my %subfields;
88
    for ( $field->subfields ) {
88
    if(defined $field){
89
        next if $_->[0] eq '9'; # $9 will be set with authid value
89
        for ( $field->subfields ) {
90
        my $letter = $_->[0];
90
            next if $_->[0] eq '9'; # $9 will be set with authid value
91
        next if defined $subfields{$letter};
91
            my $letter = $_->[0];
92
        my @values = $field->subfield($letter);
92
            next if defined $subfields{$letter};
93
        $subfields{$letter} = \@values;
93
            my @values = $field->subfield($letter);
94
    }
94
            $subfields{$letter} = \@values;
95
        }
95
96
96
    # Add all subfields to the subfield_loop
97
    # Add all subfields to the subfield_loop
97
    for( keys %subfields ) {
98
    for( keys %subfields ) {
Lines 141-146 if ($authid) { Link Here
141
        }
142
        }
142
    }
143
    }
143
}
144
}
145
}
144
else {
146
else {
145
    # authid is empty => the user want to empty the entry.
147
    # authid is empty => the user want to empty the entry.
146
    $template->param( "clear" => 1 );
148
    $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); 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 (+13 lines)
Lines 168-173 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
168
        <th>Author</th>
168
        <th>Author</th>
169
        <th>ISBN</th>
169
        <th>ISBN</th>
170
        <th>LCCN</th>
170
        <th>LCCN</th>
171
        [% IF additionalFields %]
172
        <th>Additional fields</th>
173
        [% END %]
171
        <th>Preview</th>
174
        <th>Preview</th>
172
		<th>&nbsp;</th>
175
		<th>&nbsp;</th>
173
    </tr></thead>
176
    </tr></thead>
Lines 180-185 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
180
            <td>[% breeding_loo.author %]</td>
183
            <td>[% breeding_loo.author %]</td>
181
            <td>[% breeding_loo.isbn %]</td>
184
            <td>[% breeding_loo.isbn %]</td>
182
            <td>[% breeding_loo.lccn %]</td>
185
            <td>[% breeding_loo.lccn %]</td>
186
            [% IF additionalFields %]
187
            <td>
188
               <dl>
189
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
190
                  <dt>[% addnumberfield %]:</dt>
191
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
192
                  [% END %]
193
               </dl>
194
            </td>
195
            [% END %]
183
            <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>
196
            <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>
184
			<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>
197
			<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>
185
198
(-)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 / +13 lines)
Lines 185-190 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
185
        <th>Edition</th>
185
        <th>Edition</th>
186
        <th>ISBN</th>
186
        <th>ISBN</th>
187
        <th>LCCN</th>
187
        <th>LCCN</th>
188
        % IF additionalFields %]
189
        <th>Additional fields</th>
190
        [% END %]
188
        <th>MARC</th>
191
        <th>MARC</th>
189
        <th>Card</th>
192
        <th>Card</th>
190
		<th>&nbsp;</th>
193
		<th>&nbsp;</th>
Lines 200-205 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
200
            <td>[% breeding_loo.edition %]</td>
203
            <td>[% breeding_loo.edition %]</td>
201
            <td>[% breeding_loo.isbn %]</td>
204
            <td>[% breeding_loo.isbn %]</td>
202
            <td>[% breeding_loo.lccn %]</td>
205
            <td>[% breeding_loo.lccn %]</td>
206
            [% IF additionalFields %]
207
            <td>
208
               <dl>
209
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
210
                  <dt>[% addnumberfield %]:</dt>
211
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
212
                  [% END %]
213
               </dl>
214
            </td>
215
            [% END %]
203
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
216
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
204
            <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>
217
            <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>
205
            <td><a href="#" onclick="Import([% breeding_loo.breedingid %],[% breeding_loo.biblionumber %]); return false">Import</a></td> 
218
            <td><a href="#" onclick="Import([% breeding_loo.breedingid %],[% breeding_loo.biblionumber %]); return false">Import</a></td> 
206
- 

Return to bug 11300