From 1cf881b124f92f10b524a7397e1a0d6c78a8f3bc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Oct 2014 21:50:34 +0200 Subject: [PATCH] [PASSED QA] Bug 7673: Assume that all fields can be edited if the pref is empty If the sysprefs are empty, we assume that the librarian can edit all subfields, even if s/he has the restricted permission. Signed-off-by: Katrin Fischer --- cataloguing/additem.pl | 10 ++++++++-- .../prog/en/modules/admin/preferences/cataloguing.pref | 2 ++ tools/batchMod.pl | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 3908edd..e6151d3 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -160,13 +160,18 @@ sub generate_subfield_form { # Getting list of subfields to keep when restricted edition is enabled my $subfieldsToAllowForRestrictedEdition = C4::Context->preference('SubfieldsToAllowForRestrictedEdition'); + my $allowAllSubfields = ( + not defined $subfieldsToAllowForRestrictedEdition + or $subfieldsToAllowForRestrictedEdition == q|| + ) ? 1 : 0; my @subfieldsToAllow = split(/ /, $subfieldsToAllowForRestrictedEdition); # If we're on restricted edition, and our field is not in the list of subfields to allow, # then it is read-only $attributes_no_value .= 'readonly="readonly" ' if ( - $restrictededition + not $allowAllSubfields + and $restrictededition and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow ); @@ -246,7 +251,8 @@ sub generate_subfield_form { # then it is read-only push @scrparam, (-readonly => "readonly"), (-disabled => "disabled") if ( - $restrictededition + not $allowAllSubfields + and $restrictededition and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow ); $subfield_data{marc_value} =CGI::scrolling_list(@scrparam); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 5f80f4c..a132731 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -116,6 +116,7 @@ Cataloging: - 'UNIMARC: "995$f 995$h 995$j"' - 'MARC21: "952$a 952$b 952$c"' - Note that the FA framework is excluded from the permission. + - If the pref is empty, no fields are restricted. - - Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. - pref: SubfieldsToAllowForRestrictedBatchmod @@ -123,6 +124,7 @@ Cataloging: - 'UNIMARC: "995$f 995$h 995$j"' - 'MARC21: "952$a 952$b 952$c"' - Note that the FA framework is excluded from the permission. + - If the pref is empty, no fields are restricted. Display: - - 'Separate multiple displayed authors, series or subjects with ' diff --git a/tools/batchMod.pl b/tools/batchMod.pl index a4fd66a..ea9c856 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -301,13 +301,17 @@ my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); # Getting list of subfields to keep when restricted batchmod edit is enabled my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForRestrictedBatchmod'); +my $allowAllSubfields = ( + not defined $subfieldsToAllowForBatchmod + or $subfieldsToAllowForBatchmod == q|| +) ? 1 : 0; my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); foreach my $tag (sort keys %{$tagslib}) { # loop through each subfield foreach my $subfield (sort keys %{$tagslib->{$tag}}) { next if subfield_is_koha_internal_p($subfield); - next if ($restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow ); + next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow ); next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); # barcode and stocknumber are not meant to be batch-modified next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode'; -- 1.9.1