--- loncom/interface/loncommon.pm	2008/12/19 17:19:48	1.726
+++ loncom/interface/loncommon.pm	2009/01/12 04:11:25	1.732
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.726 2008/12/19 17:19:48 raeburn Exp $
+# $Id: loncommon.pm,v 1.732 2009/01/12 04:11:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -943,24 +943,30 @@ ENDTEMPLATE
 # This is a quicky function for Latex cheatsheet editing, since it 
 # appears in at least four places
 sub helpLatexCheatsheet {
-    my $other = shift;
+    my ($topic,$text,$not_author) = @_;
+    my $out;
     my $addOther = '';
-    if ($other) {
-	$addOther = Apache::loncommon::help_open_topic($other, shift,
-						       undef, undef, 600) .
+    if ($topic) {
+	$addOther = &Apache::loncommon::help_open_topic($topic,$text,
+						       undef, undef, 600).
 							   '</td><td>';
     }
-    return '<table><tr><td>'.
-	$addOther .
-	&Apache::loncommon::help_open_topic("Greek_Symbols",&mt('Greek Symbols'),
-					    undef,undef,600)
-	.'</td><td>'.
-	&Apache::loncommon::help_open_topic("Other_Symbols",&mt('Other Symbols'),
-					    undef,undef,600)
-	.'</td><td>'.
-	&Apache::loncommon::help_open_topic("Authoring_Output_Tags",&mt('Output Tags'),
-	                                    undef,undef,600)
-	.'</td></tr></table>';
+    $out = '<table><tr><td>'.
+	   $addOther .
+	   &Apache::loncommon::help_open_topic("Greek_Symbols",&mt('Greek Symbols'),
+					       undef,undef,600).
+	   '</td><td>'.
+	   &Apache::loncommon::help_open_topic("Other_Symbols",&mt('Other Symbols'),
+					       undef,undef,600).
+	   '</td>';
+    unless ($not_author) {
+        $out .= '<td>'.
+	        &Apache::loncommon::help_open_topic("Authoring_Output_Tags",&mt('Output Tags'),
+	                                            undef,undef,600).
+	        '</td>';
+    }
+    $out .= '</tr></table>';
+    return $out;
 }
 
 sub general_help {
@@ -2717,6 +2723,43 @@ sub flush_email_cache {
     &Apache::lonnet::devalidate_cache_new('emailscache',$id);
 }
 
+# -------------------------------------------------------------------- getlangs
+
+=pod
+
+=item * &getlangs($uname,$udom)
+
+Gets a user's language preference and returns it as a hash with key:
+language.
+
+=cut
+
+
+sub getlangs {
+    my ($uname,$udom) = @_;
+    if (!$udom)  { $udom =$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'};   }
+    my $id=$uname.':'.$udom;
+    my ($langs,$cached)=&Apache::lonnet::is_cached_new('userlangs',$id);
+    if ($cached) {
+        return %{$langs};
+    } else {
+        my %loadlangs=&Apache::lonnet::get('environment',['languages'],
+                                           $udom,$uname);
+        &Apache::lonnet::do_cache_new('userlangs',$id,\%loadlangs);
+        return %loadlangs;
+    }
+}
+
+sub flush_langs_cache {
+    my ($uname,$udom)=@_;
+    if (!$udom)  { $udom =$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'};   }
+    return if ($udom eq 'public' && $uname eq 'public');
+    my $id=$uname.':'.$udom;
+    &Apache::lonnet::devalidate_cache_new('userlangs',$id);
+}
+
 # ------------------------------------------------------------------ Screenname
 
 =pod
@@ -7943,7 +7986,7 @@ sub upfile_select_html {
 #                 xml   => &mt('HTML/XML'),
                  );
     my $Str = '<input type="file" name="upfile" size="50" />'.
-        '<br />Type: <select name="upfiletype">';
+        '<br />'.&mt('Type').': <select name="upfiletype">';
     foreach my $type (sort(keys(%Types))) {
         $Str .= '<option value="'.$type.'" >'.$Types{$type}."</option>\n";
     }
@@ -8031,7 +8074,7 @@ sub csv_print_select_table {
               &end_data_table_header_row()."\n");
     foreach my $array_ref (@$d) {
 	my ($value,$display,$defaultcol)=@{ $array_ref };
-	$r->print(&start_data_table_row().'<tr><td>'.$display.'</td>');
+	$r->print(&start_data_table_row().'<td>'.$display.'</td>');
 
 	$r->print('<td><select name=f'.$i.
 		  ' onchange="javascript:flip(this.form,'.$i.');">');
@@ -9897,11 +9940,13 @@ sub get_annotation {
 }
 
 sub clean_symb {
-    my ($symb) = @_;
+    my ($symb,$delete_enc) = @_;
 
     &Apache::lonenc::check_decrypt(\$symb);
     my $enc = $env{'request.enc'};
-    delete($env{'request.enc'});
+    if ($delete_enc) {
+        delete($env{'request.enc'});
+    }
 
     return ($symb,$enc);
 }