Bugzilla – Attachment 171569 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.67 KB, created by
Olli-Antti Kivilahti
on 2024-09-16 16:34:07 UTC
(
hide
)
Description:
Bug 20153: Add new column "source" in the authorities pages's result
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2024-09-16 16:34:07 UTC
Size:
5.67 KB
patch
obsolete
>From cf2708cf54009721d290e93036a345487d8f1fb0 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 'Origin'-tab 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 | 25 +++++++++++++++++++ > Koha/SearchEngine/Elasticsearch/Search.pm | 1 + > .../authorities/searchresultlist-auth.tt | 2 ++ > .../modules/authorities/searchresultlist.tt | 2 ++ > 4 files changed, 30 insertions(+) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 1656a2ba9b..f1c46235bd 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -697,6 +697,8 @@ sub AddAuthority { > > my $heading = $authority->heading_object( { record => $record } ); > >+ my $origincode = CalculateOriginCode($record, $authtypecode); >+ > # Update > $authority->update( > { >@@ -704,6 +706,7 @@ sub AddAuthority { > marc => $record->as_usmarc, > marcxml => $record->as_xml_record($format), > heading => $heading ? $heading->display_form : '', >+ origincode => $origincode, > } > ); > >@@ -1228,6 +1231,28 @@ 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 42326e3573..d7e8b7893e 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -247,6 +247,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); > > # Reimplementing BuildSummary is out of scope because it'll be hard > $result{summary} = >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 2b1e9ce345..d5d53158bf 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 >@@ -61,6 +61,7 @@ > <table> > <tr> > <th>Summary</th> >+ <th>Source</th> > <th>Heading type</th> > <th>Used</th> > [% IF Koha.Preference('ShowHeadingUse') %] >@@ -78,6 +79,7 @@ > [% PROCESS authresult summary=resul.summary authid=resul.authid auth_preview=1 %] > [% END %] > </td> >+ <td>[% resul.origincode %]</td> > <td>[% resul.summary.label | html %]</td> > <td> > [% IF resul.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 ec06c0d065..ccddc465c1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >@@ -64,6 +64,7 @@ > <table> > <tr> > <th>Summary</th> >+ <th>Source</th> > <th>Heading type</th> > [% UNLESS ( isEDITORS ) %] > <th>Used in</th> >@@ -84,6 +85,7 @@ > [% PROCESS authresult summary=resul.summary authid=resul.authid %] > [% END %] > </td> >+ <td>[% resul.origincode %]</td> > <td>[% resul.authtype | html %]</td> > [% UNLESS ( resul.isEDITORS ) %] > <td> >-- >2.39.2
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