From 18ff1e7ea31f4fdb759a46a39223a8520e2548e0 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 5 Dec 2019 06:32:25 -0500 Subject: [PATCH] Bug 20256: (QA follow-up) Filter out branchcodes the user has no permissions for --- cataloguing/additem.pl | 6 ++++-- tools/batchMod.pl | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 38f2a8dc7f..3151518392 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -112,7 +112,7 @@ sub _increment_barcode { sub generate_subfield_form { - my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $biblionumber, $temp, $loop_data, $i, $restrictededition) = @_; + my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $biblionumber, $temp, $loop_data, $i, $restrictededition, $patron) = @_; my $frameworkcode = &GetFrameworkCode($biblionumber); @@ -175,7 +175,9 @@ sub generate_subfield_form { my %authorised_lib; # builds list, depending on authorised value... if ( $subfieldlib->{authorised_value} eq "branches" ) { + my @allowed = $patron->libraries_where_can_edit_items; foreach my $thisbranch (@$branches) { + next unless any { /^$thisbranch->{branchcode}$/ } @allowed; push @authorised_values, $thisbranch->{branchcode}; $authorised_lib{$thisbranch->{branchcode}} = $thisbranch->{branchname}; $value = $thisbranch->{branchcode} if $thisbranch->{selected} && !$value; @@ -914,7 +916,7 @@ if($itemrecord){ next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); - my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition); + my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition, $patron); push @fields, "$tag$subfieldtag"; push (@loop_data, $subfield_data); $i++; diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 46a79fbb31..044a387949 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -32,7 +32,7 @@ use C4::ClassSource; use C4::Debug; use C4::Members; use MARC::File::XML; -use List::MoreUtils qw/uniq/; +use List::MoreUtils qw( uniq any ); use Koha::AuthorisedValues; use Koha::Biblios; @@ -335,6 +335,8 @@ my $allowAllSubfields = ( ) ? 1 : 0; my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); +my @allowed_to_edit_branches = $patron->libraries_where_can_edit_items; + foreach my $tag (sort keys %{$tagslib}) { # loop through each subfield foreach my $subfield (sort keys %{$tagslib->{$tag}}) { @@ -379,6 +381,7 @@ foreach my $tag (sort keys %{$tagslib}) { if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) { foreach my $library (@$libraries) { + next unless any { /^$library->{branchcode}$/ } @allowed_to_edit_branches; push @authorised_values, $library->{branchcode}; $authorised_lib{$library->{branchcode}} = $library->{branchname}; } -- 2.21.0 (Apple Git-122.2)