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

(-)a/C4/AuthoritiesMarc.pm (+31 lines)
Lines 700-711 sub AddAuthority { Link Here
700
700
701
    my $heading = $authority->heading_object( { record => $record } );
701
    my $heading = $authority->heading_object( { record => $record } );
702
702
703
    my $origincode = CalculateOriginCode( $record, $authtypecode );
704
703
    # Update
705
    # Update
704
    $authority->update(
706
    $authority->update(
705
        {
707
        {
706
            authtypecode => $authtypecode,
708
            authtypecode => $authtypecode,
707
            marcxml      => $record->as_xml_record($format),
709
            marcxml      => $record->as_xml_record($format),
708
            heading      => $heading ? $heading->display_form : '',
710
            heading      => $heading ? $heading->display_form : '',
711
            origincode   => $origincode,
709
        }
712
        }
710
    );
713
    );
711
714
Lines 1269-1274 sub GetAuthorizedHeading { Link Here
1269
    return;
1272
    return;
1270
}
1273
}
1271
1274
1275
=head2 CalculateOriginCode
1276
1277
    Finds the auth_header.origincode from the given MARC Authorities Record for the given MARC Authorities Framework
1278
1279
=cut
1280
1281
sub CalculateOriginCode {
1282
    my ( $record, $authtypecode ) = @_;
1283
1284
    my ( $tagfield, $tagsubfield ) = GetAuthMARCFromKohaField( 'auth_header.origincode', $authtypecode );
1285
    if ( not( defined($tagfield) && defined($tagsubfield) ) || not( $record->subfield( $tagfield, $tagsubfield ) ) ) {
1286
        if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
1287
            return
1288
                   $record->subfield( '040', 'c' )
1289
                || $record->subfield( '040', 'a' )
1290
                || $record->subfield( '024', '2' )
1291
                || $record->field('003')
1292
                || '';
1293
        } else {
1294
            warn "KohaToMARCMapping for 'auth_header.origincode' not set for '"
1295
                . C4::Context->preference('marcflavour')
1296
                . "' and don't know what fallbacks to use.";
1297
            return '';
1298
        }
1299
    }
1300
    return $record->subfield( $tagfield, $tagsubfield );
1301
}
1302
1272
=head2 CompareFieldWithAuthority
1303
=head2 CompareFieldWithAuthority
1273
1304
1274
  $match = &CompareFieldWithAuthority({ field => $field, authid => $authid })
1305
  $match = &CompareFieldWithAuthority({ field => $field, authid => $authid })
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (+1 lines)
Lines 260-265 sub search_auth_compat { Link Here
260
            # Turn the resultset into a hash
260
            # Turn the resultset into a hash
261
            $result{authtype}     = $authtype ? $authtype->authtypetext : $authtypecode;
261
            $result{authtype}     = $authtype ? $authtype->authtypetext : $authtypecode;
262
            $result{reported_tag} = $reported_tag;
262
            $result{reported_tag} = $reported_tag;
263
            $result{origincode}   = C4::AuthoritiesMarc::CalculateOriginCode( $marc, $authtypecode );
263
264
264
            if ( C4::Context->preference('ShowHeadingUse') ) {
265
            if ( C4::Context->preference('ShowHeadingUse') ) {
265
266
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt (+2 lines)
Lines 85-90 Link Here
85
            <table>
85
            <table>
86
                <tr>
86
                <tr>
87
                    <th>Summary</th>
87
                    <th>Summary</th>
88
                    <th>Source</th>
88
                    <th>Heading type</th>
89
                    <th>Heading type</th>
89
                    <th>Used</th>
90
                    <th>Used</th>
90
                    [% IF Koha.Preference('ShowHeadingUse') %]
91
                    [% IF Koha.Preference('ShowHeadingUse') %]
Lines 102-107 Link Here
102
                                [% PROCESS authresult summary=line.summary authid=line.authid auth_preview=1 %]
103
                                [% PROCESS authresult summary=line.summary authid=line.authid auth_preview=1 %]
103
                            [% END %]
104
                            [% END %]
104
                        </td>
105
                        </td>
106
                        <td>[% line.origincode | html %]</td>
105
                        <td>[% line.summary.label | html %]</td>
107
                        <td>[% line.summary.label | html %]</td>
106
                        <td>
108
                        <td>
107
                            [% IF line.used > 0 %]
109
                            [% IF line.used > 0 %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt (-1 / +2 lines)
Lines 62-67 Link Here
62
                <table>
62
                <table>
63
                    <tr>
63
                    <tr>
64
                        <th>Summary</th>
64
                        <th>Summary</th>
65
                        <th>Source</th>
65
                        <th>Heading type</th>
66
                        <th>Heading type</th>
66
                        [% UNLESS ( isEDITORS ) %]
67
                        [% UNLESS ( isEDITORS ) %]
67
                            <th>Used in</th>
68
                            <th>Used in</th>
Lines 82-87 Link Here
82
                                    [% PROCESS authresult summary=line.summary authid=line.authid %]
83
                                    [% PROCESS authresult summary=line.summary authid=line.authid %]
83
                                [% END %]
84
                                [% END %]
84
                            </td>
85
                            </td>
86
                            <td>[% line.origincode | html %]</td>
85
                            <td>[% line.authtype | html %]</td>
87
                            <td>[% line.authtype | html %]</td>
86
                            [% UNLESS ( line.isEDITORS ) %]
88
                            [% UNLESS ( line.isEDITORS ) %]
87
                                <td>
89
                                <td>
88
- 

Return to bug 20153