--- loncom/interface/lonpreferences.pm 2003/04/30 15:49:45 1.23 +++ 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.23 2003/04/30 15:49:45 matthew 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 { @@ -180,16 +256,23 @@ sub msgforwardchanger { my $r = shift; my $user = $ENV{'user.name'}; my $domain = $ENV{'user.domain'}; - my %userenv = &Apache::lonnet::get('environment',['msgforward']); + my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification']); my $msgforward=$userenv{'msgforward'}; my $notification=$userenv{'notification'}; my $critnotification=$userenv{'critnotification'}; my $bodytag=&Apache::loncommon::bodytag( 'Change Your Message Forwarding and Notification'); + my $forwardingHelp = Apache::loncommon::help_open_topic("Prefs_Forwarding", + "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 - +$forwardingHelp <br /> <form name="server" action="/adm/preferences" method="post"> <input type="hidden" name="action" value="verify_and_change_msgforward" /> New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>): @@ -197,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> @@ -650,8 +733,14 @@ 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' ) { + if (($ENV{'user.name'} eq 'albertel' ) || + ($ENV{'user.name'} eq 'kortemey' ) || + ($ENV{'user.name'} eq 'korte')) { if ($ENV{'user.debug'}) { &Apache::lonnet::delenv('user\.debug'); } else { @@ -706,7 +795,16 @@ ENDABOUTME </form> ENDCOLORFORM - if ($ENV{'user.name'} eq 'albertel') { + $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')) { $r->print(<<ENDDEBUG); <form name="client" action="/adm/preferences" method="post"> <input type="hidden" name="action" value="debugtoggle" />