--- loncom/interface/lonpreferences.pm 2006/05/08 22:25:17 1.86 +++ loncom/interface/lonpreferences.pm 2012/10/04 13:41:10 1.199 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.86 2006/05/08 22:25:17 albertel Exp $ +# $Id: lonpreferences.pm,v 1.199 2012/10/04 13:41:10 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,8 @@ use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonlocal; use Apache::lonnet; +use LONCAPA::lonauthcgi(); +use LONCAPA(); # # Write lonnet::passwd to do the call below. @@ -97,6 +99,12 @@ sub des_decrypt { sub wysiwygchanger { my $r = shift; + Apache::lonhtmlcommon::add_breadcrumb( + { href => '/adm/preferences?action=changewysiwyg', + text => 'Change WYSIWYG Preferences'}); + $r->print(Apache::loncommon::start_page('Content Display Settings')); + $r->print(Apache::lonhtmlcommon::breadcrumbs('Change WYSIWYG Preferences')); + my %userenv = &Apache::lonnet::get ('environment',['wysiwygeditor']); my $onselect='checked="checked"'; @@ -107,14 +115,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(<- +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 +1609,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 +1619,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");'.$helplink.' | '. - ''.$optiontext.' | '. - '