--- loncom/interface/createaccount.pm 2014/02/12 20:47:40 1.58 +++ loncom/interface/createaccount.pm 2014/02/19 17:20:32 1.59 @@ -4,7 +4,7 @@ # kerberos, or SSO) or an e-mail address. Requests to use an e-mail address as # username may be processed automatically, or may be queued for approval. # -# $Id: createaccount.pm,v 1.58 2014/02/12 20:47:40 raeburn Exp $ +# $Id: createaccount.pm,v 1.59 2014/02/19 17:20:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -291,6 +291,7 @@ sub print_footer { &Apache::lonhtmlcommon::echo_form_input(['backto','logtoken', 'token','serverid','uname','upass','phase','create_with_email', 'code','crypt','cfirstname','clastname', + 'recaptcha_challenge_field','recaptcha_response_field', 'cmiddlename','cgeneration','cpermanentemail','cid']). ''); } @@ -321,12 +322,19 @@ sub selfenroll_crumbs { } sub javascript_setforms { - my ($now,$emailusername) = @_; + my ($now,$emailusername,$captcha) = @_; my $setuserinfo; if (ref($emailusername) eq 'HASH') { foreach my $key (sort(keys(%{$emailusername}))) { $setuserinfo .= ' server.elements.'.$key.'.value=client.elements.'.$key.'.value;'."\n"; } + if ($captcha eq 'original') { + $setuserinfo .= ' server.elements.code.value=client.elements.code.value;'."\n". + ' server.elements.crypt.value=client.elements.crypt.value;'."\n"; + } elsif ($captcha eq 'recaptcha') { + $setuserinfo .= ' server.elements.recaptcha_challenge_field.value=client.elements.recaptcha_challenge_field.value;'."\n". + ' server.elements.recaptcha_response_field.value=client.elements.recaptcha_response_field.value;'."\n"; + } } my $js = < @@ -343,8 +351,6 @@ sub javascript_setforms { if (context == 'email') { $setuserinfo } - server.elements.code.value=client.elements.code.value; - server.elements.crypt.value=client.elements.crypt.value; uextkey=client.elements.uextkey.value; lextkey=client.elements.lextkey.value; @@ -428,29 +434,35 @@ ENDSCRIPT sub print_username_form { my ($r,$domain,$domdesc,$cancreate,$now,$lonhost,$include,$courseid,$gotlondes,$emailusername) = @_; - my %lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash ( unam => 'username', udom => 'domain', uemail => 'E-mail address in LON-CAPA', - proc => 'Proceed'); + proc => 'Proceed', + crac => 'Create account with a username provided by this institution', + clca => 'Create LON-CAPA account', + type => 'Type in your log-in ID and password to find out.', + plse => 'Please provide a password for your new account.', + info => 'Please provide user information and a password for your new account.', + yopw => 'Your password will be encrypted when sent (and stored).', + ); my $output; if (ref($cancreate) eq 'ARRAY') { if (grep(/^login$/,@{$cancreate})) { my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) { - $output = '

'.&mt('Create account with a username provided by this institution').'

'; - my $submit_text = &mt('Create LON-CAPA account'); - $output .= &mt('If you already have a log-in ID at this institution,[_1] you may be able to use it for LON-CAPA.','
'). + $output = '

'.$lt{'crac'}.'

'; + $output .= &mt('If you already have a log-in ID at this institution [_1]you may be able to use it for LON-CAPA.','
'). '

'. - &mt('Type in your log-in ID and password to find out.'). + $lt{'type'}. '

'; - $output .= &login_box($now,$lonhost,$courseid,$submit_text, + $output .= &login_box($now,$lonhost,$courseid,$lt{'clca'}, $domain,'createaccount').'
'; } } if (grep(/^email(|approval)$/,@{$cancreate})) { $output .= '

'.&mt('Create account with an e-mail address as your username').'

'; - my ($captchaform,$error) = &Apache::loncommon::captcha_display('usercreation',$lonhost); + my ($captchaform,$error,$captcha) = &Apache::loncommon::captcha_display('usercreation',$lonhost); if ($error) { my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; if ($courseid ne '') { @@ -463,23 +475,24 @@ sub print_username_form { '','',''); } else { if (grep(/^login$/,@{$cancreate})) { - $output .= &mt('Provide your e-mail address to request a LON-CAPA account,[_1] if you do not have a log-in ID at your institution.','
').'

'; - } else { - $output .= '
'; - } - $output .= &mt('Please provide user information and a password for your new account.').'
'. - &mt('Your password, which must contain at least seven characters, will be sent to the LON-CAPA server in an encrypted form.').'
'; - if (grep(/^login$/,@{$cancreate})) { - $output .= &mt('Provide your e-mail address to request a LON-CAPA account,[_1] if you do not have a log-in ID at your institution.','
').'

'; - } else { - $output .= '
'; - } - $output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername); - if (grep(/^login$/,@{$cancreate})) { - $output .= &mt('Provide your e-mail address to request a LON-CAPA account,[_1] if you do not have a log-in ID at your institution.','
').'

'; + $output .= &mt('If you do not have a log-in ID at your institution, [_1]provide your e-mail address to request a LON-CAPA account.','
').'

'. + $lt{'plse'}.'
'. + $lt{'yopw'}.'
'; } else { - $output .= '
'; + my $prompt = $lt{'plse'}; + if (ref($emailusername) eq 'HASH') { + foreach my $key (keys(%{$emailusername})) { + if ($emailusername->{$key}) { + $prompt = $lt{'info'}; + last; + } + } + } + $output .= $prompt.'
'. + $lt{'yopw'}.'
'; } + $output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform, + $courseid,$gotlondes,$emailusername,$captcha); } $output .= '
'; } @@ -504,8 +517,8 @@ sub login_box { my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount', $lonhost); $output = &serverform($logtoken,$lonhost,undef,$courseid,$context); - my $unameform = ''; - my $upassform = ''; + my $unameform = ''; + my $upassform = ''; $output .= '
'."\n". &Apache::lonhtmlcommon::start_pick_box()."\n". &Apache::lonhtmlcommon::row_title($titles{$context}, @@ -776,7 +789,7 @@ sub start_session { # Stores token to store DES-key and stage during creation session # sub print_dataentry_form { - my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername) = @_; + my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername,$captcha) = @_; my ($error,$output); unless ($gotlondes) { if (open(my $jsh,"<$include/londes.js")) { @@ -784,7 +797,7 @@ sub print_dataentry_form { $r->print($line); } close($jsh); - $output = &javascript_setforms($now,$emailusername)."\n"; + $output = &javascript_setforms($now,$emailusername,$captcha)."\n"; $gotlondes = 1; } } @@ -804,14 +817,23 @@ sub print_dataentry_form { $output .= ''."\n"; } } + if ($captcha eq 'original') { + $output .= ' + + +'; + } elsif ($captcha eq 'recaptcha') { + $output .= ' + + +'; + } $output .= <<"ENDSERVERFORM"; - -
@@ -879,6 +901,8 @@ sub get_creation_controls { } if (ref($usercreation->{'cancreate'}{'emailusername'}) eq 'HASH') { $emailusername = $usercreation->{'cancreate'}{'emailusername'}; + } else { + $emailusername = {'lastname' => '1', 'firstname' => 1, }; } } }