Added an API call which returns the set of opt-in user settings for all event-defs...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 26 Apr 2010 15:16:13 +0000 (15:16 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 26 Apr 2010 15:16:13 +0000 (15:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16304 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm

index ead067e..e30fa90 100644 (file)
@@ -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;