--- loncom/interface/lonpreferences.pm 2006/05/08 22:25:17 1.86 +++ loncom/interface/lonpreferences.pm 2013/03/19 00:46:35 1.196.4.10 @@ -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.196.4.10 2013/03/19 00:46:35 raeburn 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(<' + .&mt('Change the name that is displayed in your posts.') + .'
' + ); + $r->print('+ + +
' + .&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' + ,'','') + .'
' + ); + return; + } + if (defined($data{time})) { + if (time - $data{'time'} < 7200) { + $user = $data{'username'}; + $domain = $data{'domain'}; + $currentpass = $data{'temppasswd'}; + } else { + $r->print( + '' + .&mt('Sorry, the token generated when you requested' + .' a password reset has expired.') + .'
' + ); + return; + } + } else { + $r->print( + '' + .&mt('Sorry, the URL generated when you requested reset of' + .' your password contained incomplete information.') + .'
' + ); + return; + } + if (&Apache::lonnet::domain($domain) eq '') { + $domain = $r->dir_config('lonDefDomain'); + } + } else { + $r->print( + '' + .&mt('Page requested in unexpected context') + .'
' + ); + return; + } my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain); # Check for authentication types that allow changing of the password. return if ($currentauth !~ /^(unix|internal):/); @@ -641,12 +1375,13 @@ sub passwordchanger { .$ukey_npass2 . $lkey_npass2, $lonhost); # Hexify the keys for output as javascript variables - $ukey_cpass = hex($ukey_cpass); - $lkey_cpass = hex($lkey_cpass); - $ukey_npass1= hex($ukey_npass1); - $lkey_npass1= hex($lkey_npass1); - $ukey_npass2= hex($ukey_npass2); - $lkey_npass2= hex($lkey_npass2); + my %hexkey; + $hexkey{'ukey_cpass'} = hex($ukey_cpass); + $hexkey{'lkey_cpass'} = hex($lkey_cpass); + $hexkey{'ukey_npass1'} = hex($ukey_npass1); + $hexkey{'lkey_npass1'} = hex($lkey_npass1); + $hexkey{'ukey_npass2'} = hex($ukey_npass2); + $hexkey{'lkey_npass2'} = hex($lkey_npass2); # Output javascript to deal with passwords # Output DES javascript { @@ -654,8 +1389,26 @@ sub passwordchanger { my $jsh=Apache::File->new($include."/londes.js"); $r->print(<$jsh>); } + $r->print(&jscript_send($caller)); $r->print(<+ +ENDFORM + $r->print(&server_form($logtoken,$caller,$mailtoken)); + $r->print(&client_form($caller,\%hexkey,$currentpass,$domain)); + + # + return; +} + +sub jscript_send { + my ($caller) = @_; + my $output = qq| + -$errormessage +|; +} -
- +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', + ); -
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 +1580,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 +1590,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.' | '. - '