From: erickson Date: Mon, 20 Oct 2008 16:37:10 +0000 (+0000) Subject: added a global default locale configuration setting (for when no org setting exists... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9262d61f35b376f0c07efa7ddfaf116701215aaf;p=Evergreen.git added a global default locale configuration setting (for when no org setting exists). created an org-locale finder as an addition to the user locale finder. using default locale info as preferred language in opac searches where not provided by the client git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@10872 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 09e7a8a8b0..1d728872e2 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -9,6 +9,9 @@ vim:et:ts=4:sw=4: + + en-US + LOCALSTATEDIR/log LOCALSTATEDIR/lock diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index 759c670c84..4e5acf6ccc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -12,6 +12,7 @@ use Data::Dumper; use OpenILS::Utils::CStoreEditor; use OpenILS::Const qw/:const/; use Unicode::Normalize; +use OpenSRF::Utils::SettingsClient; # --------------------------------------------------------------------------- # Pile of utilty methods used accross applications. @@ -1463,7 +1464,7 @@ sub get_org_full_path { # 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; + $e ||= OpenILS::Utils::CStoreEditor->new; # first, see if the user has an explicit locale set my $setting = $e->search_actor_user_setting( @@ -1471,8 +1472,23 @@ sub get_user_locale { return OpenSRF::Utils::JSON->JSON2perl($setting->value) if $setting; my $user = $e->retrieve_actor_user($user_id) or return $e->event; + return $self->get_org_locale($user->home_ou, $e); +} + +# returns org locale setting +sub get_org_locale { + my($self, $org_id, $e) = @_; + $e ||= OpenILS::Utils::CStoreEditor->new; + + my $locale; + if(defined $org_id) { + $locale = $self->ou_ancestor_setting_value($org_id, 'global.default_locale', $e); + return $locale if $locale; + } - my $locale = $self->ou_ancestor_setting_value($user->home_ou, 'global.default_locale', $e); + # system-wide default + my $sclient = OpenSRF::Utils::SettingsClient->new; + $locale = $sclient->config_value('default_locale'); return $locale if $locale; # if nothing else, fallback to locale=cowboy diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 13432e3647..aa5824cbf4 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -538,6 +538,8 @@ sub multiclass_query { if $sclient->config_value(apps => 'open-ils.search', app_settings => 'use_staged_search') =~ /true/i; + $arghash->{preferred_language} = $U->get_org_locale($arghash->{org_unit}) + unless $arghash->{preferred_language}; $method = $self->method_lookup($method); my ($data) = $method->run($arghash, $docache);