From 10eda7a503859e625d193baa7345c4add1a2a887 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 30 Sep 2009 14:09:11 +0000 Subject: [PATCH] added batch support to the user setting retrieval API git-svn-id: svn://svn.open-ils.org/ILS/trunk@14217 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index a5dfd4a05d..2c4fe2257c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -151,10 +151,21 @@ sub user_settings { 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 }; -- 2.11.0