Bugzilla – Attachment 191437 Details for
Bug 20153
Add new column "source" in the authorities pages's result
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20153: Add new column "source" in the authorities pages's result
Bug-20153-Add-new-column-source-in-the-authorities.patch (text/plain), 5.96 KB, created by
Lari Taskula
on 2026-01-14 18:58:32 UTC
(
hide
)
Description:
Bug 20153: Add new column "source" in the authorities pages's result
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2026-01-14 18:58:32 UTC
Size:
5.96 KB
patch
obsolete
>From dc759e6f962bea46bc9fd8de087a8d387f21fc57 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@hypernova.fi> >Date: Mon, 16 Sep 2024 19:11:37 +0300 >Subject: [PATCH] Bug 20153: Add new column "source" in the authorities pages's > result > >Populates the already existing > auth_header.origincode >from MARC Authorities CRUD. > >Displays it in the authorities search results from the cataloguing tool and >from the authorities search module. > >MARC21 cataloguing rules are followed to populate it automatically, but I have >no knowledge of UNIMARC/etc to implement origincode autovifivication for those. > >TEST PLAN (MARC21) >1. Create a MARC Authorities Record >2. Optionally define MARC Framework for Authority auth_header.origincode >3. Populate 040$ca or 024$2 or 003 or the subfield at > MARC Framework for Authority auth_header.origincode >4. Search for the Auth Record >5. Observe a new 'Source'-column in the search results has the defined 'Cataloguing Source'. >5a. Page: authorities/auth_finder.pl >5b. Page: authorities/authorities-home.pl > >TEST PLAN (Others) >0. Same as MARC21, but the MARC FW for Auth is mandatory. >--- > C4/AuthoritiesMarc.pm | 31 +++++++++++++++++++ > Koha/SearchEngine/Elasticsearch/Search.pm | 1 + > .../authorities/searchresultlist-auth.tt | 2 ++ > .../modules/authorities/searchresultlist.tt | 2 ++ > 4 files changed, 36 insertions(+) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index f0fe2c1325a..d2425a6cd6f 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -700,12 +700,15 @@ sub AddAuthority { > > my $heading = $authority->heading_object( { record => $record } ); > >+ my $origincode = CalculateOriginCode( $record, $authtypecode ); >+ > # Update > $authority->update( > { > authtypecode => $authtypecode, > marcxml => $record->as_xml_record($format), > heading => $heading ? $heading->display_form : '', >+ origincode => $origincode, > } > ); > >@@ -1269,6 +1272,34 @@ sub GetAuthorizedHeading { > return; > } > >+=head2 CalculateOriginCode >+ >+ Finds the auth_header.origincode from the given MARC Authorities Record for the given MARC Authorities Framework >+ >+=cut >+ >+sub CalculateOriginCode { >+ my ( $record, $authtypecode ) = @_; >+ >+ my ( $tagfield, $tagsubfield ) = GetAuthMARCFromKohaField( 'auth_header.origincode', $authtypecode ); >+ if ( not( defined($tagfield) && defined($tagsubfield) ) || not( $record->subfield( $tagfield, $tagsubfield ) ) ) { >+ if ( C4::Context->preference('marcflavour') eq 'MARC21' ) { >+ return >+ $record->subfield( '040', 'c' ) >+ || $record->subfield( '040', 'a' ) >+ || $record->subfield( '024', '2' ) >+ || $record->field('003') >+ || ''; >+ } else { >+ warn "KohaToMARCMapping for 'auth_header.origincode' not set for '" >+ . C4::Context->preference('marcflavour') >+ . "' and don't know what fallbacks to use."; >+ return ''; >+ } >+ } >+ return $record->subfield( $tagfield, $tagsubfield ); >+} >+ > =head2 CompareFieldWithAuthority > > $match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index ccf502c96c0..e2ddf63efc7 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -260,6 +260,7 @@ sub search_auth_compat { > # Turn the resultset into a hash > $result{authtype} = $authtype ? $authtype->authtypetext : $authtypecode; > $result{reported_tag} = $reported_tag; >+ $result{origincode} = C4::AuthoritiesMarc::CalculateOriginCode( $marc, $authtypecode ); > > if ( C4::Context->preference('ShowHeadingUse') ) { > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >index 363ae676a31..f4b530e6b1b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >@@ -85,6 +85,7 @@ > <table> > <tr> > <th>Summary</th> >+ <th>Source</th> > <th>Heading type</th> > <th>Used</th> > [% IF Koha.Preference('ShowHeadingUse') %] >@@ -102,6 +103,7 @@ > [% PROCESS authresult summary=line.summary authid=line.authid auth_preview=1 %] > [% END %] > </td> >+ <td>[% line.origincode | html %]</td> > <td>[% line.summary.label | html %]</td> > <td> > [% IF line.used > 0 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >index 861eca86c30..83bcb8ec5f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >@@ -62,6 +62,7 @@ > <table> > <tr> > <th>Summary</th> >+ <th>Source</th> > <th>Heading type</th> > [% UNLESS ( isEDITORS ) %] > <th>Used in</th> >@@ -82,6 +83,7 @@ > [% PROCESS authresult summary=line.summary authid=line.authid %] > [% END %] > </td> >+ <td>[% line.origincode | html %]</td> > <td>[% line.authtype | html %]</td> > [% UNLESS ( line.isEDITORS ) %] > <td> >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20153
:
171569
|
188205
|
188206
|
188208
|
188209
|
188210
| 191437 |
191438