From f36d0486d4b158b26161a018995990495ee3cb16 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Oct 2021 16:08:34 +0200 Subject: [PATCH] Bug 14957: Tell the cataloguer that a change has been rejected --- C4/Biblio.pm | 7 ++++--- Koha/MarcOverlayRules.pm | 11 +++++++++-- catalogue/detail.pl | 3 ++- cataloguing/addbiblio.pl | 7 +++++-- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 863ce496efa..cdf8846a290 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -356,7 +356,7 @@ sub ModBiblio { if (!$record) { carp 'No record passed to ModBiblio'; - return 0; + return (0, 0); } if ( C4::Context->preference("CataloguingLog") ) { @@ -386,12 +386,13 @@ sub ModBiblio { _strip_item_fields($record, $frameworkcode); # apply overlay rules + my $blocked; if ( C4::Context->preference('MARCOverlayRules') && $biblionumber && defined $options && exists $options->{overlay_context} ) { - $record = ApplyMarcOverlayRules( + ($blocked, $record) = ApplyMarcOverlayRules( { biblionumber => $biblionumber, record => $record, @@ -429,7 +430,7 @@ sub ModBiblio { C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record); } - return 1; + return ($blocked, 1); } =head2 _strip_item_fields diff --git a/Koha/MarcOverlayRules.pm b/Koha/MarcOverlayRules.pm index 7d7e07a1d4d..1f511be143a 100644 --- a/Koha/MarcOverlayRules.pm +++ b/Koha/MarcOverlayRules.pm @@ -134,7 +134,7 @@ sub merge_records { my $rules = $self->context_rules($context); # Default when no rules found is to overwrite with incoming record - return $incoming_record unless $rules; + return (0, $incoming_record) unless $rules; my $fields_by_tag = sub { my ($record) = @_; @@ -219,6 +219,7 @@ sub merge_records { # Then we get the intersection of fields, present both in # current and incoming record (possibly to be overwritten) my @common_field_tags = grep { exists $incoming_fields->{$_} } keys %{$current_fields}; + my $blocked; foreach my $tag (@common_field_tags) { my $rule = $get_matching_field_rule->($tag); @@ -236,6 +237,7 @@ sub merge_records { push @{$merged_record_fields{$tag}}, @{$incoming_fields->{$tag}}; } else { + $blocked = 1; push @{$merged_record_fields{$tag}}, @{$current_fields->{$tag}}; } } @@ -269,6 +271,7 @@ sub merge_records { } else { # else keep existing subfield order + $blocked = 1; push @merged_fields, map { $_->[0] } @{$common_fields}; } } @@ -276,12 +279,16 @@ sub merge_records { if (@{$current_fields_only}) { if (!$rule->{remove}->{allow}) { push @merged_fields, @{$current_fields_only}; + } else { + $blocked = 1; } } # Appended if (@{$incoming_fields_only}) { if ($rule->{append}->{allow}) { push @merged_fields, @{$incoming_fields_only}; + } else { + $blocked = 1; } } $merged_record_fields{$tag} //= []; @@ -301,7 +308,7 @@ sub merge_records { $merged_record->append_fields(@{$merged_record_fields{$tag}}); } } - return $merged_record; + return ($blocked, $merged_record); } sub _clear_caches { diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b5801cca71c..ca46baf74a2 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -60,6 +60,7 @@ use Koha::SearchEngine::QueryBuilder; my $query = CGI->new(); my $analyze = $query->param('analyze'); +my $blocked = $query->param('blocked'); my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( { @@ -605,6 +606,6 @@ if ( C4::Context->preference('UseCourseReserves') ) { $template->param( course_reserves => $course_reserves ); } -$template->param(biblio => $biblio); +$template->param(biblio => $biblio, blocked => $blocked); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 89a68e06f89..0a0fa8222d2 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -862,11 +862,13 @@ if ( $op eq "addbiblio" ) { } my $confirm_not_duplicate = $input->param('confirm_not_duplicate'); # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate) + my $blocked; if ( !$duplicatebiblionumber or $confirm_not_duplicate ) { my $oldbibitemnum; if ( $is_a_modif ) { my $member = Koha::Patrons->find($loggedinuser); - ModBiblio( + my $x; + ($blocked, $x)= ModBiblio( $record, $biblionumber, $frameworkcode, @@ -878,6 +880,7 @@ if ( $op eq "addbiblio" ) { } } ); + $template->param(has_been_blocked => $blocked); } else { ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); @@ -913,7 +916,7 @@ if ( $op eq "addbiblio" ) { } elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) { print $input->redirect("/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=$biblionumber&searchid=$searchid"); } else { - print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid"); + print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid&blocked=$blocked"); } exit; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 7c2b961d6ca..3bc9df32285 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -94,6 +94,7 @@ [% CoceHost = Koha.Preference('CoceHost') %] [% INCLUDE 'cat-toolbar.inc' %] +[% IF blocked %]

HAS BEEN BLOCKED

[% END %] [% IF decoding_error %]
-- 2.25.1