--- loncom/interface/lonpreferences.pm 2003/04/19 15:34:06 1.21 +++ loncom/interface/lonpreferences.pm 2004/06/08 01:32:02 1.44 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.21 2003/04/19 15:34:06 www Exp $ +# $Id: lonpreferences.pm,v 1.44 2004/06/08 01:32:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,18 +25,6 @@ # # http://www.lon-capa.org/ # -# (Internal Server Error Handler -# -# (Login Screen -# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14, -# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer) -# -# 3/1/1 Gerd Kortemeyer) -# -# 3/1 Gerd Kortemeyer -# -# 2/13/02 2/14 2/15 Matthew Hall -# # This package uses the "londes.js" javascript code. # # TODOs that have to be completed: @@ -50,6 +38,8 @@ use Apache::File; 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. @@ -61,7 +51,7 @@ use Apache::loncommon(); ################################################## sub des_keys { # Make a new key for DES encryption. - # Each key has two parts which are returned seperately. + # Each key has two parts which are returned separately. # Please note: Each key must be passed through the &hex function # before it is output to the web browser. The hex versions cannot # be used to decrypt. @@ -100,6 +90,95 @@ sub des_decrypt { ################################################################ ################################################################ +# Language Change Subroutines # +################################################################ + +sub wysiwygchanger { + my $r = shift; + my %userenv = &Apache::lonnet::get + ('environment',['wysiwygeditor']); + my $offselect=''; + my $onselect='checked="1"'; + if ($userenv{'wysiwygeditor'}) { + $onselect=''; + $offselect='checked="1"'; + } + my $switchoff=&mt('Disable WYSIWYG editor'); + my $switchon=&mt('Enable WYSIWYG editor'); + $r->print(< + +
+ $switchoff
+ $switchon +ENDLSCREEN + $r->print('
'); +} + + +sub verify_and_change_wysiwyg { + my $r = shift; + my $newsetting=$ENV{'form.wysiwyg'}; + &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting}); + &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting); + $r->print('

'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'

'); +} + +################################################################ +# 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 $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(< + +
$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'; + } + $r->print(< +$message +ENDVCSCREEN +} + + +################################################################ # Anonymous Discussion Name Change Subroutines # ################################################################ sub screennamechanger { @@ -110,12 +189,7 @@ sub screennamechanger { ('environment',['screenname','nickname']); my $screenname=$userenv{'screenname'}; my $nickname=$userenv{'nickname'}; - my $bodytag=&Apache::loncommon::bodytag( - 'Change Your Nickname and Anonymous Screen Name'); $r->print(< -$bodytag -

New screenname (shown if you post anonymously): @@ -124,8 +198,6 @@ $bodytag
- - ENDSCREEN } @@ -160,14 +232,9 @@ sub verify_and_change_screenname { $message.='Reset nickname'; } - my $bodytag=&Apache::loncommon::bodytag( - 'Change Your Nickname and Anonymous Screen Name'); $r->print(< -$bodytag

$message - ENDVCSCREEN } @@ -179,16 +246,19 @@ 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'); - $r->print(< -$bodytag + 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(<
New Forwarding Address(es) (user:domain,user:domain,...): @@ -196,11 +266,9 @@ 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
- - ENDMSG } @@ -254,14 +322,9 @@ sub verify_and_change_msgforward { &Apache::lonnet::delenv('environment\.critnotification'); $message.='Reset critical message notification
'; } - my $bodytag=&Apache::loncommon::bodytag( - 'Change Your Message Forwarding and Notifications'); $r->print(< -$bodytag

$message - ENDVCMSG } @@ -271,9 +334,6 @@ ENDVCMSG sub colorschanger { my $r = shift; - my $bodytag=&Apache::loncommon::bodytag( - 'Change Color Scheme for Current Role Type','', - 'onUnload="pclose();"'); # figure out colors my $function='student'; if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { @@ -295,7 +355,7 @@ sub colorschanger { 'vlink' => 'Visited Link', 'alink' => 'Active Link'); my $chtable=''; - foreach my $item (keys %colortypes) { + foreach my $item (sort(keys(%colortypes))) { my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); $chtable.=''.$colortypes{$item}.'      Select'; } + my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(< -$bodytag
@@ -353,8 +405,6 @@ $chtable
- - ENDCOL } @@ -395,18 +445,12 @@ sub verify_and_change_colors { $message.='Reset '.$colortypes{$item}.'
'; } } - my $bodytag=&Apache::loncommon::bodytag( - 'Change Color Scheme for Current Role Type'); $r->print(< -$bodytag

$message
-
- ENDVCCOL } @@ -452,12 +496,7 @@ sub passwordchanger { my $jsh=Apache::File->new($include."/londes.js"); $r->print(<$jsh>); } - my $bodytag=&Apache::loncommon::bodytag('Change Password','', - 'onLoad="init();"'); $r->print(< -$bodytag -