From 4f041f65774d48a3ec0f73a52521635bdb8d6171 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 26 Apr 2010 15:16:13 +0000 Subject: [PATCH] Added an API call which returns the set of opt-in user settings for all event-defs in a given org unit range. open-ils.actor.event_def.opt_in.settings git-svn-id: svn://svn.open-ils.org/ILS/trunk@16304 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index ead067e122..e30fa901e2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -3934,4 +3934,61 @@ sub check_password_strength_custom { return 1; } + + +__PACKAGE__->register_method( + method => "event_def_opt_in_settings", + api_name => "open-ils.actor.event_def.opt_in.settings", + stream => 1, + signature => { + desc => 'Streams the set of "cust" objects that are used as opt-in settings for event definitions', + params => [ + { desc => 'Authentication token', type => 'string'}, + { + desc => 'Org Unit ID. (optional). If no org ID is present, the home_ou of the requesting user is used', + type => 'number' + }, + ], + return => { + desc => q/set of "cust" objects that are used as opt-in settings for event definitions at the specified org unit/, + type => 'object', + class => 'cust' + } + } +); + +sub event_def_opt_in_settings { + my($self, $conn, $auth, $org_id) = @_; + my $e = new_editor(authtoken => $auth); + return $e->event unless $e->checkauth; + + if(defined $org_id and $org_id != $e->requestor->home_ou) { + return $e->event unless + $e->allowed(['VIEW_USER_SETTING_TYPE', 'ADMIN_USER_SETTING_TYPE'], $org_id); + } else { + $org_id = $e->requestor->home_ou; + } + + # find all config.user_setting_type's related to event_defs for the requested org unit + my $types = $e->json_query({ + select => {cust => ['name']}, + from => {atevdef => 'cust'}, + where => { + '+atevdef' => { + owner => $U->get_org_ancestors($org_id), # context org plus parents + active => 't' + } + } + }); + + if(@$types) { + $conn->respond($_) for + @{$e->search_config_usr_setting_type({name => [map {$_->{name}} @$types]})}; + } + + return undef; +} + + + 1; -- 2.11.0