--- loncom/interface/lonpreferences.pm 2003/04/30 15:12:29 1.22 +++ loncom/interface/lonpreferences.pm 2003/09/29 19:33:51 1.31 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.22 2003/04/30 15:12:29 matthew Exp $ +# $Id: lonpreferences.pm,v 1.31 2003/09/29 19:33:51 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,7 @@ use Apache::File; use Crypt::DES; use DynaLoader; # for Crypt::DES version use Apache::loncommon(); +use Apache::lonhtmlcommon(); # # Write lonnet::passwd to do the call below. @@ -100,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 { @@ -179,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>): @@ -196,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> @@ -304,6 +388,7 @@ sub colorschanger { "','".$curcol."','" .$item."','parmform.pres','psub'".');">Select</a></td></tr>'; } + my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(<<ENDCOL); <html> <script> @@ -314,14 +399,7 @@ sub colorschanger { parmwin.close(); } - function pjump(type,dis,value,marker,ret,call) { - parmwin=window.open("/adm/rat/parameter.html?type="+escape(type) - +"&value="+escape(value)+"&marker="+escape(marker) - +"&return="+escape(ret) - +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms", - "height=350,width=350,scrollbars=no,menubar=no"); - - } + $pjump_def function psub() { pclose(); @@ -633,7 +711,7 @@ sub handler { my $r = shift; my $user = $ENV{'user.name'}; my $domain = $ENV{'user.domain'}; - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); # Some pages contain DES keys and should not be cached. &Apache::loncommon::no_cache($r); $r->send_http_header; @@ -655,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 { @@ -711,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" />