[open-ils-commits] r13181 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri May 15 15:49:48 EDT 2009


Author: erickson
Date: 2009-05-15 15:49:44 -0400 (Fri, 15 May 2009)
New Revision: 13181

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
ranged org unit setting method which returns the whole pile of settings for a given org, plus ancestor settings that are not represented by the context org or intermediate ancestor.

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-05-15 18:51:37 UTC (rev 13180)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-05-15 19:49:44 UTC (rev 13181)
@@ -181,7 +181,39 @@
 }
 
 
+__PACKAGE__->register_method(
+	method	=> "ranged_ou_settings",
+	api_name	=> "open-ils.actor.org_unit_setting.values.ranged.retrieve",
+);
+sub ranged_ou_settings {
+	my( $self, $client, $auth, $org_id ) = @_;
 
+	my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
+    return $e->event unless $e->allowed('VIEW_ORG_SETTINGS', $org_id);
+
+    my %ranged_settings;
+    my $org_list = $U->get_org_ancestors($org_id);
+    my $settings = $e->search_actor_org_unit_setting({org_unit => $org_list});
+    $org_list = [ reverse @$org_list ];
+
+    # start at the context org and capture the setting value
+    # without clobbering settings we've already captured
+    for my $org_id (@$org_list) {
+        
+        my @sets = grep { $_->org_unit == $org_id } @$settings;
+
+        for my $set (@sets) {
+            $ranged_settings{$set->name} = OpenSRF::Utils::JSON->JSON2perl($set->value)
+                unless defined $ranged_settings{$set->name};
+        }
+    }
+
+	return \%ranged_settings;
+}
+
+
+
 __PACKAGE__->register_method(
     api_name => 'open-ils.actor.ou_setting.ancestor_default',
     method => 'ou_ancestor_setting',



More information about the open-ils-commits mailing list