From 69bae512f72bf8c9bce2b3b86453978adc4cf455 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 18 Oct 2021 13:04:55 +0200 Subject: [PATCH] Bug 14957: Fix record preview Signed-off-by: Martin Renvoize --- .../tools/batch_record_modification.tt | 6 ++-- svc/records/preview | 32 ++++++++++++++++--- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt index 9cde52931f..a88f84c6b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt @@ -198,7 +198,7 @@ [% biblio.biblionumber | html %] [% biblio.title | html %] - Show MARC + Show MARC [% END %] @@ -225,7 +225,7 @@ [% authority.authid | html %] [% PROCESS authresult summary=authority.summary authid=authority.authid %] - Show MARC + Show MARC [% END %] @@ -355,7 +355,7 @@ var url = "/cgi-bin/koha/svc/records/preview?" var mmtid = $(this).val(); $("a.previewMARC").each(function() { - $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid); + $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod"); }); }); diff --git a/svc/records/preview b/svc/records/preview index 643fb62fd3..2bc1afcc85 100755 --- a/svc/records/preview +++ b/svc/records/preview @@ -20,14 +20,17 @@ use Modern::Perl; use CGI; use C4::Auth qw( get_template_and_user ); -use C4::Biblio qw( GetMarcBiblio ); +use C4::Biblio qw( GetMarcBiblio ApplyMarcOverlayRules ); use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate ); use C4::Output qw( output_html_with_http_headers ); + use Koha::MetadataRecord::Authority; +use Koha::Patrons; my $query = CGI->new(); my $record_id = $query->param('record_id'); my $record_type = $query->param('record_type') || 'biblio'; +my $overlay_context = $query->param('overlay_context'); my $mmtid = $query->param('mmtid'); # Marc modification template id my $record; @@ -38,15 +41,34 @@ if ( $record_type eq 'biblio' ) { $record = $authority->record; } -if ( $mmtid ) { - ModifyRecordWithTemplate( $mmtid, $record ); -} - my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ template_name => "catalogue/showmarc.tt", query => $query, type => "intranet", }); + +if ($mmtid) { + ModifyRecordWithTemplate( $mmtid, $record ); + + if ( $record_type eq 'biblio' + && C4::Context->preference('MARCOverlayRules') + && $overlay_context ) + { + my $logged_in_user = Koha::Patrons->find($loggedinuser); + $record = ApplyMarcOverlayRules( + { + biblionumber => $record_id, + record => $record, + overlay_context => { + source => $overlay_context, + categorycode => $logged_in_user->categorycode, + userid => $logged_in_user->userid + }, + } + ); + } +} + $template->param( MARC_FORMATTED => $record->as_formatted ); output_html_with_http_headers $query, $cookie, $template->output; -- 2.20.1