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
/
# 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);
}
# -------------------------------------------------------------------
# -------------------------------------------------------------------
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(
record_format => $s->record_format,
transmission_format => $s->transmission_format,
auth => $s->auth,
+ use_perm => $s->use_perm
};
for my $a ( @{ $s->attrs } ) {
}
};
+ # 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;
}