View | Details | Raw Unified | Return to bug 20407
Collapse All | Expand All

(-)a/Koha/REST/Plugin/Objects.pm (-6 / +20 lines)
Lines 91-101 sub register { Link Here
91
                });
91
                });
92
            }
92
            }
93
93
94
            my @objects_list = map {
94
            my $spec = $c->openapi->spec();
95
                ( defined $to_api )
95
            my $properties = $spec->{responses}{200}{schema}{items}{properties};
96
                  ? $to_api->( $_->TO_JSON )
96
97
                  : $_->TO_JSON
97
            my $user = $c->stash('koha.user');
98
            } $objects->as_list;
98
            my @hidden_properties;
99
            unless ( $user && $user->has_permission({ catalogue => 1 }) ) {
100
                foreach my $property ( keys %$properties ) {
101
                    if ( defined( $properties->{ $property }{'x-public'} )
102
                        && !$properties->{ $property }{'x-public'}) {
103
                        push @hidden_properties, $property;
104
                    }
105
                }
106
            }
107
108
            my @objects_list;
109
            foreach my $o ( @{ $objects->as_list } ) {
110
                my $json = defined($to_api) ? $to_api->( $o->TO_JSON ) : $o->TO_JSON;
111
                delete @{ $json }{ @hidden_properties };
112
                push @objects_list, $json;
113
            }
99
114
100
            return \@objects_list;
115
            return \@objects_list;
101
        }
116
        }
102
- 

Return to bug 20407