--- loncom/interface/lonpreferences.pm 2003/07/05 10:07:11 1.26 +++ loncom/interface/lonpreferences.pm 2003/09/17 01:45:14 1.29 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.26 2003/07/05 10:07:11 www Exp $ +# $Id: lonpreferences.pm,v 1.29 2003/09/17 01:45:14 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -101,6 +101,82 @@ sub des_decrypt { ################################################################ ################################################################ +# Language Change Subroutines # +################################################################ +sub languagechanger { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; + my %userenv = &Apache::lonnet::get + ('environment',['languages','translator']); + my $language=$userenv{'languages'}; + my $translator=$userenv{'translator'}; + my $bodytag=&Apache::loncommon::bodytag( + 'Change Your Language Preferences'); + $r->print(<<ENDLSCREEN); +<html> +$bodytag + +<form name="server" action="/adm/preferences" method="post"> +<input type="hidden" name="action" value="verify_and_change_languages" /> +<br />Preferred language: +<input type="text" size="5" value="$language" name="language" /> +ENDLSCREEN + if ($ENV{'user.adv'}) { + $r->print (<<ENDTRSC); +<br />Willing to translate for language: +<input type="text" size="5" value="$translator" name="translator" /> +ENDTRSC + } + $r->print('<br /><input type="submit" value="Change" /></form></body></html>'); +} + + +sub verify_and_change_languages { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; +# Screenname + my $newlanguage = $ENV{'form.language'}; + $newlanguage=~s/[^\-\w]//g; + my $message=''; + if ($newlanguage) { + &Apache::lonnet::put('environment',{'languages' => $newlanguage}); + &Apache::lonnet::appenv('environment.languages' => $newlanguage); + $message='Set new preferred languages to '.$newlanguage; + } else { + &Apache::lonnet::del('environment',['languages']); + &Apache::lonnet::delenv('environment\.languages'); + $message='Reset preferred language'; + } + if ($ENV{'user.adv'}) { + $message.='<br />'; + my $newtrans = $ENV{'form.translator'}; + $newtrans=~s/[^\-\w]//g; + if ($newtrans) { + &Apache::lonnet::put('environment',{'translator' => $newtrans}); + &Apache::lonnet::appenv('environment.translator' => $newtrans); + $message.='Set translator to '.$newtrans; + } else { + &Apache::lonnet::del('environment',['translator']); + &Apache::lonnet::delenv('environment\.translator'); + $message.='Reset translator'; + } + } + + my $bodytag=&Apache::loncommon::bodytag( + 'Change Your Language Preferences'); + $r->print(<<ENDVCSCREEN); +<html> +$bodytag +</p> +$message +</body></html> +ENDVCSCREEN +} + + +################################################################ # Anonymous Discussion Name Change Subroutines # ################################################################ sub screennamechanger { @@ -190,6 +266,9 @@ sub msgforwardchanger { "What are forwarding ". "and notification ". "addresses"); + my $criticalMessageHelp = Apache::loncommon::help_open_topic("Course_Critical_Message", + "What are critical messages"); + $r->print(<<ENDMSG); <html> $bodytag @@ -201,7 +280,7 @@ New Forwarding Address(es) (<tt>user:dom New Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>): <input type="text" size="40" value="$notification" name="notification" /><hr /> New Critical Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>): -<input type="text" size="40" value="$critnotification" name="critnotification" /><hr /> +<input type="text" size="40" value="$critnotification" name="critnotification" />$criticalMessageHelp<hr /> <input type="submit" value="Change" /> </form> </body> @@ -654,6 +733,10 @@ sub handler { &colorschanger($r); } elsif ($ENV{'form.action'} eq 'verify_and_change_colors') { &verify_and_change_colors($r); + } elsif ($ENV{'form.action'} eq 'changelanguages') { + &languagechanger($r); + } elsif ($ENV{'form.action'} eq 'verify_and_change_languages') { + &verify_and_change_languages($r); } elsif ($ENV{'form.action'} eq 'debugtoggle') { if (($ENV{'user.name'} eq 'albertel' ) || ($ENV{'user.name'} eq 'kortemey' ) || @@ -712,6 +795,13 @@ ENDABOUTME </form> ENDCOLORFORM + $r->print(<<ENDLANGUAGES); +<form name="client" action="/adm/preferences" method="post"> +<input type="hidden" name="action" value="changelanguages" /> +<input type="submit" value="Change language preferences" /> +</form> +ENDLANGUAGES + if (($ENV{'user.name'} eq 'albertel' ) || ($ENV{'user.name'} eq 'kortemey' ) || ($ENV{'user.name'} eq 'korte')) {