--- loncom/interface/lonpreferences.pm 2004/11/02 00:17:24 1.49 +++ loncom/interface/lonpreferences.pm 2004/11/19 20:17:52 1.50 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.49 2004/11/02 00:17:24 albertel Exp $ +# $Id: lonpreferences.pm,v 1.50 2004/11/19 20:17:52 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -177,6 +177,83 @@ $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 # @@ -953,6 +1030,23 @@ sub handler { subroutine => \&verify_and_change_discussion, } )); + push (@Options,({ action => 'changerolespref', + linktext => 'Change Roles Page Preferences', + href => '/adm/preferences', + subroutine => \&rolesprefchanger, + breadcrumb => + { href => '/adm/preferences?action=changerolespref', + text => 'Change Roles Pref'}, + }, + { action => 'verify_and_change_rolespref', + subroutine => \&verify_and_change_rolespref, + breadcrumb => + { href => '/adm/preferences?action=changerolespref', + text => 'Change Roles Preferences'}, + printmenu => 'yes', + })); + + if ($ENV{'user.name'} =~ /^(albertel|koretemey|korte|hallmat3|turtle)$/) { push (@Options,({ action => 'debugtoggle', printmenu => 'yes',