--- loncom/interface/lonpreferences.pm 2006/06/14 18:56:58 1.88 +++ 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.88 2006/06/14 18:56:58 albertel Exp $ +# $Id: lonpreferences.pm,v 1.89 2006/06/14 18:59:25 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -298,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 { @@ -326,23 +377,54 @@ 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(<