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

(-)a/C4/Biblio.pm (-12 / +26 lines)
Lines 115-120 use Koha::SearchEngine::Indexer; Link Here
115
use Koha::SimpleMARC;
115
use Koha::SimpleMARC;
116
use Koha::Libraries;
116
use Koha::Libraries;
117
use Koha::Util::MARC;
117
use Koha::Util::MARC;
118
use C4::Linker::Default;
118
119
119
=head1 NAME
120
=head1 NAME
120
121
Lines 643-649 sub BiblioAutoLink { Link Here
643
644
644
=head2 LinkBibHeadingsToAuthorities
645
=head2 LinkBibHeadingsToAuthorities
645
646
646
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $tagtolink,  $verbose]);
647
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $tagtolink, $dont_auto_create, $verbose]);
647
648
648
Links bib headings to authority records by checking
649
Links bib headings to authority records by checking
649
each authority-controlled field in the C<MARC::Record>
650
each authority-controlled field in the C<MARC::Record>
Lines 661-674 MARC record. Link Here
661
=cut
662
=cut
662
663
663
sub LinkBibHeadingsToAuthorities {
664
sub LinkBibHeadingsToAuthorities {
664
    my $linker        = shift;
665
    my $linker           = shift;
665
    my $bib           = shift;
666
    my $bib              = shift;
666
    my $frameworkcode = shift;
667
    my $frameworkcode    = shift;
667
    my $allowrelink   = shift;
668
    my $allowrelink      = shift;
668
    my $tagtolink     = shift;
669
    my $tagtolink        = shift;
669
    my $verbose       = shift;
670
    my $verbose          = shift;
671
    my $dont_auto_create = shift;
670
    my %results;
672
    my %results;
671
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
673
    my $linker_default = C4::Linker::Default->new();
674
    my $memory_cache   = Koha::Cache::Memory::Lite->get_instance();
672
675
673
    if ( !$bib ) {
676
    if ( !$bib ) {
674
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
677
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
Lines 696-702 sub LinkBibHeadingsToAuthorities { Link Here
696
            next;
699
            next;
697
        }
700
        }
698
701
699
        my ( $authid, $fuzzy, $match_count ) = $linker->get_link($heading);
702
        my ( $authid, $fuzzy, $match_count, $status ) = $linker->get_link($heading);
703
        if ( defined $status ) {
704
            if ( $status eq 'NO_CONNECTION' or $status eq 'SERVER_NOT_FOUND' ) {
705
                return 0, { error => $status };
706
            } elsif ( $status eq 'Z3950_SEARCH_EMPTY' ) {
707
                ( $authid, $fuzzy, $match_count, $status ) = $linker_default->get_link($heading);
708
            }
709
        }
700
        if ($authid) {
710
        if ($authid) {
701
            $results{ $fuzzy ? 'fuzzy' : 'linked' }->{ $heading->display_form() }++;
711
            $results{ $fuzzy ? 'fuzzy' : 'linked' }->{ $heading->display_form() }++;
702
            if ( defined $current_link and $current_link == $authid ) {
712
            if ( defined $current_link and $current_link == $authid ) {
Lines 710-717 sub LinkBibHeadingsToAuthorities { Link Here
710
            $field->delete_subfield( code => '9' ) if defined $current_link;
720
            $field->delete_subfield( code => '9' ) if defined $current_link;
711
            $field->add_subfields( '9', $authid );
721
            $field->add_subfields( '9', $authid );
712
            $num_headings_changed++;
722
            $num_headings_changed++;
713
            push( @{ $results{'details'} }, { tag => $field->tag(), authid => $authid, status => 'LOCAL_FOUND' } )
723
            push(
714
                if $verbose;
724
                @{ $results{'details'} },
725
                { tag => $field->tag(), authid => $authid, status => $status || 'LOCAL_FOUND' }
726
            ) if $verbose;
715
        } else {
727
        } else {
716
            my $authority_type =
728
            my $authority_type =
717
                $memory_cache->get_from_cache( "LinkBibHeadingsToAuthorities:AuthorityType:" . $heading->auth_type() );
729
                $memory_cache->get_from_cache( "LinkBibHeadingsToAuthorities:AuthorityType:" . $heading->auth_type() );
Lines 730-738 sub LinkBibHeadingsToAuthorities { Link Here
730
                    @{ $results{'details'} },
742
                    @{ $results{'details'} },
731
                    { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED' }
743
                    { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED' }
732
                ) if $verbose;
744
                ) if $verbose;
733
            } elsif ( C4::Context->preference('AutoCreateAuthorities') ) {
745
            } elsif ( !$dont_auto_create && C4::Context->preference('AutoCreateAuthorities') ) {
734
                if ( _check_valid_auth_link( $current_link, $field ) ) {
746
                if ( _check_valid_auth_link( $current_link, $field ) ) {
735
                    $results{'linked'}->{ $heading->display_form() }++;
747
                    $results{'linked'}->{ $heading->display_form() }++;
748
                    push( @{ $results{'details'} }, { tag => $field->tag(), authid => $authid, status => 'UNCHANGED' } )
749
                        if $verbose;
736
                } elsif ( $match_count > 1 ) {
750
                } elsif ( $match_count > 1 ) {
737
                    $results{'unlinked'}->{ $heading->display_form() }++;
751
                    $results{'unlinked'}->{ $heading->display_form() }++;
738
                    push(
752
                    push(
(-)a/C4/Linker/Z3950Server.pm (+319 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 Modern::Perl;
19
use Carp;
20
use MARC::Field;
21
use MARC::Record;
22
use C4::Context;
23
use C4::Heading;
24
use ZOOM;                   # For Z39.50 Searches
25
use C4::AuthoritiesMarc;    # For Authority addition
26
use C4::Log;                # logaction
27
use Koha::SearchEngine::Indexer;
28
29
use base qw(C4::Linker);
30
31
sub get_link {
32
    my $self        = shift;
33
    my $heading     = shift;
34
    my $behavior    = shift || 'default';
35
    my $search_form = $heading->search_form();
36
    my $authid;
37
    my $fuzzy       = 0;
38
    my $match_count = 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
    } else {
45
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'
50
                or $status eq 'Z3950_QUERY_ERROR'
51
                or $status eq 'NO_CONNECTION'
52
                or $status eq 'SERVER_NOT_FOUND' )
53
            {
54
                return $authid, $fuzzy, 0, $status;
55
            }
56
        }
57
        if ( !$authid ) {
58
59
            # look for matching authorities
60
            my $authorities = $heading->authorities(1);    # $skipmetadata = true
61
            $match_count = scalar @$authorities;
62
63
            if ( $behavior eq 'default' && $#{$authorities} >= 0 ) {
64
                $authid = $authorities->[0]->{'authid'};
65
            } elsif ( $behavior eq 'first' && $#{$authorities} >= 0 ) {
66
                $authid = $authorities->[0]->{'authid'};
67
                $fuzzy  = $#{$authorities} > 0;
68
            } elsif ( $behavior eq 'last' && $#{$authorities} >= 0 ) {
69
                $authid = $authorities->[ $#{$authorities} ]->{'authid'};
70
                $fuzzy  = $#{$authorities} > 0;
71
            }
72
73
            if ( !defined $authid && $self->{'broader_headings'} ) {
74
                my $field     = $heading->field();
75
                my @subfields = $field->subfields();
76
                if ( scalar @subfields > 1 ) {
77
                    pop @subfields;
78
                    $field->replace_with(
79
                        MARC::Field->new(
80
                            $field->tag,
81
                            $field->indicator(1),
82
                            $field->indicator(2),
83
                            map { $_[0] => $_[1] } @subfields
84
                        )
85
                    );
86
                    ( $authid, $fuzzy ) = $self->get_link(
87
                        C4::Heading->new_from_bib_field($field),
88
                        $behavior
89
                    );
90
                }
91
            }
92
        }
93
        if ( $self->{'local_first'} && !$authid ) {
94
            ( $authid, undef, $status ) = $self->getZ3950Authority($heading);
95
        }
96
97
        $self->{'cache'}->{$search_form}->{'cached'} = 1;
98
        $self->{'cache'}->{$search_form}->{'authid'} = $authid;
99
        $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
100
    }
101
    return $self->SUPER::_handle_auth_limit($authid), $fuzzy, $match_count, $status;
102
}
103
104
sub update_cache {
105
    my $self        = shift;
106
    my $heading     = shift;
107
    my $authid      = shift;
108
    my $search_form = $heading->search_form();
109
    my $fuzzy       = 0;
110
111
    $self->{'cache'}->{$search_form}->{'cached'} = 1;
112
    $self->{'cache'}->{$search_form}->{'authid'} = $authid;
113
    $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
114
}
115
116
sub flip_heading {
117
    my $self    = shift;
118
    my $heading = shift;
119
120
    # TODO: implement
121
}
122
123
=head1 getZ3950Authority
124
125
  ($authid, $record, $status) = $self->getZ3950Authority($heading);
126
127
  Do a Z39.50 search for the heading using the $conn ZOOM::Connection object and the $heading Heading.
128
  The column origincode is used to check for duplicates.
129
  FIXME: Use thesaurus in search? As of Koha 3.8, the community stopped using them.
130
131
  RETURNS :
132
  $authid = the ID of the local copy of the authority record that was found. undef if nothing was found.
133
  $record = the MARC record of the found authority.
134
  $status = A string with additional informations on the search status (Z3950_CREATED, Z3950_UPDATED, Z3950_QUERY_ERROR, Z3950_SEARCH_ERROR)
135
136
=cut
137
138
sub getZ3950Authority {
139
    my $self    = shift;
140
    my $heading = shift;
141
142
    # Try to find a match on the Z39.50 server if LinkerZ3950Server is set
143
    if ( C4::Context->preference('LinkerZ3950Server') ) {
144
        unless ( $self->{'conn'} ) {
145
            my $sth = C4::Context->dbh->prepare("select * from z3950servers where servername=?");
146
            $sth->execute( C4::Context->preference('LinkerZ3950Server') );
147
            my $server = $sth->fetchrow_hashref or undef;
148
            $sth->finish;
149
150
            if ($server) {
151
                my $options = ZOOM::Options->new();
152
                $options->option(
153
                    'cclfile' => C4::Context->new()->{"config"}->{"serverinfo"}->{"authorityserver"}->{"ccl2rpn"} );
154
                $options->option( 'elementSetName',        'F' );
155
                $options->option( 'async',                 0 );
156
                $options->option( 'databaseName',          $server->{db} );
157
                $options->option( 'user',                  $server->{userid} )   if $server->{userid};
158
                $options->option( 'password',              $server->{password} ) if $server->{password};
159
                $options->option( 'preferredRecordSyntax', $server->{syntax} );
160
                $self->{'conn'} = create ZOOM::Connection($options);
161
                eval { $self->{'conn'}->connect( $server->{host}, $server->{port} ) };
162
163
                if ($@) {
164
                    return ( undef, undef, 'NO_CONNECTION' );
165
                }
166
            } else {
167
                return ( undef, undef, 'SERVER_NOT_FOUND' );
168
            }
169
        }
170
    } else {
171
        return;
172
    }
173
    my $query  = qq(Match-Heading,do-not-truncate,ext="$heading->{'search_form'}");
174
    my $zquery = eval { ZOOM::Query::CCL2RPN->new( $query, $self->{'conn'} ) };
175
    if ($@) {
176
        warn $query . "\n" . $@;
177
        return ( undef, undef, 'Z3950_QUERY_ERROR' );
178
    }
179
180
    # Try to send the search query to the server.
181
    my $rs = eval { $self->{'conn'}->search($zquery) };
182
    if ($@) {
183
        warn $query . "\n" . $@;
184
        return ( undef, undef, 'Z3950_SEARCH_EMPTY' );
185
    }
186
187
    # If authorities are found, select the first valid one for addition in the local authority table.
188
    my $record;
189
    if ( $rs->size() != 0 ) {
190
        $record = MARC::Record::new_from_usmarc( $rs->record(0)->raw() );
191
    } else {
192
        return ( undef, undef, 'Z3950_SEARCH_ERROR' );
193
    }
194
    $rs->destroy();
195
    $zquery->destroy();
196
197
    # If a valid authority was found, add it in the local authority database.
198
    if ($record) {
199
        my $dbh = C4::Context->dbh;
200
201
        my $authtypecode = C4::AuthoritiesMarc::GuessAuthTypeCode($record);
202
        my $authId;
203
204
        # Use the control number to prevent the creation of duplicate authorities.
205
        my $controlNumber = $record->field('970')->subfield('0');
206
        my $sthExist      = $dbh->prepare("SELECT authid FROM auth_header WHERE origincode =?");
207
        $sthExist->execute($controlNumber) or die $sthExist->errstr;
208
        ($authId) = $sthExist->fetchrow;
209
        $sthExist->finish;
210
211
        #------------------------------------------------------------------------------------------
212
        # Corrections and verifications before insertion
213
        my $format;
214
        my $leader = '     nz  a22     o  4500';    # Leader for incomplete MARC21 record
215
216
        if ( uc( C4::Context->preference('marcflavour') ) eq 'UNIMARC' ) {
217
            $format = 'UNIMARCAUTH';
218
        } else {
219
            $format = 'MARC21';
220
        }
221
222
        if ( $format eq "MARC21" ) {
223
            if ( !$record->leader ) {
224
                $record->leader($leader);
225
            }
226
            if ( !$record->field('003') ) {
227
                $record->insert_fields_ordered( MARC::Field->new( '003', C4::Context->preference('MARCOrgCode') ) );
228
            }
229
            my $time = POSIX::strftime( "%Y%m%d%H%M%S", localtime );
230
            if ( !$record->field('005') ) {
231
                $record->insert_fields_ordered( MARC::Field->new( '005', $time . ".0" ) );
232
            }
233
            my $date = POSIX::strftime( "%y%m%d", localtime );
234
            if ( !$record->field('008') ) {
235
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
                } else {
241
                    $default_008 = substr( $default_008, 0, 34 );
242
                }
243
                $record->insert_fields_ordered( MARC::Field->new( '008', $date . $default_008 ) );
244
            }
245
            if ( !$record->field('040') ) {
246
                $record->insert_fields_ordered(
247
                    MARC::Field->new(
248
                        '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
            } elsif ( $record->field('100') ) {
262
                $record->field('100')->update( 'a' => $date . "afrey50      ba0" );
263
            } else {
264
                $record->append_fields(
265
                    MARC::Field->new(
266
                        '100', ' ', ' '
267
                        , 'a' => $date . "afrey50      ba0"
268
                    )
269
                );
270
            }
271
        }
272
        my ( $auth_type_tag, $auth_type_subfield ) = C4::AuthoritiesMarc::get_auth_type_location($authtypecode);
273
        if ( !$authId and $format eq "MARC21" ) {
274
275
            # only need to do this fix when modifying an existing authority
276
            C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location( $record, $auth_type_tag, $auth_type_subfield );
277
        }
278
        if ( my $field = $record->field($auth_type_tag) ) {
279
            $field->update( $auth_type_subfield => $authtypecode );
280
        } else {
281
            $record->add_fields( $auth_type_tag, '', '', $auth_type_subfield => $authtypecode );
282
        }
283
284
        #------------------------------------------------------------------------------------------
285
        if ($authId) {
286
            my $sth = $dbh->prepare("UPDATE auth_header SET authtypecode=?,marc=?,marcxml=? WHERE origincode =?");
287
            eval {
288
                $sth->execute( $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $controlNumber )
289
                    or die $sth->errstr;
290
            };
291
            $sth->finish;
292
            warn "Problem with authority $controlNumber : Cannot update" if $@;
293
            return                                                       if $@;
294
295
            my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
296
            $indexer->index_records( $authId, 'specialUpdate', "authorityserver", $record );
297
            return ( $authId, $record, 'Z3950_UPDATED' );
298
        } else {
299
            my $sth = $dbh->prepare(
300
                "INSERT INTO auth_header (datecreated,authtypecode,marc,marcxml,origincode) VALUES (NOW(),?,?,?,?)");
301
            eval {
302
                $sth->execute( $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $controlNumber )
303
                    or die $sth->errstr;
304
            };
305
            $sth->finish;
306
            warn "Problem with authority $controlNumber : Cannot insert" if $@;
307
            my $id = $dbh->{'mysql_insertid'};
308
            return if $@;
309
310
            logaction( "AUTHORITIES", "ADD", $id, "authority" ) if C4::Context->preference("AuthoritiesLog");
311
            my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
312
            $indexer->index_records( $id, 'specialUpdate', "authorityserver", $record );
313
            return ( $id, $record, 'Z3950_CREATED' );
314
        }
315
    }
316
    return;
317
}
318
319
1;
(-)a/installer/data/mysql/atomicupdate/bug_11300.pl (+17 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "11300",
5
    description =>
6
        "Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module",
7
    up => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do(
12
            q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('LinkerZ3950Server', '', NULL, 'Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module', 'free') }
13
        );
14
15
        say $out "Added system preference 'LinkerZ3950Server'";
16
    },
17
};
(-)a/installer/data/mysql/atomicupdate/skeleton.pl (-1 / +1 lines)
Lines 4-10 use Koha::Installer::Output qw(say_warning say_success say_info); Link Here
4
return {
4
return {
5
    bug_number  => "BUG_NUMBER",
5
    bug_number  => "BUG_NUMBER",
6
    description => "A single line description",
6
    description => "A single line description",
7
    up          => sub {
7
    up => sub {
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
10
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 391-396 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
391
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
391
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
392
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
392
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
393
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
393
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
394
('LinkerZ3950Server','',NULL,'Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module',''),
394
('ListOwnerDesignated', '', NULL, 'Designated list owner at patron deletion', 'Free'),
395
('ListOwnerDesignated', '', NULL, 'Designated list owner at patron deletion', 'Free'),
395
('ListOwnershipUponPatronDeletion', 'delete', 'delete|transfer', 'Defines the action on their public or shared lists when patron is deleted', 'Choice'),
396
('ListOwnershipUponPatronDeletion', 'delete', 'delete|transfer', 'Defines the action on their public or shared lists when patron is deleted', 'Choice'),
396
('LoadCheckoutsTableDelay','0','','Delay before auto-loading checkouts table on checkouts screen','Integer'),
397
('LoadCheckoutsTableDelay','0','','Delay before auto-loading checkouts table on checkouts screen','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (+5 lines)
Lines 115-120 Authorities: Link Here
115
                  Default: default
115
                  Default: default
116
                  FirstMatch: "first match"
116
                  FirstMatch: "first match"
117
                  LastMatch: "last match"
117
                  LastMatch: "last match"
118
                  Z3950Server: "Z39.50 Server"
118
            - linker module for matching headings to authority records.
119
            - linker module for matching headings to authority records.
119
        -
120
        -
120
            - "Set the following options for the authority linker:"
121
            - "Set the following options for the authority linker:"
Lines 149-154 Authorities: Link Here
149
                  1: Do
150
                  1: Do
150
                  0: "Don't"
151
                  0: "Don't"
151
            - attempt to automatically link headings when saving records in the cataloging module, obeys <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=LinkerRelink'>LinkerRelink</a> and <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CatalogModuleRelink'>CatalogModuleRelink</a> for record edits.
152
            - attempt to automatically link headings when saving records in the cataloging module, obeys <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=LinkerRelink'>LinkerRelink</a> and <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CatalogModuleRelink'>CatalogModuleRelink</a> for record edits.
153
        -
154
            - pref: LinkerZ3950Server
155
            - class: multi
156
            - Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module :
152
        -
157
        -
153
            - pref: LinkerConsiderThesaurus
158
            - pref: LinkerConsiderThesaurus
154
              default: no
159
              default: no
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-2 / +19 lines)
Lines 324-329 Link Here
324
            var message = '';
324
            var message = '';
325
            var field_class = 'no_matching_authority_field';
325
            var field_class = 'no_matching_authority_field';
326
            switch(heading.status) {
326
            switch(heading.status) {
327
                case 'Z3950_CREATED':
328
                    image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
329
                    message = _("A matching authority record was found on the Z39.50 server and was imported locally.");
330
                    field_class = 'matching_authority_field';
331
                    break;
332
                case 'Z3950_UPDATED':
333
                    image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
334
                    message = _("A matching authority record was found on the Z39.50 server and a local authority was updated.");
335
                    field_class = 'matching_authority_field';
336
                    break;
327
                case 'LOCAL_FOUND':
337
                case 'LOCAL_FOUND':
328
                    image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
338
                    image = '<i class="fa fa-check subfield_status matching_authority"</i> ';
329
                    message = _("A matching authority was found in the local database.");
339
                    message = _("A matching authority was found in the local database.");
Lines 377-383 Link Here
377
        $('#f').find('.tag').each(function() {
387
        $('#f').find('.tag').each(function() {
378
            var empty = true;
388
            var empty = true;
379
            $(this).find('.input_marceditor').each(function() {
389
            $(this).find('.input_marceditor').each(function() {
380
                if($(this).val() != '') {
390
                if(this.value != '') {
381
                    empty = false;
391
                    empty = false;
382
                    return false;
392
                    return false;
383
                }
393
                }
Lines 389-396 Link Here
389
399
390
        // Get all the form values to post via AJAX
400
        // Get all the form values to post via AJAX
391
        var form_data = {};
401
        var form_data = {};
402
        var i=0;
392
        $('#f').find(':input').each(function(){
403
        $('#f').find(':input').each(function(){
393
            form_data[this.name] = $(this).val();
404
            form_data[this.name] = this.value;
394
        });
405
        });
395
        delete form_data[''];
406
        delete form_data[''];
396
407
Lines 408-413 Link Here
408
                    case 'UNAUTHORIZED':
419
                    case 'UNAUTHORIZED':
409
                        alert(_("Error : You do not have the permissions necessary to use this functionality."));
420
                        alert(_("Error : You do not have the permissions necessary to use this functionality."));
410
                        break;
421
                        break;
422
                    case 'SERVER_NOT_FOUND':
423
                        alert(_("Error : The Z39.50 server configured in the 'LinkerZ3950Server' preference was not found in the Z39.50 servers list."));
424
                        break;
425
                    case 'NO_CONNECTION':
426
                        alert(_("Error : Could not connect to the Z39.50 server."));
427
                        break;
411
                    case 'OK':
428
                    case 'OK':
412
                        updateHeadingLinks(json.links);
429
                        updateHeadingLinks(json.links);
413
                        break;
430
                        break;
(-)a/svc/cataloguing/automatic_linker.pl (-8 / +5 lines)
Lines 35-51 my ($auth_status) = C4::Auth::check_cookie_auth( Link Here
35
        editcatalogue   => 'edit_catalogue'
35
        editcatalogue   => 'edit_catalogue'
36
    }
36
    }
37
);
37
);
38
if ( $auth_status ne "ok" ) {
39
    print to_json( { status => 'UNAUTHORIZED' } );
40
    exit 0;
41
}
42
38
43
# Link the biblio headings to authorities and return a json containing the status of all the links.
39
# Link the biblio headings to authorities and return a json containing the status of all the links.
44
# Example : {"status":"OK","links":[{"authid":"123","status":"LINK_CHANGED","tag":"650"}]}
40
# Example : {"status":"OK","links":[{"authid":"123","status":"LINK_CHANGED","tag":"650"}]}
45
#
41
#
46
# tag = the tag number of the field
42
# tag = the tag number of the field
47
# authid = the value of the $9 subfield for this tag
43
# authid = the value of the $9 subfield for this tag
48
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED)
44
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED, 3950_CREATED, Z3950_UPDATED)
49
45
50
my $json;
46
my $json;
51
47
Lines 57-63 my ( $headings_changed, $results ) = BiblioAutoLink( Link Here
57
    1
53
    1
58
);
54
);
59
55
60
$json->{status} = 'OK';
56
if ( !defined $results->{error} ) {
61
$json->{links}  = $results->{details} || '';
57
    $json->{status} = 'OK';
58
}
59
$json->{links} = $results->{details} || '';
62
60
63
print to_json($json);
61
print to_json($json);
64
- 

Return to bug 11300