Bug 30966: Record Overlay Rules - can't use Z39.50 filter
authorJohanna Raisa <johanna.raisa@gmail.com>
Fri, 29 Jul 2022 05:37:50 +0000 (08:37 +0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Mar 2023 09:47:13 +0000 (11:47 +0200)
This patch fixes overlay rules on z39.50 import

Test plan:
1) Create protection overlay rule to some fields for z39.50.
2) Import a record via z39.50.
3) See that the protected fields are replaced on the editor.
4) Apply the patch.
5) Import a record again.
6) See that the protected fields are in place on the editor.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
cataloguing/addbiblio.pl

index 9711a89..815e2a8 100755 (executable)
@@ -35,6 +35,7 @@ use C4::Biblio qw(
     prepare_host_field
     PrepHostMarcField
     TransformHtmlToMarc
+    ApplyMarcOverlayRules
 );
 use C4::Search qw( FindDuplicate enabled_staff_search_views );
 use C4::Auth qw( get_template_and_user haspermission );
@@ -864,6 +865,20 @@ if ($biblionumber) {
     my $sth =  $dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
     $sth->execute($biblionumber);
     ($biblioitemnumber) = $sth->fetchrow;
+    if (C4::Context->preference('MARCOverlayRules')) {
+        my $member = Koha::Patrons->find($loggedinuser);
+        $record = ApplyMarcOverlayRules(
+            {
+                biblionumber    => $biblionumber,
+                record          => $record,
+                overlay_context =>  {
+                        source       => $z3950 ? 'z3950' : 'intranet',
+                        categorycode => $member->categorycode,
+                        userid       => $member->userid
+                }
+            }
+        );
+    }
 }
 
 #-------------------------------------------------------------------------------------
@@ -892,7 +907,7 @@ if ( $op eq "addbiblio" ) {
                 $frameworkcode,
                 {
                     overlay_context => {
-                        source       => $z3950 ? 'z39.50' : 'intranet',
+                        source       => $z3950 ? 'z3950' : 'intranet',
                         categorycode => $member->categorycode,
                         userid       => $member->userid
                     }