--- loncom/interface/lonpreferences.pm 2003/09/29 16:09:20 1.30 +++ loncom/interface/lonpreferences.pm 2004/12/22 11:58:32 1.51 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.30 2003/09/29 16:09:20 www Exp $ +# $Id: lonpreferences.pm,v 1.51 2004/12/22 11:58:32 foxr 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: @@ -51,6 +39,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. @@ -62,7 +51,7 @@ use Apache::lonhtmlcommon(); ################################################## 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. @@ -103,32 +92,65 @@ 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','translator']); + ('environment',['languages']); my $language=$userenv{'languages'}; - my $translator=$userenv{'translator'}; - my $bodytag=&Apache::loncommon::bodytag( - 'Change Your Language Preferences'); - $r->print(< -$bodytag + 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(< -
Preferred language: - +
$pref: $selectionbox ENDLSCREEN - if ($ENV{'user.adv'}) { - $r->print (<Willing to translate for language: - -ENDTRSC - } - $r->print('
'); + $r->print('
'); } @@ -149,32 +171,89 @@ sub verify_and_change_languages { &Apache::lonnet::delenv('environment\.languages'); $message='Reset preferred language'; } - if ($ENV{'user.adv'}) { - $message.='
'; - 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(< -$bodytag

$message - ENDVCSCREEN } +################################################################ +# Roles Page Preference Change Subroutines # +################################################################ +sub rolesprefchanger { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; + my %userenv = &Apache::lonnet::get + ('environment',['recentroles','recentrolesn']); + my $hotlist_flag=$userenv{'recentroles'}; + my $hotlist_n=$userenv{'recentrolesn'}; + my $checked; + if ($hotlist_flag) { + $checked = 'checked="checked"'; + } + + if (!$hotlist_n) { $hotlist_n=3; } + my $options; + for (my $i=1; $i<10; $i++) { + my $select; + if ($hotlist_n == $i) { $select = 'selected="selected"'; } + $options .= "\n"; + } + + $r->print(<Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist +feature keeps track of the last N roles which have been +visited and places a table of these at the top of the roles page. +People with very few roles should leave this feature disabled. +

+ +
+ +
Enable Recent Roles Hotlist: + +
Number of roles in Hotlist: + +
+ +
+ENDSCREEN +} + +sub verify_and_change_rolespref { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; +# Recent Roles Hotlist Flag + my $hotlist_flag = $ENV{'form.recentroles'}; + my $hotlist_n = $ENV{'form.recentrolesn'}; + my $message=''; + if ($hotlist_flag) { + &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag}); + &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag); + $message='Recent Roles Hotlist is Enabled'; + } else { + &Apache::lonnet::del('environment',['recentroles']); + &Apache::lonnet::delenv('environment\.recentroles'); + $message='Recent Roles Hotlist is Disabled'; + } + if ($hotlist_n) { + &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n}); + &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n); + if ($hotlist_flag) { + $message.="
Display $hotlist_n Most Recent Roles\n"; + } + } + + $r->print(< +$message +ENDRPSCREEN +} + + ################################################################ # Anonymous Discussion Name Change Subroutines # @@ -187,12 +266,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): @@ -201,8 +275,6 @@ $bodytag
- - ENDSCREEN } @@ -237,14 +309,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 } @@ -260,8 +327,6 @@ sub msgforwardchanger { 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 ". @@ -270,8 +335,6 @@ sub msgforwardchanger { "What are critical messages"); $r->print(< -$bodytag $forwardingHelp
@@ -283,8 +346,6 @@ New Critical Message Notification Email $criticalMessageHelp
- - ENDMSG } @@ -338,14 +399,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 } @@ -355,9 +411,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)/) { @@ -390,7 +443,6 @@ sub colorschanger { } my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(< -$bodytag
@@ -431,8 +482,6 @@ $chtable
- - ENDCOL } @@ -473,18 +522,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 } @@ -530,12 +573,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 -