--- loncom/interface/lonpreferences.pm 2003/04/30 15:49:45 1.23 +++ loncom/interface/lonpreferences.pm 2004/01/14 15:51:07 1.34 @@ -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.34 2004/01/14 15:51:07 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,6 +51,7 @@ use Crypt::DES; use DynaLoader; # for Crypt::DES version use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::lonlocal; # # Write lonnet::passwd to do the call below. @@ -101,6 +102,70 @@ 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']); + my $language=$userenv{'languages'}; + + my $bodytag=&Apache::loncommon::bodytag( + 'Change Your Language Preferences'); + my $pref=&mt('Preferred language'); + my %langchoices=('' => 'No language preference'); + foreach (&Apache::loncommon::languageids()) { + if (&Apache::loncommon::supportedlanguagecode($_)) { + $langchoices{&Apache::loncommon::supportedlanguagecode($_)} + = &Apache::loncommon::plainlanguagedescription($_); + } + } + my $selectionbox=&Apache::loncommon::select_form($language,'language', + %langchoices); + $r->print(< +$bodytag + +
+ +
$pref: $selectionbox +ENDLSCREEN + $r->print('
'); +} + + +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'; + } + my $bodytag=&Apache::loncommon::bodytag( + 'Change Your Language Preferences'); + $r->print(< +$bodytag +

+$message + +ENDVCSCREEN +} + + +################################################################ # Anonymous Discussion Name Change Subroutines # ################################################################ sub screennamechanger { @@ -180,16 +245,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(< $bodytag - +$forwardingHelp
New Forwarding Address(es) (user:domain,user:domain,...): @@ -197,7 +269,7 @@ New Forwarding Address(es) (user:dom New Message Notification Email Address(es) (joe\@doe.com,jane\@doe.edu,...):
New Critical Message Notification Email Address(es) (joe\@doe.com,jane\@doe.edu,...): -
+$criticalMessageHelp
@@ -628,7 +700,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; @@ -650,8 +722,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 { @@ -659,6 +737,11 @@ sub handler { } } } else { + my %help=(); + foreach ('Change_Colors','Change_Password', + 'Prefs_Screen_Name_Nickname','Prefs_Forwarding') { + $help{$_}=&Apache::loncommon::help_open_topic($_); + } $r->print(< @@ -673,6 +756,7 @@ ENDHEADER
+$help{'Change_Password'}
ENDPASSWORDFORM } @@ -682,12 +766,14 @@ ENDPASSWORDFORM +$help{'Prefs_Screen_Name_Nickname'} ENDSCREENNAMEFORM $r->print(< +$help{'Prefs_Forwarding'} ENDMSGFORWARDFORM # The "about me" page @@ -703,10 +789,20 @@ ENDABOUTME
+$help{'Change_Colors'}
ENDCOLORFORM - if ($ENV{'user.name'} eq 'albertel') { + $r->print(< + + + +ENDLANGUAGES + + if (($ENV{'user.name'} eq 'albertel' ) || + ($ENV{'user.name'} eq 'kortemey' ) || + ($ENV{'user.name'} eq 'korte')) { $r->print(<