From 27c7fe0c7fa1e11d311d579b398b0d962f449688 Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 21 Oct 2022 09:28:06 +0200 Subject: [PATCH] Bug 28639: Embed see-from headings (from authorities) into bibliographic records at OAI repository level Test plan: 1. Create an authority with at least a 1XX$a and a 4XX$a, for instance: 100 $a Foo 400 $a Bar 2. Create a biblio and add a link to this authority using the cataloguing plugin 3. Enable OAI-PMH syspref and fill OAI-PMH:archiveID syspref with "oai:sandbox" 4. Go to OAI repository and display the previously created record (at /cgi-bin/koha/oai.pl?verb=GetRecord&metadataPrefix=marcxml&identifier=oai:sandbox:{biblionumber} 5. The record should not contain see-from headings 6. Run perl installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl 7. Enable OAI-PMH:EmbedSeeFromInBibRecord 8. Go again to the OAI record, you should see alternative forms at the end of the record --- Koha/OAI/Server/Repository.pm | 4 +++- ...639-add_EmbedSeeFromInBibRecord_syspref.pl | 21 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/web_services.pref | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm index cef649169f9..4acd46d3196 100644 --- a/Koha/OAI/Server/Repository.pm +++ b/Koha/OAI/Server/Repository.pm @@ -40,6 +40,7 @@ use C4::Biblio qw( GetFrameworkCode ); use C4::Charset qw( StripNonXmlChars ); use Koha::XSLT::Base; use Koha::Biblios; +use Koha::Filter::MARC::EmbedSeeFromHeadings; use MARC::Record; @@ -175,6 +176,7 @@ sub get_biblio_marcxml { my ( $self, $biblionumber, $format ) = @_; my $with_items = 0; my $expanded_avs = 0; + my $embedseefromheadings = C4::Context->preference('OAI-PMH:EmbedSeeFromInBibRecord') || 0; if ( my $conf = $self->{conf} ) { $with_items = $conf->{format}->{$format}->{include_items }; $expanded_avs = $conf->{format}->{$format}->{expanded_avs}; @@ -194,7 +196,7 @@ sub get_biblio_marcxml { $record = $biblio->metadata->record_strip_nonxml( { embed_items => $with_items, opac => 1 } ); } if ($record) { - + Koha::Filter::MARC::EmbedSeeFromHeadings->filter($record) if $embedseefromheadings; my $rules = C4::Context->yaml_preference('OpacHiddenItems') // {}; if ( $biblio->hidden_in_opac( { rules => $rules } ) ) { return; diff --git a/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl b/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl new file mode 100755 index 00000000000..4665e24be0c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28639-add_EmbedSeeFromInBibRecord_syspref.pl @@ -0,0 +1,21 @@ +use Modern::Perl; + +return { + bug_number => "bug_28639", + description => "Add embed see-from headings for oai", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ( + 'EmbedSeeFromInBibRecord', '0', NULL, 'Add embed see-from headings for OAI', 'YesNo' + ) + } + ); + + say $out "Syspref EmbedSeeFromInBibRecord for OAI"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 20d11d36ab3..b15509d5444 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -446,6 +446,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:AutoUpdateSetsEmbedItemData', '0', '', 'Embed item information when automatically updating OAI sets. Requires OAI-PMH:AutoUpdateSets syspref to be enabled', 'YesNo'), ('OAI-PMH:ConfFile','',NULL,'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','File'), ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent), might be deleted (transient), or will never have any data in it (no)','transient|persistent|no','Choice'), +('OAI-PMH:EmbedSeeFromInBibRecord','0','','Embed see-from headings in bibliographic records exposed through OAI repository.','YesNo'), ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), ('OnSiteCheckoutAutoCheck','0','','Enable/Do not enable onsite checkout by default if last checkout was an onsite checkout','YesNo'), ('OnSiteCheckouts','0','','Enable/Disable the on-site checkouts feature','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index d5c7c1feb24..161bf59c0e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -91,6 +91,12 @@ Web services: transient: might be emptied or truncated at some point (transient) no: will never have any data in it (no) - "." + - + - pref: "OAI-PMH:EmbedSeeFromInBibRecord" + choices: + 1: Enable + 0: "Don't enabled" + - "Embed see from (non-preferred form) headings in bibliographic records exposed through OAI repository." ILS-DI: - - pref: ILS-DI -- 2.30.2