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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 30 10:09:13 EDT 2009


Author: erickson
Date: 2009-09-30 10:09:11 -0400 (Wed, 30 Sep 2009)
New Revision: 14217

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
added batch support to the user setting retrieval API

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-09-30 13:53:14 UTC (rev 14216)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-09-30 14:09:11 UTC (rev 14217)
@@ -151,10 +151,21 @@
         return $e->event unless $e->allowed('VIEW_USER', $patron->home_ou);
     }
 
-    if($setting) {
+    sub get_setting {
+        my($e, $user_id, $setting) = @_;
         my $val = $e->search_actor_user_setting({usr => $user_id, name => $setting})->[0];
-        return '' unless $val;
+        return '' unless $val; # XXX this should really return undef, but needs testing
         return OpenSRF::Utils::JSON->JSON2perl($val->value);
+    }
+
+    if($setting) {
+        if(ref $setting eq 'ARRAY') {
+            my %settings;
+            $settings{$_} = get_setting($e, $user_id, $_) for @$setting;
+            return \%settings;
+        } else {
+            return get_setting($e, $user_id, $setting);    
+        }
     } else {
         my $s = $e->search_actor_user_setting({usr => $user_id});
 	    return { map { ( $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) ) } @$s };



More information about the open-ils-commits mailing list