[open-ils-commits] r10404 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 21 13:25:49 EDT 2008
Author: erickson
Date: 2008-08-21 13:25:46 -0400 (Thu, 21 Aug 2008)
New Revision: 10404
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
added a utility method to find a user's locale
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-08-21 16:25:03 UTC (rev 10403)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2008-08-21 17:25:46 UTC (rev 10404)
@@ -1452,5 +1452,26 @@
return \@orgs;
}
+# returns the user's configured locale as a string. Defaults to en-US if none is configured.
+sub get_user_locale {
+ my($self, $user_id, $e) = @_;
+ $e ||=OpenILS::Utils::CStoreEditor->new;
+
+ # first, see if the user has an explicit locale set
+ my $setting = $e->search_actor_user_setting(
+ {usr => $user_id, name => 'global.locale'})->[0];
+ return OpenSRF::Utils::JSON->JSON2perl($setting->value) if $setting;
+
+ my $user = $e->retrieve_actor_user($user_id) or return $e->event;
+
+ # next see if their home org specifies a default locale
+ $setting = $e->search_actor_org_unit_setting(
+ {org_unit => $user->home_ou, name => 'global.default_locale'})->[0];
+ return OpenSRF::Utils::JSON->JSON2perl($setting->value) if $setting;
+
+ # if nothing else, fallback to locale=cowboy
+ return 'en-US';
+}
+
1;
More information about the open-ils-commits
mailing list