--- loncom/interface/lonpreferences.pm 2006/06/14 18:54:23 1.87 +++ loncom/interface/lonpreferences.pm 2009/10/08 21:15:19 1.125.4.6 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.87 2006/06/14 18:54:23 albertel Exp $ +# $Id: lonpreferences.pm,v 1.125.4.6 2009/10/08 21:15:19 raeburn 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. @@ -107,14 +108,19 @@ sub wysiwygchanger { } my $switchoff=&mt('Disable WYSIWYG editor'); my $switchon=&mt('Enable WYSIWYG editor'); + my $warning=''; + if ($env{'user.adv'}) { + $warning.="
".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."
"; + } $r->print(<' + .&mt('Change the name that is displayed in your posts.') + .'
' + ); + $r->print('- +sub client_form { + my ($caller,$hexkey,$currentpass,$defdom) = @_; + my %lt=&Apache::lonlocal::texthash( + 'email' => 'E-mail Address', + 'username' => 'Username', + 'domain' => 'Domain', + 'currentpass' => 'Current Password', + 'newpass' => 'New Password', + 'confirmpass' => 'Confirm Password', + 'changepass' => 'Save'); + my $output = '
Current password: | -|
New password: | -|
Confirm password: | -|
- - |
\n". + &mt("Invalid username and/or domain")."\n
", + $caller,$mailtoken); + return 1; + } + } else { + &passwordchanger($r,"\n". + &mt("Username and domain were blank")."\n
", + $caller,$mailtoken); + return 1; + } + } else { + $user = $env{'user.name'}; + $domain = $env{'user.domain'}; + $homeserver = $env{'user.home'}; + } my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain); # Check for authentication types that allow changing of the password. - return if ($currentauth !~ /^(unix|internal):/); + if ($currentauth !~ /^(unix|internal):/) { + if ($caller eq 'reset_by_email') { + &passwordchanger($r,"\n". + &mt("Authentication type for this user can not be changed by this mechanism"). + "\n
", + $caller,$mailtoken); + return 1; + } else { + return; + } + } # my $currentpass = $env{'form.currentpass'}; my $newpass1 = $env{'form.newpass_1'}; @@ -737,8 +1432,9 @@ sub verify_and_change_password { unless (defined($currentpass) && defined($newpass1) && defined($newpass2) ){ - &passwordchanger($r,"\nERROR". - "Password data was blank.\n
"); + &passwordchanger($r,"\n". + &mt("One or more password fields were blank"). + "\n
",$caller,$mailtoken); return; } # Get the keys @@ -746,10 +1442,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.'); + } + my $unable=&mt("Unable to retrieve saved token for password decryption"); $r->print(<!"\#$%&\'()*+,-./0123456789:;<=>?\@ 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 + my $message; if ($result =~ /^ok$/) { - $r->print(<<"ENDTEXT"); -
'.$lt{'thde'}.'
'); + $r->print(&Apache::loncommon::start_data_table()); $r->print(<<"END");