--- loncom/interface/lonpreferences.pm 2006/06/14 18:56:58 1.88
+++ loncom/interface/lonpreferences.pm 2007/04/13 13:39:32 1.98
@@ -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.98 2007/04/13 13:39:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonnet;
+use LONCAPA();
#
# Write lonnet::passwd to do the call below.
@@ -279,6 +280,8 @@ ENDVCSCREEN
################################################################
sub rolesprefchanger {
my $r = shift;
+ my $role = ($env{'user.adv'} ? 'Role' : 'Course');
+ my $lc_role = ($env{'user.adv'} ? 'role' : 'course');
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get
@@ -298,52 +301,154 @@ 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'});
+ my %frozen_roles =
+ &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
+
+ my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
+ my @sorted_roles = sort {$role_text{$a} cmp $role_text{$b}} keys(%role_text);
+
+ $roles_check_list .=
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ "
");
+ "One or more password fields were blank.\n",$caller,$mailtoken);
return;
}
# Get the keys
@@ -746,10 +1013,14 @@ sub verify_and_change_password {
my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
# I do not a have a better idea about how to handle this
+ my $tryagain_text = &mt('Please log out and try again.');
+ if ($caller eq 'reset_by_email') {
+ $tryagain_text = &mt('Please try again later.');
+ }
$r->print(<
ERROR: Unable to retrieve stored token for
-password decryption. Please log out and try again.
+password decryption. $tryagain_text
ENDERROR
# Probably should log an error here
@@ -760,19 +1031,29 @@ ENDERROR
$currentpass = &des_decrypt($ckey ,$currentpass);
$newpass1 = &des_decrypt($n1key,$newpass1);
$newpass2 = &des_decrypt($n2key,$newpass2);
- #
+ #
+ if ($caller eq 'reset_by_email') {
+ my %data = &Apache::lonnet::tmpget($mailtoken);
+ if ($currentpass ne $data{'temppasswd'}) {
+ &passwordchanger($r,
+ 'ERROR:'.
+ 'Could not verify current authentication. '.
+ 'Please try again.',$caller,$mailtoken);
+ return 1;
+ }
+ }
if ($newpass1 ne $newpass2) {
&passwordchanger($r,
'ERROR:'.
'The new passwords you entered do not match. '.
- 'Please try again.');
+ 'Please try again.',$caller,$mailtoken);
return 1;
}
if (length($newpass1) < 7) {
&passwordchanger($r,
'ERROR:'.
'Passwords must be a minimum of 7 characters long. '.
- 'Please try again.');
+ 'Please try again.',$caller,$mailtoken);
return 1;
}
#
@@ -783,7 +1064,7 @@ ENDERROR
}
if ($badpassword) {
# I can't figure out how to enter bad characters on my browser.
- &passwordchanger($r,<ERROR:
The password you entered contained illegal characters.
Valid characters are: space and
@@ -792,20 +1073,22 @@ Valid characters are: space and
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
ENDERROR
+ &passwordchanger($r,$errormessage,$caller,$mailtoken);
+ return 1;
}
#
# Change the password (finally)
my $result = &Apache::lonnet::changepass
- ($user,$domain,$currentpass,$newpass1,$homeserver);
+ ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
# Inform the user the password has (not?) been changed
if ($result =~ /^ok$/) {
$r->print(<<"ENDTEXT");
-
The password for $user was successfully changed
+
The password for $user was successfully changed
ENDTEXT
} else {
# error error: run in circles, scream and shout
$r->print(<The password for $user was not changed
+
The password for $user was not changed
Please make sure your old password was entered correctly.
ENDERROR
return 1;
@@ -1096,7 +1379,7 @@ sub handler {
}));
push (@Options,({ action => 'changemsgforward',
- linktext => 'Change Message Forwarding and Notification Addresses',
+ linktext => 'Change Message Forwarding and Notification Email Addresses',
href => '/adm/preferences',
help => 'Prefs_Forwarding',
breadcrumb =>
@@ -1180,20 +1463,21 @@ sub handler {
printmenu => 'yes',
subroutine => \&verify_and_change_discussion, }
));
-
+
+ my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
push (@Options,({ action => 'changerolespref',
- linktext => 'Change Roles Page Preferences',
+ linktext => 'Change '.$role.' Page Preferences',
href => '/adm/preferences',
subroutine => \&rolesprefchanger,
breadcrumb =>
{ href => '/adm/preferences?action=changerolespref',
- text => 'Change Roles Pref'},
+ text => 'Change '.$role.' Page Pref'},
},
{ action => 'verify_and_change_rolespref',
subroutine => \&verify_and_change_rolespref,
breadcrumb =>
{ href => '/adm/preferences?action=changerolespref',
- text => 'Change Roles Preferences'},
+ text => 'Change '.$role.' Page Preferences'},
printmenu => 'yes',
}));
@@ -1225,6 +1509,22 @@ sub handler {
}));
}
+ push (@Options,({ action => 'changeicons',
+ linktext => 'Change How Main Menu is Displayed',
+ href => '/adm/preferences',
+ subroutine => \&iconchanger,
+ breadcrumb =>
+ { href => '/adm/preferences?action=changeicons',
+ text => 'Change Main Menu'},
+ },
+ { action => 'verify_and_change_icons',
+ subroutine => \&verify_and_change_icons,
+ breadcrumb =>
+ { href => '/adm/preferences?action=changeicons',
+ text => 'Change Main Menu'},
+ printmenu => 'yes',
+ }));
+
if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
|| &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
.$env{'request.course.sec'})) {