Bug 18811: Change visibility checks in authorities.pl
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 15 Jun 2017 10:30:27 +0000 (12:30 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Sep 2017 14:30:40 +0000 (11:30 -0300)
The check is now <=-4 or >=5, but the framework uses 0 for Show all and
-5 for Hide all. (Note that sql installer scripts also use 8.)
When modifying an authority, the script also showed hidden fields when
filled, since it did not check the hidden field but only the tab field.

NOTE: The proposed solution restores consistency, but will remove hidden
fields from the MARC record.

Test plan:
[1] Set field 942a to Show all in an authority framework.
[2] Open a new record in this framework and verify that you see 942a.
[3] Edit an existing record in this framework and verify again.
[4] Set field 942a now to Hide all in this framework.
[5] Open a new record in this framework and verify that 942a is hidden.
[6] Edit an existing record in this framework and verify again.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

authorities/authorities.pl

index e45f5dd..5935b07 100755 (executable)
@@ -404,6 +404,7 @@ sub build_tabs {
                             $subfield = '@';
                         }
                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+                        next if $tagslib->{$tag}->{$subfield}->{hidden};
                         push(
                             @subfields_data,
                             &create_input(
@@ -419,6 +420,7 @@ sub build_tabs {
                             my $value    = $subfields[$subfieldcount][1];
                             next if ( length $subfield != 1 );
                             next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+                            next if $tagslib->{$tag}->{$subfield}->{hidden};
                             push(
                                 @subfields_data,
                                 &create_input(
@@ -435,10 +437,7 @@ sub build_tabs {
                         next if ( length $subfield != 1 );
                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
                         next if ( $tag < 10 );
-                        next
-                        if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
-                            or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
-                        );    #check for visibility flag
+                        next if $tagslib->{$tag}->{$subfield}->{hidden};
                         next if ( defined( $field->subfield($subfield) ) );
                         push(
                             @subfields_data,
@@ -477,9 +476,7 @@ sub build_tabs {
                 my @subfields_data;
                 foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
                     next if ( length $subfield != 1 );
-                    next if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
-                                or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
-                            ;    #check for visibility flag
+                    next if $tagslib->{$tag}->{$subfield}->{hidden};
                     next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
                     push(
                         @subfields_data,