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

(-)a/C4/AuthoritiesMarc.pm (+25 lines)
Lines 704-715 sub AddAuthority { Link Here
704
704
705
    my $heading = $authority->heading_object( { record => $record } );
705
    my $heading = $authority->heading_object( { record => $record } );
706
706
707
    my $origincode = CalculateOriginCode($record, $authtypecode);
708
707
    # Update
709
    # Update
708
    $authority->update(
710
    $authority->update(
709
        {
711
        {
710
            authtypecode => $authtypecode,
712
            authtypecode => $authtypecode,
711
            marcxml      => $record->as_xml_record($format),
713
            marcxml      => $record->as_xml_record($format),
712
            heading      => $heading ? $heading->display_form : '',
714
            heading      => $heading ? $heading->display_form : '',
715
            origincode   => $origincode,
713
        }
716
        }
714
    );
717
    );
715
718
Lines 1273-1278 sub GetAuthorizedHeading { Link Here
1273
    return;
1276
    return;
1274
}
1277
}
1275
1278
1279
=head2 CalculateOriginCode
1280
1281
    Finds the auth_header.origincode from the given MARC Authorities Record for the given MARC Authorities Framework
1282
1283
=cut
1284
1285
sub CalculateOriginCode {
1286
    my ($record, $authtypecode) = @_;
1287
1288
    my ($tagfield, $tagsubfield) = GetAuthMARCFromKohaField('auth_header.origincode', $authtypecode);
1289
    if (not(defined($tagfield) && defined($tagsubfield)) || not($record->subfield($tagfield, $tagsubfield))) {
1290
        if (C4::Context->preference('marcflavour') eq 'MARC21') {
1291
            return $record->subfield('040', 'c') || $record->subfield('040', 'a') || $record->subfield('024', '2') || $record->field('003') || '';
1292
        }
1293
        else {
1294
            warn "KohaToMARCMapping for 'auth_header.origincode' not set for '".C4::Context->preference('marcflavour')."' and don't know what fallbacks to use.";
1295
            return '';
1296
        }
1297
    }
1298
    return $record->subfield($tagfield, $tagsubfield);
1299
}
1300
1276
=head2 CompareFieldWithAuthority
1301
=head2 CompareFieldWithAuthority
1277
1302
1278
  $match = &CompareFieldWithAuthority({ field => $field, authid => $authid })
1303
  $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