Bug 41902: Display additional biblio info on duplicate check
When a duplicate record is suspected during cataloguing, query the AdditionalContents record_display category for the StaffDuplicateCheckPage location. If configured, process the content as a Template Toolkit template with the duplicate biblio object and display the rendered result in the duplicate warning. The TT context variable is 'biblio' (a Koha::Biblio object), so administrators can use expressions like: [% biblio.author %] ([% biblio.copyrightdate %]) Content is scrubbed using the record_display scrubber for XSS safety. Signed-off-by: Jeanne Mauriello <jeanne.mauriello@mainlib.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
470ac28564
commit
cdf015b497
|
|
@ -44,15 +44,20 @@ use MARC::Record;
|
|||
use C4::ClassSource qw( GetClassSources );
|
||||
use C4::ImportBatch qw( GetImportRecordMarc );
|
||||
use C4::Charset qw( SetMarcUnicodeFlag );
|
||||
use C4::Languages qw( getlanguage );
|
||||
use C4::Scrubber;
|
||||
use Koha::BiblioFrameworks;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
|
||||
use Koha::Acquisition::Orders;
|
||||
use Koha::AdditionalContents;
|
||||
use Koha::Biblios;
|
||||
use Koha::ItemTypes;
|
||||
use Koha::Libraries;
|
||||
|
||||
use Koha::Biblio::Metadata::Extractor::MARC::MARC21;
|
||||
use Koha::Logger;
|
||||
use Koha::TemplateUtils qw( process_tt );
|
||||
use Koha::Patrons;
|
||||
use Koha::UI::Form::Builder::Biblio;
|
||||
|
||||
|
|
@ -793,12 +798,42 @@ if ( $op eq "cud-addbiblio" ) {
|
|||
|
||||
# it may be a duplicate, warn the user and do nothing
|
||||
build_tabs( $template, $record, $dbh, $encoding, $input );
|
||||
|
||||
my $duplicate_additional_info = q{};
|
||||
my $dup_biblio = Koha::Biblios->find($duplicatebiblionumber);
|
||||
if ($dup_biblio) {
|
||||
my $lang = C4::Languages::getlanguage();
|
||||
my $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : q{};
|
||||
my @customizations = Koha::AdditionalContents->search_for_display(
|
||||
{
|
||||
category => 'record_display',
|
||||
location => 'StaffDuplicateCheckPage',
|
||||
lang => $lang,
|
||||
library_id => $branch,
|
||||
}
|
||||
)->as_list;
|
||||
|
||||
foreach my $customization (@customizations) {
|
||||
my $processed = eval { process_tt( $customization->content, { biblio => $dup_biblio } ) };
|
||||
if ($@) {
|
||||
Koha::Logger->get->error("Duplicate check additional info template error: $@");
|
||||
next;
|
||||
}
|
||||
$duplicate_additional_info .= $processed if $processed;
|
||||
}
|
||||
if ($duplicate_additional_info) {
|
||||
my $scrubber = C4::Scrubber->new('record_display');
|
||||
$duplicate_additional_info = $scrubber->scrub($duplicate_additional_info);
|
||||
}
|
||||
}
|
||||
|
||||
$template->param(
|
||||
biblionumber => $biblionumber,
|
||||
biblioitemnumber => $biblioitemnumber,
|
||||
duplicatebiblionumber => $duplicatebiblionumber,
|
||||
duplicatebibid => $duplicatebiblionumber,
|
||||
duplicatetitle => $duplicatetitle,
|
||||
biblionumber => $biblionumber,
|
||||
biblioitemnumber => $biblioitemnumber,
|
||||
duplicatebiblionumber => $duplicatebiblionumber,
|
||||
duplicatebibid => $duplicatebiblionumber,
|
||||
duplicatetitle => $duplicatetitle,
|
||||
duplicateadditionalinfo => $duplicate_additional_info,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -848,6 +848,9 @@
|
|||
></a>
|
||||
?</p
|
||||
>
|
||||
[% IF ( duplicateadditionalinfo ) %]
|
||||
<p class="duplicate-additional-info">[% duplicateadditionalinfo | $raw %]</p>
|
||||
[% END %]
|
||||
[% IF ( CAN_user_editcatalogue_edit_items ) %]
|
||||
<form action="/cgi-bin/koha/cataloguing/additem.pl" method="get">
|
||||
[% IF ( circborrowernumber ) # It is possible we have come from fast cataloging - include the fields %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue