Bug 7673: Assume that all fields can be edited if the pref is empty
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 10 Oct 2014 19:50:34 +0000 (21:50 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 11 Nov 2014 15:27:23 +0000 (12:27 -0300)
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 <Katrin.Fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
tools/batchMod.pl

index 3908edd..e6151d3 100755 (executable)
@@ -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);
index 5f80f4c..a132731 100644 (file)
@@ -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 '
index a4fd66a..ea9c856 100755 (executable)
@@ -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';