[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmsg.pm

raeburn raeburn@source.lon-capa.org
Thu, 05 Feb 2009 00:45:30 -0000


raeburn		Thu Feb  5 00:45:30 2009 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm loncommon.pm 
  Log:
  - Move &user_lang() from lonmsg.pm to loncommon.pm so it is more generally available.
  - This routine is used to get a language handle object from Locale::Maketext for a user different to the current session user.
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.221 loncom/interface/lonmsg.pm:1.222
--- loncom/interface/lonmsg.pm:1.221	Mon Jan  5 20:04:40 2009
+++ loncom/interface/lonmsg.pm	Thu Feb  5 00:45:29 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.221 2009/01/05 20:04:40 raeburn Exp $
+# $Id: lonmsg.pm,v 1.222 2009/02/05 00:45:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -194,8 +194,6 @@
   %to - a hash, which keys are addresses of users to send messages to
         the keys will look like   name:domain
 
-=item user_lang()
-
 =back
 
 =cut
@@ -490,7 +488,7 @@
     my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,
         $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);
     my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend);
-    my $user_lh = &user_lang($touname,$toudom,$fromcid);
+    my $user_lh = &Apache::loncommon::user_lang($touname,$toudom,$fromcid);
     if ($fromcid ne '') {
         $coursetext = "\n".&mt_user($user_lh,'Course').': ';
         if ($env{'course.'.$fromcid.'.description'} ne '') {
@@ -1025,28 +1023,6 @@
     return ($typestyle,%to);
 }
 
-sub user_lang {
-    my ($touname,$toudom,$fromcid) = @_;
-    my @userlangs;
-    if (($fromcid ne '') && ($env{'course.'.$fromcid.'.languages'} ne '')) {
-        @userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/,
-                    $env{'course.'.$fromcid.'.languages'}));
-    } else {
-        my %langhash = &Apache::loncommon::getlangs($touname,$toudom);
-        if ($langhash{'languages'} ne '') {
-            @userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'});
-        } else {
-            my %domdefs = &Apache::lonnet::get_domain_defaults($toudom);
-            if ($domdefs{'lang_def'} ne '') {
-                @userlangs = ($domdefs{'lang_def'});
-            }
-        }
-    }
-    my @languages=&Apache::lonlocal::get_genlanguages(@userlangs);
-    my $user_lh = Apache::localize->get_handle(@languages);
-    return $user_lh;
-}
-
 1;
 __END__
 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.741 loncom/interface/loncommon.pm:1.742
--- loncom/interface/loncommon.pm:1.741	Tue Feb  3 19:36:19 2009
+++ loncom/interface/loncommon.pm	Thu Feb  5 00:45:29 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.741 2009/02/03 19:36:19 harmsja Exp $
+# $Id: loncommon.pm,v 1.742 2009/02/05 00:45:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3073,6 +3073,29 @@
     return $preferred_possibilities[0];
 }
 
+sub user_lang {
+    my ($touname,$toudom,$fromcid) = @_;
+    my @userlangs;
+    if (($fromcid ne '') && ($env{'course.'.$fromcid.'.languages'} ne '')) {
+        @userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/,
+                    $env{'course.'.$fromcid.'.languages'}));
+    } else {
+        my %langhash = &getlangs($touname,$toudom);
+        if ($langhash{'languages'} ne '') {
+            @userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'});
+        } else {
+            my %domdefs = &Apache::lonnet::get_domain_defaults($toudom);
+            if ($domdefs{'lang_def'} ne '') {
+                @userlangs = ($domdefs{'lang_def'});
+            }
+        }
+    }
+    my @languages=&Apache::lonlocal::get_genlanguages(@userlangs);
+    my $user_lh = Apache::localize->get_handle(@languages);
+    return $user_lh;
+}
+
+
 ###############################################################
 ##               Student Answer Attempts                     ##
 ###############################################################