From: Jason Etheridge Date: Fri, 22 Jul 2011 06:09:06 +0000 (-0400) Subject: filter z39.50 services retrieval based on use_perm X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b30eb8805d55c4008d0ab38e947bfbbca95be144;p=working%2FEvergreen.git filter z39.50 services retrieval based on use_perm Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm index a5cd5ca478..5f3c0abfe8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Z3950.pm @@ -73,6 +73,9 @@ __PACKAGE__->register_method( method => "query_services", api_name => "open-ils.search.z3950.retrieve_services", signature => q/ + @param auth The login session key + @param check_use_perm If true, checks the Use Perm on the services + against the requestor Returns a list of service names that we have config data for / @@ -84,12 +87,12 @@ __PACKAGE__->register_method( # What services do we have config info for? # ------------------------------------------------------------------- sub query_services { - my( $self, $client, $auth ) = @_; + my( $self, $client, $auth, $check_use_perm ) = @_; my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; return $e->event unless $e->allowed('REMOTE_Z3950_QUERY'); - return fetch_service_defs(); + return fetch_service_defs($check_use_perm,$e); } # ------------------------------------------------------------------- @@ -97,10 +100,13 @@ sub query_services { # ------------------------------------------------------------------- sub fetch_service_defs { + my $check_use_perm = shift; + my $editor_with_authtoken = shift; + my $hash = $sclient->config_value('z3950', 'services'); # overlay config file values with in-db values - my $e = new_editor(); + my $e = $editor_with_authtoken || new_editor(); if($e->can('search_config_z3950_source')) { my $sources = $e->search_config_z3950_source( @@ -118,6 +124,7 @@ sub fetch_service_defs { record_format => $s->record_format, transmission_format => $s->transmission_format, auth => $s->auth, + use_perm => $s->use_perm }; for my $a ( @{ $s->attrs } ) { @@ -151,6 +158,22 @@ sub fetch_service_defs { } }; + # If checking use_perm, then filter out any services which the requestor + # lacks the perm for + if ($check_use_perm) { + foreach my $s (keys %{ $hash }) { + if ($$hash{$s}{use_perm}) { + if ($U->check_perms( + $e->requestor->id, + $e->requestor->ws_ou, + $$hash{$s}{use_perm} + )) { + delete $$hash{$s}; + } + }; + } + } + %services = %$hash; # cache these internally so we can actually use the db-configured sources return $hash; } diff --git a/Open-ILS/xul/staff_client/server/cat/z3950.js b/Open-ILS/xul/staff_client/server/cat/z3950.js index dc600e8562..ce7fc09ca1 100644 --- a/Open-ILS/xul/staff_client/server/cat/z3950.js +++ b/Open-ILS/xul/staff_client/server/cat/z3950.js @@ -371,7 +371,7 @@ cat.z3950.prototype = { var robj = obj.network.simple_request( 'RETRIEVE_Z3950_SERVICES', - [ ses() ] + [ ses(), true ] ); if (typeof robj.ilsevent != 'undefined') throw(robj); obj.services = robj;