added a global default locale configuration setting (for when no org setting exists...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Oct 2008 16:37:10 +0000 (16:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Oct 2008 16:37:10 +0000 (16:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@10872 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/opensrf.xml.example
Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm

index 09e7a8a..1d72887 100644 (file)
@@ -9,6 +9,9 @@ vim:et:ts=4:sw=4:
 
     <default>
 
+        <!-- unless otherwise overidden, use this locale -->
+        <default_locale>en-US</default_locale>
+
         <dirs>
             <log>LOCALSTATEDIR/log</log> <!-- unix::server log files -->
             <sock>LOCALSTATEDIR/lock</sock> <!-- unix::server sock files -->
index 759c670..4e5acf6 100644 (file)
@@ -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
index 13432e3..aa5824c 100644 (file)
@@ -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);