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

(-)a/C4/AuthoritiesMarc.pm (-1 / +2 lines)
Lines 1180-1191 sub GetAuthorizedHeading { Link Here
1180
    unless ($record = $args->{record}) {
1180
    unless ($record = $args->{record}) {
1181
        return unless $args->{authid};
1181
        return unless $args->{authid};
1182
        $record = GetAuthority($args->{authid});
1182
        $record = GetAuthority($args->{authid});
1183
        return unless $record;
1183
    }
1184
    }
1184
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
1185
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
1185
# construct UNIMARC summary, that is quite different from MARC21 one
1186
# construct UNIMARC summary, that is quite different from MARC21 one
1186
# accepted form
1187
# accepted form
1187
        foreach my $field ($record->field('2..')) {
1188
        foreach my $field ($record->field('2..')) {
1188
            return $field->as_string('abcdefghijlmnopqrstuvwxyz');
1189
            return $field->as_string('abcdefghijklmnopqrstuvwxyz');
1189
        }
1190
        }
1190
    } else {
1191
    } else {
1191
        foreach my $field ($record->field('1..')) {
1192
        foreach my $field ($record->field('1..')) {
(-)a/C4/Biblio.pm (-4 / +4 lines)
Lines 662-674 safest place. Link Here
662
662
663
sub _check_valid_auth_link {
663
sub _check_valid_auth_link {
664
    my ( $authid, $field ) = @_;
664
    my ( $authid, $field ) = @_;
665
666
    require C4::AuthoritiesMarc;
665
    require C4::AuthoritiesMarc;
667
668
    my $authorized_heading =
666
    my $authorized_heading =
669
      C4::AuthoritiesMarc::GetAuthorizedHeading( { 'authid' => $authid } );
667
      C4::AuthoritiesMarc::GetAuthorizedHeading( { 'authid' => $authid } );
670
668
    my $field_value = $field->as_string('abcdefghijklmnopqrstuvwxyz');
671
   return ($field->as_string('abcdefghijklmnopqrstuvwxyz') eq $authorized_heading);
669
    return ( $authorized_heading
670
          && $field_value
671
          && $field_value eq $authorized_heading );
672
}
672
}
673
673
674
=head2 GetRecordValue
674
=head2 GetRecordValue
(-)a/C4/Heading.pm (-6 / +28 lines)
Lines 140-157 sub search_form { Link Here
140
140
141
=head2 authorities
141
=head2 authorities
142
142
143
  my $authorities = $heading->authorities([$skipmetadata]);
143
  my $authorities = $heading->authorities([$skipmetadata][$checkvalidity]);
144
144
145
Return a list of authority records for this 
145
Return a list of authority records for this heading.
146
heading. If passed a true value for $skipmetadata,
146
If passed a true value for $skipmetadata, SearchAuthorities will return only authids.
147
SearchAuthorities will return only authids.
147
If passed a true value for $checkvalidity, SearchAuthorities will check authorities validity.
148
148
149
=cut
149
=cut
150
150
151
sub authorities {
151
sub authorities {
152
    my $self         = shift;
152
    my $self         = shift;
153
    my $skipmetadata = shift;
153
    my $skipmetadata = shift;
154
    my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata );
154
    my $checkvalidity = shift;
155
    my ( $results, $total ) = _search( $self, 'match-heading', $skipmetadata, $checkvalidity );
155
    return $results;
156
    return $results;
156
}
157
}
157
158
Lines 181-186 sub _search { Link Here
181
    my $self         = shift;
182
    my $self         = shift;
182
    my $index        = shift || undef;
183
    my $index        = shift || undef;
183
    my $skipmetadata = shift || undef;
184
    my $skipmetadata = shift || undef;
185
    my $checkvalidity = shift || undef;
184
    my @marclist;
186
    my @marclist;
185
    my @and_or;
187
    my @and_or;
186
    my @excluding = [];
188
    my @excluding = [];
Lines 202-212 sub _search { Link Here
202
    #        push @value, $self->{'thesaurus'};
204
    #        push @value, $self->{'thesaurus'};
203
    #    }
205
    #    }
204
    require C4::AuthoritiesMarc;
206
    require C4::AuthoritiesMarc;
205
    return C4::AuthoritiesMarc::SearchAuthorities(
207
    my ( $authorities, $nbresults ) = C4::AuthoritiesMarc::SearchAuthorities(
206
        \@marclist, \@and_or, \@excluding, \@operator,
208
        \@marclist, \@and_or, \@excluding, \@operator,
207
        \@value,    0,        20,          $self->{'auth_type'},
209
        \@value,    0,        20,          $self->{'auth_type'},
208
        'AuthidAsc',         $skipmetadata
210
        'AuthidAsc',         $skipmetadata
209
    );
211
    );
212
213
    if ($checkvalidity) {
214
        my @authorities_cheked;
215
        foreach (@$authorities) {
216
            # TODO should be merged with C4::Biblio->_check_valid_auth_link
217
            my $authorized_heading = C4::AuthoritiesMarc::GetAuthorizedHeading(
218
                { authid => $_->{'authid'} } );
219
            my $field_value =
220
              $self->{'field'}->as_string('abcdefghijklmnopqrstuvwxyz');
221
            if (   $authorized_heading
222
                && $field_value
223
                && $field_value eq $authorized_heading )
224
            {
225
                push @authorities_cheked, $_;
226
            }
227
        }
228
        $authorities = \@authorities_cheked;
229
    }
230
231
    return $authorities;
210
}
232
}
211
233
212
=head1 INTERNAL FUNCTIONS
234
=head1 INTERNAL FUNCTIONS
(-)a/C4/Linker/Default.pm (-1 / +2 lines)
Lines 40-46 sub get_link { Link Here
40
    else {
40
    else {
41
41
42
        # look for matching authorities
42
        # look for matching authorities
43
        my $authorities = $heading->authorities(1);    # $skipmetadata = true
43
        # Skip meta datas and use CheckValidity from LinkerOptions
44
        my $authorities = $heading->authorities(1, $self->{'CheckValidity'});
44
45
45
        if ( $behavior eq 'default' && $#{$authorities} == 0 ) {
46
        if ( $behavior eq 'default' && $#{$authorities} == 0 ) {
46
            $authid = $authorities->[0]->{'authid'};
47
            $authid = $authorities->[0]->{'authid'};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (-2 / +1 lines)
Lines 57-63 Authorities: Link Here
57
            - Set the following options for the authority linker
57
            - Set the following options for the authority linker
58
            - pref: LinkerOptions
58
            - pref: LinkerOptions
59
              class: multi
59
              class: multi
60
            - (separate options with |)
60
            - (separate options with |). Use : CheckValidity.
61
        -
61
        -
62
            - pref: LinkerRelink
62
            - pref: LinkerRelink
63
              default: yes
63
              default: yes
64
- 

Return to bug 9072