Diff for /loncom/interface/createaccount.pm between versions 1.24 and 1.28

version 1.24, 2008/08/13 08:17:58 version 1.28, 2009/02/07 00:59:17
Line 58  sub handler { Line 58  sub handler {
     my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown');      my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown');
     my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain');      my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain');
   
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']);
       &Apache::lonacc::get_posted_cgi($r);
       &Apache::lonlocal::get_language_handle($r);
   
     if ($sso_username ne '' && $sso_domain ne '') {      if ($sso_username ne '' && $sso_domain ne '') {
         $domain = $sso_domain;           $domain = $sso_domain; 
     } else {       } else {
         $domain = &Apache::lonnet::default_login_domain();          $domain = &Apache::lonnet::default_login_domain();
           if (defined($env{'form.courseid'})) {
               if (&validate_course($env{'form.courseid'})) {
                   if ($env{'form.courseid'} =~ /^($match_domain)_($match_courseid)$/) {
                       $domain = $1; 
                   }
               }
           }
     }      }
     my $domdesc = &Apache::lonnet::domain($domain,'description');      my $domdesc = &Apache::lonnet::domain($domain,'description');
     my $contact_name = &mt('LON-CAPA helpdesk');      my $contact_name = &mt('LON-CAPA helpdesk');
Line 74  sub handler { Line 85  sub handler {
     my $include = $r->dir_config('lonIncludes');      my $include = $r->dir_config('lonIncludes');
     my $start_page;      my $start_page;
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']);  
     &Apache::lonacc::get_posted_cgi($r);  
     &Apache::lonlocal::get_language_handle($r);  
   
     my $handle = &Apache::lonnet::check_for_valid_session($r);      my $handle = &Apache::lonnet::check_for_valid_session($r);
     if ($handle ne '') {      if ($handle ne '') {
         $start_page =          $start_page =
Line 381  sub print_username_form { Line 388  sub print_username_form {
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                                          unam => 'username',                                           unam => 'username',
                                          udom => 'domain',                                           udom => 'domain',
                                          uemail => 'Email address in LON-CAPA',                                           uemail => 'E-mail address in LON-CAPA',
                                          proc => 'Proceed');                                           proc => 'Proceed');
     my $output;      my $output;
     if (ref($cancreate) eq 'ARRAY') {      if (ref($cancreate) eq 'ARRAY') {
Line 397  sub print_username_form { Line 404  sub print_username_form {
         }          }
         if (grep(/^email$/,@{$cancreate})) {          if (grep(/^email$/,@{$cancreate})) {
             $output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>';              $output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>';
             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.','<br />').'<br /><br />';  
             } else {  
                 $output .= '<br />';  
             }  
             my $emailform = '<input type="text" name="useremail" size="25" value="" />';  
             my $captchaform = &create_captcha();              my $captchaform = &create_captcha();
             my $submit_text = &mt('Request LON-CAPA account');              if ($captchaform) {
             $output .=  '<form name="createaccount" method="post" onSubmit="return validate_email()" action="/adm/createaccount">'.                  my $submit_text = &mt('Request LON-CAPA account');
                         &Apache::lonhtmlcommon::start_pick_box()."\n".                  my $emailform = '<input type="text" name="useremail" size="25" value="" />';
                         &Apache::lonhtmlcommon::row_title(&mt('E-mail address'),                  if (grep(/^login$/,@{$cancreate})) {
                                                          'LC_pick_box_title')."\n".                      $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.','<br />').'<br /><br />';
                         $emailform."\n".                  } else {
                         &Apache::lonhtmlcommon::row_closure(1).                      $output .= '<br />';
                         &Apache::lonhtmlcommon::row_title(&mt('Validation'),                  }
                                                          'LC_pick_box_title')."\n".                  $output .=  '<form name="createaccount" method="post" onSubmit="return validate_email()" action="/adm/createaccount">'.
                         $captchaform."\n".'<br /><br />';                              &Apache::lonhtmlcommon::start_pick_box()."\n".
             if ($courseid ne '') {                              &Apache::lonhtmlcommon::row_title(&mt('E-mail address'),
                 $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n";                                                                'LC_pick_box_title')."\n".
             }                              $emailform."\n".
             $output .= '<input type="submit" name="create_with_email" value="'.                               &Apache::lonhtmlcommon::row_closure(1).
                         $submit_text.'" />'.                              &Apache::lonhtmlcommon::row_title(&mt('Validation'),
                         &Apache::lonhtmlcommon::row_closure(1).                                                               'LC_pick_box_title')."\n".
                         &Apache::lonhtmlcommon::end_pick_box().'<br /><br />';                              $captchaform."\n".'<br /><br />';
             if ($courseid ne '') {                  if ($courseid ne '') {
                 $output .= &Apache::lonhtmlcommon::echo_form_input(['courseid']);                      $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; 
                   }
                   $output .= '<input type="submit" name="create_with_email" value="'. 
                               $submit_text.'" />'.
                               &Apache::lonhtmlcommon::row_closure(1).
                               &Apache::lonhtmlcommon::end_pick_box().'<br /><br />';
                   if ($courseid ne '') {
                       $output .= &Apache::lonhtmlcommon::echo_form_input(['courseid']);
                   }
                   $output .= '</form>';
               } else {
                   my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount';
                   if ($courseid ne '') {
                       $helpdesk .= '&courseid='.$courseid;
                   }
                   $output .= '<span class="LC_error">'.&mt('An error occurred generating the validation code[_1] required for an e-mail address to be used as username.','<br />').'</span><br /><br />'.&mt('[_1]Contact the helpdesk[_2] or [_3]reload[_2] the page and try again.','<a href="'.$helpdesk.'">','</a>','<a href="javascript:window.location.reload()">');
             }              }
             $output .= '</form></div>';              $output .= '</div>';
         }          }
     }      }
     if ($output eq '') {      if ($output eq '') {
Line 576  sub send_token { Line 592  sub send_token {
     my $token = &Apache::lonnet::tmpput(\%info,$server);      my $token = &Apache::lonnet::tmpput(\%info,$server);
     if ($token !~ /^error/ && $token ne 'no_such_host') {      if ($token !~ /^error/ && $token ne 'no_such_host') {
         my $esc_token = &escape($token);          my $esc_token = &escape($token);
         my $mailmsg = &mt('A request was submitted on [_1] for creation of a LON-CAPA account at the following institution: [_2].',localtime(time),$domdesc).' '.          my $showtime = localtime(time);
              &mt('To complete this process please open a web browser and enter the following'          my $mailmsg = &mt('A request was submitted on [_1] for creation of a LON-CAPA account at the following institution: [_2].',$showtime,$domdesc).' '.
                 .' URL in the address/location box: [_1]'               &mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]',
                 ,&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token);                   &Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token);
         my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name,          my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name,
                                                  $contact_email);                                                   $contact_email);
         if ($result eq 'ok') {          if ($result eq 'ok') {
Line 1084  sub invalid_state { Line 1100  sub invalid_state {
     } elsif ($error eq 'existinguser') {      } elsif ($error eq 'existinguser') {
         $msg = &mt('The e-mail address you provided is already in use as a username in LON-CAPA at this institution.');          $msg = &mt('The e-mail address you provided is already in use as a username in LON-CAPA at this institution.');
     } elsif ($error eq 'userrules') {      } elsif ($error eq 'userrules') {
         $msg = &mt('Username rules for this LON-CAPA at this institution do not allow the e-mail address you provided to be used as a username.');          $msg = &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.');
     } elsif ($error eq 'userformat') {      } elsif ($error eq 'userformat') {
         $msg = &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.');          $msg = &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.');
     } elsif ($error eq 'captcha') {      } elsif ($error eq 'captcha') {
Line 1115  sub linkto_email_help { Line 1131  sub linkto_email_help {
 sub create_captcha {  sub create_captcha {
     my ($output_dir,$db_dir) = @_;      my ($output_dir,$db_dir) = @_;
     my %captcha_params = &captcha_settings();      my %captcha_params = &captcha_settings();
     my $captcha = Authen::Captcha->new(      my ($output,$maxtries,$tries) = ('',10,0);
                                        output_folder => $captcha_params{'output_dir'},      while ($tries < $maxtries) {
                                        data_folder   => $captcha_params{'db_dir'},          $tries ++;
                                       );          my $captcha = Authen::Captcha->new (
     my $md5sum = $captcha->generate_code($captcha_params{'numchars'});                                             output_folder => $captcha_params{'output_dir'},
     my $output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n".                                             data_folder   => $captcha_params{'db_dir'},
                  &mt('Type in the letters/numbers shown below').'&nbsp;'.                                            );
                  '<input type="text" size="5" name="code" value="" /><br />'.          my $md5sum = $captcha->generate_code($captcha_params{'numchars'});
                  '<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png">';  
           if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') {
               $output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n".
                         &mt('Type in the letters/numbers shown below').'&nbsp;'.
                        '<input type="text" size="5" name="code" value="" /><br />'.
                        '<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png">';
               last;
           }
       }
     return $output;      return $output;
 }  }
   

Removed from v.1.24  
changed lines
  Added in v.1.28


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>