--- loncom/interface/lonpreferences.pm 2006/05/01 22:15:17 1.82 +++ loncom/interface/lonpreferences.pm 2006/06/14 18:59:25 1.89 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.82 2006/05/01 22:15:17 albertel Exp $ +# $Id: lonpreferences.pm,v 1.89 2006/06/14 18:59:25 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +33,7 @@ package Apache::lonpreferences; use strict; +use LONCAPA; use Apache::Constants qw(:common); use Apache::File; use Crypt::DES; @@ -107,7 +108,7 @@ sub wysiwygchanger { my $switchoff=&mt('Disable WYSIWYG editor'); my $switchon=&mt('Enable WYSIWYG editor'); $r->print(< +


@@ -147,7 +148,7 @@ sub languagechanger { my $selectionbox=&Apache::loncommon::select_form($language,'language', %langchoices); $r->print(< +
$pref: $selectionbox ENDLSCREEN @@ -201,7 +202,7 @@ sub texenginechanger { $r->print(< - +

$pref: $selectionbox

@@ -297,25 +298,76 @@ sub rolesprefchanger { $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. -

+# Get list of recent roles and display with checkbox in front + my $roles_check_list = ''; + my $role_key=''; + if ($env{'environment.recentroles'}) { + my %recent_roles = + &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); + + $roles_check_list .= + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + "".&mt('Freeze Role')."". + "".&mt('Role')."". + &Apache::loncommon::end_data_table_header_row(). + "\n"; + my $count; + foreach $role_key (sort(keys(%recent_roles))) { + my $checked = ""; + my $value = $recent_roles{$role_key}; + if ($value eq 'role_frozen') { + $checked = "checked=\"checked\""; + } +# get course information + my ($role,$rest) = split(/\./, $role_key); + my $trole = &Apache::lonnet::plaintext($role); + my ($tdomain,$other,$tsection)= + split(/\//,Apache::lonnet::declutter($rest)); + my $tother = '-'; + if ($role =~ /cc|st|in|ta/ ) { + my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other); + $tother = " - ".$newhash{'description'}; + } elsif ($role =~ /dc/) { + $tother = ""; + } else { + $tother = " - $other"; + } + my $section=""; + if ($tsection) { + $section = " - Section/Group: $tsection"; + } + $count++; + $roles_check_list .= + &Apache::loncommon::start_data_table_row(). + ''. + "". + "". + &Apache::loncommon::end_data_table_row(). "\n"; + } + $roles_check_list .= "\n"; + } + + $r->print(' +

'.&mt('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.').' +

-
-
Number of roles in Hotlist: +
+
'.&mt('Number of roles in Hotlist:').' +

'.&mt('This list below can be used to freeze roles on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').' +

+'.$roles_check_list.'
- - -ENDSCREEN + +'); } sub verify_and_change_rolespref { @@ -325,24 +377,55 @@ sub verify_and_change_rolespref { # Recent Roles Hotlist Flag my $hotlist_flag = $env{'form.recentroles'}; my $hotlist_n = $env{'form.recentrolesn'}; - my $message=''; + 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'; + $message=&mt('Recent Roles Hotlist is Enabled'); } else { &Apache::lonnet::del('environment',['recentroles']); &Apache::lonnet::delenv('environment\.recentroles'); - $message='Recent Roles Hotlist is Disabled'; + $message=&mt('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"; + $message.="
".&mt('Display [_1]$hotlist_n Most Recent Roles', + $hotlist_n)."\n"; + } + } + +# Get list of froze roles and list of recent roles + my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles'); + my %freeze = (); + foreach my $key (@freeze_list) { + $freeze{$key}='role_frozen'; + } + + my %recent_roles = + &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'}); + +# Unset any roles that were previously frozen but aren't in list + + foreach my $role_key (sort(keys(%recent_roles))) { + if (($recent_roles{$role_key} eq 'role_frozen') && + (!exists($freeze{$role_key}))) { + $message .= "
".&mt('Unfreezing Role: [_1]',$role_key)."\n"; + &Apache::lonhtmlcommon::store_recent('roles',$role_key,' '); } } +# Freeze selected roles + foreach my $role_key (@freeze_list) { + $message .= "
".&mt('Freezing Role: [_1]',$role_key)."\n"; + if ($recent_roles{$role_key} ne 'role_frozen') { + &Apache::lonhtmlcommon::store_recent('roles', + $role_key,'role_frozen'); + } + } + $message .= "

\n"; + $r->print(<print(< +

New screenname (shown if you post anonymously): @@ -430,7 +513,7 @@ sub msgforwardchanger { $r->print(< - + New Forwarding Address(es) (user:domain,user:domain,...):
@@ -519,13 +602,13 @@ sub colorschanger { foreach my $item (sort(keys(%colortypes))) { my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); $chtable.=&Apache::loncommon::start_data_table_row(). - ''.$colortypes{$item}.'      Select'. - &Apache::loncommon::end_data_table_row(); + &Apache::loncommon::end_data_table_row()."\n"; } my $end_data_table = &Apache::loncommon::end_data_table(); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); @@ -561,7 +644,7 @@ sub colorschanger { -
+ $start_data_table $chtable @@ -600,9 +683,13 @@ sub verify_and_change_colors { $message.='Reset '.$colortypes{$item}.'
'; } } + my $now = time; + &Apache::lonnet::put('environment',{'color.timestamp' => $now}); + &Apache::lonnet::appenv('environment.color.timestamp' => $now); + $r->print(< + ENDVCCOL @@ -683,7 +770,7 @@ $errormessage ensure that unencrypted passwords will not be sent out by a crappy browser --> -
+ @@ -872,10 +959,10 @@ sub discussionchanger { } $r->print(<<"END"); - +
-$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}
+$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}


END @@ -922,11 +1009,11 @@ sub verify_and_change_discussion { if (defined($env{'form.discdisp'}) ) { my $newdisp = $env{'form.newdisp'}; if ($newdisp eq 'unread') { - $message .='In discussions: only new posts will be displayed.
'; + $message .='In discussions: only new posts will be displayed.
'; &Apache::lonnet::put('environment',{'discdisplay' => $newdisp}); &Apache::lonnet::appenv('environment.discdisplay' => $newdisp); } else { - $message .= 'In discussions: all posts will be displayed.
'; + $message .= 'In discussions: all posts will be displayed.
'; &Apache::lonnet::del('environment',['discdisplay']); &Apache::lonnet::delenv('environment\.discdisplay'); } @@ -934,11 +1021,11 @@ sub verify_and_change_discussion { if (defined($env{'form.discmark'}) ) { my $newmark = $env{'form.newmark'}; if ($newmark eq 'ondisp') { - $message.='In discussions: new posts will be cease to be identified as "new" after display.
'; + $message.='In discussions: new posts will be cease to be identified as "new" after display.
'; &Apache::lonnet::put('environment',{'discmarkread' => $newmark}); &Apache::lonnet::appenv('environment.discmarkread' => $newmark); } else { - $message.='In discussions: posts will be identified as "new" until marked as read by the reader.
'; + $message.='In discussions: posts will be identified as "new" until marked as read by the reader.
'; &Apache::lonnet::del('environment',['discmarkread']); &Apache::lonnet::delenv('environment\.discmarkread'); } @@ -975,7 +1062,7 @@ sub coursedisplaychanger { $r->print('
'.&mt('Set the default page to be displayed when you select a course role').' '.&mt('(Currently: [_1])',$pagenames{$currvalue}).'
'.&mt('The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the "[_1]" page in the course',"What's New").'

'); $r->print(< +

@@ -999,11 +1086,11 @@ sub verify_and_change_coursepage { my $newdisp = $env{'form.newdisp'}; $message = ''.$lt{'defs'}.': '.$lt{'when'}.', '; if ($newdisp eq 'firstres') { - $message .= $lt{'ywbt'}.'
'; + $message .= $lt{'ywbt'}.'
'; &Apache::lonnet::put('environment',{'course_init_display' => $newdisp}); &Apache::lonnet::appenv('environment.course_init_display' => $newdisp); } else { - $message .= $lt{'apwb'}.'
'; + $message .= $lt{'apwb'}.'
'; &Apache::lonnet::del('environment',['course_init_display']); &Apache::lonnet::delenv('environment\.course_init_display'); } @@ -1207,6 +1294,19 @@ sub handler { text => 'Change Math Preferences'}, printmenu => 'yes', })); + + if ($env{'environment.remote'} eq 'off') { + push (@Options,({ action => 'launch', + linktext => 'Launch Remote Control', + href => '/adm/remote?url=/adm/preferences', + })); + } else { + push (@Options,({ action => 'collapse', + linktext => 'Collapse Remote Control', + href => '/adm/remote?url=/adm/preferences', + })); + } + if (&Apache::lonnet::allowed('whn',$env{'request.course.id'}) || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/' .$env{'request.course.sec'})) { @@ -1273,9 +1373,10 @@ sub handler { foreach my $option(@Options) { my $optiontext = ''; if (exists($option->{'href'})) { - $optiontext .= - ''. + $option->{'href_args'}{'action'}=$option->{'action'}; + $optiontext .= + ''. &mt($option->{'linktext'}).''; } if (exists($option->{'text'})) {