File:  [LON-CAPA] / loncom / interface / createaccount.pm
Revision 1.7: download - view: text, annotated - select for diffs
Tue Jul 1 16:41:57 2008 UTC (16 years ago) by bisitz
Branches: MAIN
CVS tags: HEAD
Wording and optimized &mt() calls:
e.g., same text for same function; use already existing phrases; links as parameters; no html inside mt(), etc.

    1: # The LearningOnline Network
    2: # Allow visitors to create a user account with the username being either an 
    3: # institutional log-in ID (institutional authentication required - localauth
    4: #  or kerberos) or an e-mail address.
    5: #
    6: # $Id: createaccount.pm,v 1.7 2008/07/01 16:41:57 bisitz Exp $
    7: #
    8: # Copyright Michigan State University Board of Trustees
    9: #
   10: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   11: #
   12: # LON-CAPA is free software; you can redistribute it and/or modify
   13: # it under the terms of the GNU General Public License as published by
   14: # the Free Software Foundation; either version 2 of the License, or
   15: # (at your option) any later version.
   16: #
   17: # LON-CAPA is distributed in the hope that it will be useful,
   18: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   19: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20: # GNU General Public License for more details.
   21: #
   22: # You should have received a copy of the GNU General Public License
   23: # along with LON-CAPA; if not, write to the Free Software
   24: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25: #
   26: # /home/httpd/html/adm/gpl.txt
   27: #
   28: # http://www.lon-capa.org/
   29: #
   30: #
   31: package Apache::createaccount;
   32: 
   33: use strict;
   34: use Apache::Constants qw(:common);
   35: use Apache::lonacc;
   36: use Apache::lonnet;
   37: use Apache::loncommon;
   38: use Apache::lonlocal;
   39: use Apache::lonauth;
   40: use Apache::resetpw;
   41: use Authen::Captcha;
   42: use DynaLoader; # for Crypt::DES version
   43: use Crypt::DES;
   44: use LONCAPA qw(:DEFAULT :match);
   45: 
   46: sub handler {
   47:     my $r = shift;
   48:     &Apache::loncommon::content_type($r,'text/html');
   49:     $r->send_http_header;
   50:     if ($r->header_only) {
   51:         return OK;
   52:     }
   53:     
   54:     my $domain;
   55: 
   56:     my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown');
   57:     my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain');
   58: 
   59:     if ($sso_username ne '' && $sso_domain ne '') {
   60:         $domain = $sso_domain; 
   61:     } else { 
   62:         $domain = &Apache::lonnet::default_login_domain();
   63:     }
   64:     my $domdesc = &Apache::lonnet::domain($domain,'description');
   65:     my $contact_name = &mt('LON-CAPA helpdesk');
   66:     my $contact_email =  $r->dir_config('lonSupportEMail');
   67:     my $lonhost = $r->dir_config('lonHostID');
   68:     my $include = $r->dir_config('lonIncludes');
   69:     my $start_page;
   70: 
   71:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']);
   72:     &Apache::lonacc::get_posted_cgi($r);
   73:     &Apache::lonlocal::get_language_handle($r);
   74: 
   75:     my $handle = &Apache::lonnet::check_for_valid_session($r);
   76:     if ($handle ne '') {
   77:         $start_page =
   78:             &Apache::loncommon::start_page('Already logged in');
   79:         my $end_page =
   80:             &Apache::loncommon::end_page();
   81:         $r->print($start_page."\n".'<h2>'.&mt('You are already logged in').'</h2>'.
   82:                   '<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]logout[_4].','<a href="/adm/roles">','</a>','<a href="/adm/logout">','</a>').
   83:                   '</p><p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'.$end_page);
   84:        return OK;
   85:     }
   86:     $start_page =
   87:         &Apache::loncommon::start_page('Create a user account in LON-CAPA','',
   88:                                        {'no_inline_link'   => 1,});
   89:     if ($env{'form.phase'} eq 'username_activation') {
   90:         if ($env{'form.udom'} ne '') {
   91:             $domain = $env{'form.udom'};
   92:         }
   93:     }
   94:     my @cancreate;
   95:     my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
   96:     if (ref($domconfig{'usercreation'}) eq 'HASH') {
   97:         if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
   98:             if (ref($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}) eq 'ARRAY') {
   99:                 @cancreate = @{$domconfig{'usercreation'}{'cancreate'}{'selfcreate'}};
  100:             } elsif (($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') &&
  101:                      ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne '')) {
  102:                 @cancreate = ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'});
  103:             }
  104:         }
  105:     }
  106: 
  107:     if (@cancreate == 0) {
  108:         &print_header($r,$start_page);
  109:         my $output = &mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted in the domain: [_1] ([_2]).',$domain,$domdesc);
  110:         $r->print($output);
  111:         $r->print(&Apache::loncommon::end_page());
  112:         return OK;
  113:     }
  114: 
  115:     my $courseid;
  116:     if (defined($env{'form.courseid'})) {
  117:         $courseid = &validate_course($env{'form.courseid'});
  118:     }
  119: 
  120:     if ($sso_username ne '') {
  121:         &print_header($r,$start_page);
  122:         my ($output,$msg);
  123:         if (grep(/^sso$/,@cancreate)) {
  124:             $msg = &mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account in this domain.");
  125:             ($output, my $checkfail) = &username_check($sso_username,$domain,$domdesc,$courseid);
  126:             if ($checkfail) {
  127:                 $msg .= &mt('A LON-CAPA account may not be created with the username you use.');
  128:             } else {
  129:                 $msg .= &mt('To create one, use the table below to provide information about yourself (if appropriate), then click the "Create LON-CAPA account" button.');
  130:             }
  131:         } else {
  132:             $msg = &mt("Although your username and password were authenticated by your institution's Single Sign On system, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.");
  133:         }
  134:         $r->print('<h4>'.$msg.'</h4>'.$output);
  135:         $r->print(&Apache::loncommon::end_page());
  136:         return OK;
  137:     }
  138: 
  139:     my ($output,$nostart,$noend);
  140:     my $token = $env{'form.token'};
  141:     if ($token) {
  142:         ($output,$nostart,$noend) = 
  143:             &process_mailtoken($r,$token,$contact_name,$contact_email,$domain,
  144:                                $domdesc,$lonhost,$include,$start_page);
  145:         if ($nostart) {
  146:             if ($noend) {
  147:                 return OK;
  148:             } else {
  149:                 $r->print($output);
  150:                 $r->print(&Apache::loncommon::end_page());
  151:                 return OK;
  152:             }
  153:         } else {
  154:             &print_header($r,$start_page);
  155:             $r->print($output);
  156:             $r->print(&Apache::loncommon::end_page());
  157:             return OK;
  158:         }
  159:     }
  160: 
  161:     if ($env{'form.phase'} eq 'username_activation') {
  162:         (my $result,$output,$nostart) = 
  163:             &username_activation($r,$env{'form.uname'},$domain,$domdesc,
  164:                                  $lonhost,$courseid);
  165:         if ($result eq 'ok') {
  166:             if ($nostart) {
  167:                 return OK;
  168:             }
  169:         }
  170:         &print_header($r,$start_page);
  171:         $r->print($output);
  172:         $r->print(&Apache::loncommon::end_page());
  173:         return OK;
  174:     }
  175: 
  176:     &print_header($r,$start_page);
  177:     if ($env{'form.create_with_email'}) {
  178:         $output = &process_email_request($env{'form.useremail'},$domain,$domdesc,
  179:                                          $contact_name,$contact_email,\@cancreate,
  180:                                          $lonhost,$domconfig{'usercreation'},
  181:                                          $courseid);
  182:     } elsif ($env{'form.phase'} eq 'username_validation') {
  183:         $output = &username_validation($env{'form.uname'},$domain,$domdesc,
  184:                                        $contact_name,$contact_email,$courseid);
  185:     } elsif (!$token) {
  186:         my $now=time;
  187:         if (grep(/^login$/,@cancreate)) {
  188:             my $jsh=Apache::File->new($include."/londes.js");
  189:             $r->print(<$jsh>);
  190:             $r->print(&javascript_setforms($now));
  191:         }
  192:         $output = &print_username_form($domain,$domdesc,\@cancreate,$now,$lonhost,
  193:                                        $courseid); 
  194:     }
  195:     $r->print($output);
  196:     $r->print(&Apache::loncommon::end_page());
  197:     return OK;
  198: }
  199: 
  200: sub print_header {
  201:     my ($r,$start_page) = @_;
  202:     $r->print($start_page);
  203:     &Apache::lonhtmlcommon::clear_breadcrumbs();
  204:     &Apache::lonhtmlcommon::add_breadcrumb
  205:     ({href=>"/adm/createuser",
  206:       text=>"New username"});
  207:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Create account'));
  208:     return;
  209: }
  210: 
  211: sub validate_course {
  212:     my ($courseid) = @_;
  213:     my ($cdom,$cnum) = ($courseid =~ /^($match_domain)_($match_courseid)$/);
  214:     if (($cdom ne '') && ($cnum ne '')) {
  215:         if (&Apache::lonnet::is_course($cdom,$cnum)) {
  216:             return ($courseid);
  217:         }
  218:     }
  219:     return;
  220: }
  221: 
  222: sub javascript_setforms {
  223:     my ($now) =  @_;
  224:     my $js = <<ENDSCRIPT;
  225:  <script language="JavaScript">
  226:     function send() {
  227:         this.document.server.elements.uname.value = this.document.client.elements.uname.value;
  228:         uextkey=this.document.client.elements.uextkey.value;
  229:         lextkey=this.document.client.elements.lextkey.value;
  230:         initkeys();
  231: 
  232:         this.document.server.elements.upass.value
  233:             = crypted(this.document.client.elements.upass$now.value);
  234: 
  235:         this.document.client.elements.uname.value='';
  236:         this.document.client.elements.upass$now.value='';
  237: 
  238:         this.document.server.submit();
  239:         return false;
  240:     }
  241:  </script>
  242: ENDSCRIPT
  243:     return $js;
  244: }
  245: 
  246: sub javascript_checkpass {
  247:     my ($now) = @_;
  248:     my $nopass = &mt('You must enter a password.');
  249:     my $mismatchpass = &mt('The passwords you entered did not match.').'\\n'.
  250:                        &mt('Please try again.'); 
  251:     my $js = <<"ENDSCRIPT";
  252: <script type="text/javascript" language="JavaScript">
  253:     function checkpass() {
  254:         var upass = this.document.client.elements.upass$now.value;
  255:         var upasscheck = this.document.client.elements.upasscheck$now.value;
  256:         if (upass == '') {
  257:             alert("$nopass");
  258:             return;
  259:         }
  260:         if (upass == upasscheck) {
  261:             this.document.client.elements.upasscheck$now.value='';
  262:             send();
  263:             return;
  264:         } else {
  265:             alert("$mismatchpass");
  266:             return;
  267:         } 
  268:     }
  269: </script>
  270: ENDSCRIPT
  271:     return $js;
  272: }
  273: 
  274: sub print_username_form {
  275:     my ($domain,$domdesc,$cancreate,$now,$lonhost,$courseid) = @_;
  276:     my %lt = &Apache::lonlocal::texthash(
  277:                                          unam => 'username',
  278:                                          udom => 'domain',
  279:                                          uemail => 'Email address in LON-CAPA',
  280:                                          proc => 'Proceed');
  281:     my $output;
  282:     if (ref($cancreate) eq 'ARRAY') {
  283:         if (grep(/^login$/,@{$cancreate})) {
  284:             my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
  285:             if ((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) {
  286:                 $output = '<div class="LC_left_float"><h3>'.&mt('Create account with a username provided by your institution').'</h3>';
  287:                 $output .= &mt('If you already have a log-in ID at your institution, you may be able to use it for LON-CAPA.').'<br />'.&mt('Type in your log-in ID and password to find out.').'<br /><br />';
  288:                 my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
  289:                 my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
  290:                 my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
  291:                                                    $lonhost);
  292:                 $output .= &serverform($logtoken,$lonhost,undef,$courseid);
  293:                 my $unameform = '<input type="text" name="uname" size="10" value="" />';
  294:                 my $upassform = '<input type="password" name="upass'.$now.'" size="10" />';
  295:                 my $submit_text = &mt('Create LON-CAPA account');
  296:                 $output .= '<form name="client" method="post" action="/adm/createaccount">'."\n". 
  297:                            &Apache::lonhtmlcommon::start_pick_box()."\n".
  298:                            &Apache::lonhtmlcommon::row_title(&mt('Log-in ID'),
  299:                                                         'LC_pick_box_title')."\n".
  300:                            $unameform."\n".
  301:                            &Apache::lonhtmlcommon::row_closure(1)."\n".
  302:                            &Apache::lonhtmlcommon::row_title(&mt('Password'),
  303:                                                         'LC_pick_box_title')."\n".
  304:                            $upassform."\n".'<br /><br />'."\n".
  305:                            '<input type="button" name="username_validation" value="'.
  306:                            $submit_text.'" onclick="javascript:send()" />'."\n". 
  307:                            &Apache::lonhtmlcommon::row_closure(1)."\n".
  308:                            &Apache::lonhtmlcommon::end_pick_box().'<br /><br />'."\n".
  309:                            '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
  310:                            '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
  311:                            '</form></div>';
  312:             }
  313:         }
  314:         if (grep(/^email$/,@{$cancreate})) {
  315:             $output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>';
  316:             if (grep(/^login$/,@{$cancreate})) {
  317:                 $output .= &mt('Provide your e-mail address to request a LON-CAPA account if you do not have a log-in ID at your institution.').'<br /><br />';
  318:             } else {
  319:                 $output .= '<br />';
  320:             }
  321:             my $emailform = '<input type="text" name="useremail" size="25" value="" />';
  322:             my $captchaform = &create_captcha();
  323:             my $submit_text = &mt('Request LON-CAPA account');
  324:             $output .=  '<form name="createaccount" method="post" onsubmit="validate_email();" action="/adm/createaccount">'.
  325:                         &Apache::lonhtmlcommon::start_pick_box()."\n".
  326:                         &Apache::lonhtmlcommon::row_title(&mt('E-mail address'),
  327:                                                          'LC_pick_box_title')."\n".
  328:                         $emailform."\n".
  329:                         &Apache::lonhtmlcommon::row_closure(1).
  330:                         &Apache::lonhtmlcommon::row_title(&mt('Validation'),
  331:                                                          'LC_pick_box_title')."\n".
  332:                         $captchaform."\n".'<br /><br />';
  333:             if ($courseid ne '') {
  334:                 $output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; 
  335:             }
  336:             $output .= '<input type="submit" name="create_with_email" value="'. 
  337:                         $submit_text.'" />'.
  338:                         &Apache::lonhtmlcommon::row_closure(1).
  339:                         &Apache::lonhtmlcommon::end_pick_box().'<br /><br /></form>'.
  340:                         '</div>';
  341:         }
  342:     }
  343:     if ($output eq '') {
  344:         $output = &mt('Creation of a new user account using an e-mail address or an institutional log-in ID as your username is not permitted in the domain: [_1] ([_2])',$domain,$domdesc);
  345:     } else {
  346:         $output .= '<div class="LC_clear_float_footer"></div>';
  347:     }
  348:     return $output;
  349: }
  350: 
  351: sub process_email_request {
  352:     my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate,
  353:         $server,$settings,$courseid) = @_;
  354:     my $useremail = $env{'form.useremail'};
  355:     my $output;
  356:     if (ref($cancreate) eq 'ARRAY') {
  357:         if (!grep(/^email$/,@{$cancreate})) {
  358:             $output = &invalid_state('noemails',$domdesc,
  359:                                      $contact_name,$contact_email);
  360:             return $output;
  361:         } elsif ($useremail !~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {
  362:             $output = &invalid_state('baduseremail',$domdesc,
  363:                                      $contact_name,$contact_email);
  364:             return $output;
  365:         } else {
  366:             my $uhome = &Apache::lonnet::homeserver($useremail,$domain);
  367:             if ($uhome ne 'no_host') {
  368:                 $output = &invalid_state('existinguser',$domdesc,
  369:                                          $contact_name,$contact_email);
  370:                 return $output;
  371:             } else {
  372:                 my $code = $env{'form.code'};
  373:                 my $md5sum = $env{'form.crypt'};
  374:                 my %captcha_params = &captcha_settings();
  375:                 my $captcha = Authen::Captcha->new(
  376:                                   output_folder => $captcha_params{'output_dir'},
  377:                                   data_folder   => $captcha_params{'db_dir'},
  378:                                  );
  379:                 my $captcha_chk = $captcha->check_code($code,$md5sum);
  380:                 my %captcha_hash = (
  381:                                   0       => 'Code not checked (file error)',
  382:                                   -1      => 'Failed: code expired',
  383:                                   -2      => 'Failed: invalid code (not in database)',
  384:                                   -3      => 'Failed: invalid code (code does not match crypt)',
  385:                                    );
  386:                 if ($captcha_chk != 1) {
  387:                     $output = &invalid_state('captcha',$domdesc,$contact_name,
  388:                                              $contact_email,$captcha_hash{$captcha_chk});
  389:                     return $output;
  390:                 }
  391:                 my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);
  392:                 my $uhome=&Apache::lonnet::homeserver($useremail,$domain);
  393:                 if ($uhome eq 'no_host') {
  394:                     my $checkhash;
  395:                     my $checks = { 'username' => 1 };
  396:                     $checkhash->{$useremail.':'.$domain} = { 'newuser' => 1, };
  397:                     &Apache::loncommon::user_rule_check($checkhash,$checks,
  398:                           \%alerts,\%rulematch,\%inst_results,\%curr_rules,
  399:                           \%got_rules);
  400:                     if (ref($alerts{'useremail'}) eq 'HASH') {
  401:                         if (ref($alerts{'useremail'}{$domain}) eq 'HASH') {
  402:                             if ($alerts{'username'}{$domain}{$useremail}) {
  403:                                 $output = &invalid_state('userrules',$domdesc,
  404:                                                          $contact_name,$contact_email);
  405:                                 return $output;
  406:                             }
  407:                         }
  408:                     }
  409:                     my $format_msg = 
  410:                         &guest_format_check($useremail,$domain,$cancreate,
  411:                                             $settings);
  412:                     if ($format_msg) {
  413:                         $output = &invalid_state('userformat',$domdesc,$contact_name,
  414:                                                  $contact_email,$format_msg);
  415:                         return $output;
  416:                     }
  417:                 }
  418:             }
  419:         }
  420:         $output = &send_token($domain,$useremail,$server,$domdesc,$contact_name,
  421:                           $contact_email,$courseid);
  422:     }
  423:     return $output;
  424: }
  425: 
  426: sub send_token {
  427:     my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid) = @_;
  428:     my $msg = &mt('Thank you for your request to create a new LON-CAPA account.').'<br /><br />';
  429:     my $now = time;
  430:     my %info = ('ip'         => $ENV{'REMOTE_ADDR'},
  431:                 'time'       => $now,
  432:                 'domain'     => $domain,
  433:                 'username'   => $email,
  434:                 'courseid'   => $courseid);
  435:     my $token = &Apache::lonnet::tmpput(\%info,$server);
  436:     if ($token !~ /^error/ && $token ne 'no_such_host') {
  437:         my $esc_token = &escape($token);
  438:         my $mailmsg = &mt('A request was submitted on [_1] for creation of a LON-CAPA account in the [_2] domain.',localtime(time),$domdesc).' '.
  439:              &mt('To complete this process please open a web browser and enter the following'
  440:                 .' URL in the address/location box: [_1]'
  441:                 ,&Apache::lonnet::absolute_url().'/adm/createaccount?token=$esc_token');
  442:         my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name,
  443:                                                  $contact_email);
  444:         if ($result eq 'ok') {
  445:             $msg .= &mt('A message has been sent to the e-mail address you provided.').'<br />'.&mt('The message includes the web address for the link you will use to complete the account creation process.').'<br />'.&mt("The link included in the message will be valid for the next [_1]two[_2] hours.",'<b>','</b>');
  446:         } else {
  447:             $msg .= &mt('An error occurred when sending a message to the e-mail address you provided.')
  448:                    .' '.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);
  449:         }
  450:     } else {
  451:         $msg .= &mt('An error occurred creating a token required for the account creation process.')
  452:                .' '.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);
  453:     }
  454:     return $msg;
  455: }
  456: 
  457: sub process_mailtoken {
  458:     my ($r,$token,$contact_name,$contact_email,$domain,$domdesc,$lonhost,
  459:         $include,$start_page) = @_;
  460:     my ($msg,$nostart,$noend);
  461:     my %data = &Apache::lonnet::tmpget($token);
  462:     my $now = time;
  463:     if (keys(%data) == 0) {
  464:         $msg = &mt('Sorry, the URL you provided to complete creation of a new LON-CAPA account was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid.')
  465:               .' '.&mt('Please submit a [_1]new request[_2] for account creation and follow the new link page included in the e-mail that will be sent to you.','<a href="/adm/createaccount">','</a>');
  466:         return $msg;
  467:     }
  468:     if (($data{'time'} =~ /^\d+$/) &&
  469:         ($data{'domain'} ne '') &&
  470:         ($data{'username'}  =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/)) {
  471:         if ($now - $data{'time'} < 7200) {
  472:             if ($env{'form.phase'} eq 'createaccount') {
  473:                 my ($result,$output) = &create_account($r,$domain,$lonhost,
  474:                                                        $data{'username'},$domdesc);
  475:                 if ($result eq 'ok') {
  476:                     $msg = $output; 
  477:                     my $shownow = localtime($now);
  478:                     my $mailmsg = &mt('A LON-CAPA account in the [_1] domain has been created [_2] from IP address: [_3].  If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n";
  479:                     my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
  480:                                                                  $mailmsg,$contact_name,
  481:                                                                  $contact_email);
  482:                     if ($mailresult eq 'ok') {
  483:                         $msg .= &mt('An e-mail confirming creation of your new LON-CAPA account has been sent to [_1].',$data{'username'});
  484:                     } else {
  485:                         $msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'});
  486:                     }
  487:                     my %form = &start_session($r,$data{'username'},$domain, 
  488:                                               $lonhost,$data{'courseid'},
  489:                                               $token);
  490:                     $nostart = 1;
  491:                     $noend = 1;
  492:                 } else {
  493:                     $msg .= &mt('A problem occurred when attempting to create your new LON-CAPA account.')
  494:                            .'<br />'.$output
  495: #                           .&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,'<a href="mailto:'.$contact_email.'">'.$contact_email.'</a>');
  496:                            .&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);
  497:                 }
  498:                 my $delete = &Apache::lonnet::tmpdel($token);
  499:             } else {
  500:                 $msg .= &mt('Please provide user information and a password for your new account.').'<br />'.&mt('Your password, which must contain at least seven characters, will be sent to the LON-CAPA server in an encrypted form.').'<br />';
  501:                 $msg .= &print_dataentry_form($r,$domain,$lonhost,$include,$token,$now,$data{'username'},$start_page);
  502:                 $nostart = 1;
  503:             }
  504:         } else {
  505:             $msg = &mt('Sorry, the token generated when you requested creation of an account has expired.')
  506:                   .' '.&mt('Please submit a [_1]new request[_2] for account creation and follow the new link included in the e-mail that will be sent to you.','<a href="/adm/createaccount">','</a>');
  507:             }
  508:     } else {
  509:         $msg .= &mt('Sorry, the URL generated when you requested creation of an account contained incomplete information.')
  510:                .' '.&mt('Please submit a [_1]new request[_2] for account creation and follow the new link included in the e-mail that will be sent to you.','<a href="/adm/createaccount">','</a>');
  511:     }
  512:     return ($msg,$nostart,$noend);
  513: }
  514: 
  515: sub start_session {
  516:     my ($r,$username,$domain,$lonhost,$courseid,$token) = @_;
  517:     my %form = (
  518:                 uname => $username,
  519:                 udom  => $domain,
  520:                );
  521:     my $firsturl = '/adm/roles';
  522:     if (defined($courseid)) {
  523:         $courseid = &validate_course($courseid);
  524:         if ($courseid ne '') {
  525:             $form{'courseid'} = $courseid;
  526:             $firsturl = '/adm/selfenroll?cid='.$courseid;
  527:         }
  528:     }
  529:     if ($r->dir_config('lonBalancer') eq 'yes') {
  530:         &Apache::lonauth::success($r,$form{'uname'},$form{'udom'},
  531:                                   $lonhost,'noredirect',undef,\%form);
  532:         my $delete = &Apache::lonnet::tmpdel($token);
  533:         $r->internal_redirect('/adm/switchserver');
  534:     } else {
  535:         &Apache::lonauth::success($r,$form{'uname'},$form{'udom'},
  536:                                   $lonhost,$firsturl,undef,\%form);
  537:     }
  538:     return %form;
  539: }
  540: 
  541: 
  542: sub print_dataentry_form {
  543:     my ($r,$domain,$lonhost,$include,$mailtoken,$now,$username,$start_page) = @_;
  544:     my ($error,$output);
  545:     &print_header($r,$start_page);
  546:     if (open(my $jsh,"<$include/londes.js")) {
  547:         while(my $line = <$jsh>) {
  548:             $r->print($line);
  549:         }
  550:         close($jsh);
  551:         $output .= &javascript_setforms($now)."\n".&javascript_checkpass($now);
  552:         my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
  553:         my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
  554:         my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
  555:                                            $lonhost);
  556:         my @userinfo = ('firstname','middlename','lastname','generation','id',
  557:                         'permanentemail');
  558:         my %lt=&Apache::lonlocal::texthash(
  559:                     'pd'             => "Personal Data",
  560:                     'firstname'      => "First Name",
  561:                     'middlename'     => "Middle Name",
  562:                     'lastname'       => "Last Name",
  563:                     'generation'     => "Generation",
  564:                     'permanentemail' => "Permanent e-mail address",
  565:                     'id'             => "ID/Student Number",
  566:                     'lg'             => "Login Data"
  567:         );
  568:         my %textboxsize = (
  569:                            firstname      => '15',
  570:                            middlename     => '15',
  571:                            lastname       => '15',
  572:                            generation     => '5',
  573:                            id             => '15',
  574:                           );
  575:         my $genhelp=&Apache::loncommon::help_open_topic('Generation');
  576:         $output .= '<div class="LC_left_float"><h3>'.$lt{'pd'}.'</h3>'.
  577:                   '<form name="server" method="post" target="_top" action="/adm/createaccount">'.
  578:                   &Apache::lonhtmlcommon::start_pick_box();
  579:         foreach my $item (@userinfo) {
  580:             my $rowtitle = $lt{$item};
  581:             if ($item eq 'generation') {
  582:                 $rowtitle = $genhelp.$rowtitle;
  583:             }
  584:             $output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
  585:             if ($item eq 'permanentemail') {
  586:                 $output .= $username;
  587:             } else {
  588:                 $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
  589:             }
  590:             $output .= &Apache::lonhtmlcommon::row_closure(1);
  591:         }
  592:         $output .= &Apache::lonhtmlcommon::end_pick_box();
  593:         $output .= <<"ENDSERVERFORM";
  594:    <input type="hidden" name="logtoken" value="$logtoken" />
  595:    <input type="hidden" name="token" value="$mailtoken" />
  596:    <input type="hidden" name="serverid" value="$lonhost" />
  597:    <input type="hidden" name="uname" value="" />
  598:    <input type="hidden" name="upass" value="" />
  599:    <input type="hidden" name="phase" value="createaccount" />
  600:   </form></div>
  601: ENDSERVERFORM
  602:         my $upassone = '<input type="password" name="upass'.$now.'" size="10" />';
  603:         my $upasstwo = '<input type="password" name="upasscheck'.$now.'" size="10" />';
  604:         my $submit_text = &mt('Create LON-CAPA account');
  605:         $output .= '<div class="LC_left_float"><h3>'.$lt{'lg'}.'</h3>'."\n".
  606:                    '<form name="client" method="post" />'."\n".
  607:                    &Apache::lonhtmlcommon::start_pick_box()."\n".
  608:                    &Apache::lonhtmlcommon::row_title(&mt('Username'),
  609:                                                     'LC_pick_box_title')."\n".
  610:                    $username."\n".
  611:                    &Apache::lonhtmlcommon::row_closure(1)."\n".
  612:                    &Apache::lonhtmlcommon::row_title(&mt('Password'),
  613:                                                     'LC_pick_box_title')."\n".
  614:                    $upassone."\n".
  615:                    &Apache::lonhtmlcommon::row_closure(1)."\n".
  616:                    &Apache::lonhtmlcommon::row_title(&mt('Confirm password'),
  617:                                                 'LC_pick_box_title')."\n".
  618:                    $upasstwo."\n".
  619:                    &Apache::lonhtmlcommon::row_closure(1)."\n".
  620:                    &Apache::lonhtmlcommon::end_pick_box()."\n".
  621:                    '<input type="hidden" name="uname" value="'.$username.'">'."\n".
  622:                    '<input type="hidden" name="lextkey" value="'.$lextkey.'">'."\n".
  623:                    '<input type="hidden" name="uextkey" value="'.$uextkey.'">'."\n".
  624:                    '</form></div>'."\n".
  625:                    '<div class="LC_clear_float_footer"><br /><br />'."\n".
  626:                    '<form name="buttonform">'."\n".
  627:                    '<input type="button" name="createaccount" value="'.
  628:                    $submit_text.'" onclick="javascript:checkpass();" /></form></div>';
  629:     } else {
  630:         $output = &mt('Could not load javascript file [_1]','<tt>londes.js</tt>');
  631:     }
  632:     return $output;
  633: }
  634: 
  635: sub create_account {
  636:     my ($r,$domain,$lonhost,$username,$domdesc) = @_;
  637:     my ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'},
  638:                                                           $env{'form.serverid'}); 
  639:     # Error messages
  640:     my $error     = '<span class="LC_error">'.&mt('Error:').' ';
  641:     my $end       = '</span><br /><br />';
  642:     my $rtnlink   = '<a href="javascript:history.back();" />'.
  643:                     &mt('Return to previous page').'</a>'.
  644:                     &Apache::loncommon::end_page();
  645:     if ($retrieved eq 'ok') {
  646:         if ($env{'form.cid'} ne '') {
  647:             my ($result,$userchkmsg) = &check_id($username,$domain,$domdesc);
  648:             if ($result eq 'fail') {
  649:                 $output = $error.&mt('Invalid ID format').$end.
  650:                           $userchkmsg.$rtnlink;
  651:                 return ('fail',$output);
  652:             }
  653:         }
  654:     } else {
  655:         return ('fail',$error.$output.$end.$rtnlink);
  656:     }
  657:     # Call modifyuser
  658:     my $result = 
  659:         &Apache::lonnet::modifyuser($domain,$username,$env{'form.cid'},
  660:                                     'internal',$upass,$env{'form.cfirstname'},
  661:                                     $env{'form.cmiddlename'},$env{'form.clastname'},
  662:                                     $env{'form.cgeneration'},undef,undef,$username);
  663:     $output = &mt('Generating user: [_1]',$result);
  664:     my $uhome = &Apache::lonnet::homeserver($username,$domain);
  665:     $output .= '<br />'.&mt('Home server: [_1]',$uhome).' '.
  666:               &Apache::lonnet::hostname($uhome).'<br /><br />';
  667:     return ('ok',$output);
  668: }
  669: 
  670: sub username_validation {
  671:     my ($username,$domain,$domdesc,$contact_name,$contact_email,$courseid) = @_;
  672:     my ($retrieved,$output,$upass);
  673: 
  674:     $username= &LONCAPA::clean_username($username);
  675:     $domain = &LONCAPA::clean_domain($domain);
  676:     my $uhome = &Apache::lonnet::homeserver($username,$domain);
  677: 
  678:     if ($uhome ne 'no_host') {
  679:         $output = &invalid_state('existinguser',$domdesc,
  680:                                  $contact_name,$contact_email);
  681:         return $output;
  682:     }
  683:     ($retrieved,$output,$upass) = &process_credentials($env{'form.logtoken'},
  684:                                                        $env{'form.serverid'});
  685:     if ($retrieved eq 'ok') {
  686:         my $primlibserv = &Apache::lonnet::domain($domain,'primary');
  687:         my $authok;
  688:         my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
  689:         if ((($domdefaults{'auth_def'} =~/^krb(4|5)$/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth')) {
  690:             my $checkdefauth = 1;
  691:             $authok = 
  692:                 &Apache::lonnet::reply("encrypt:auth:$domain:$username:$upass:$checkdefauth",$primlibserv);
  693:         } else {
  694:             $authok = 'non_authorized';
  695:         }
  696:         if ($authok eq 'authorized') {
  697:             ($output,undef) = &username_check($username,$domain,$domdesc,$courseid);            
  698:         } else {
  699:             $output = '<div class="LC_warning">'
  700:                      .&mt('Username and/or password could not be authenticated.')
  701:                      .'</div>'
  702:                      .&mt('Please check the username and password.'); 
  703:         }
  704:     }
  705:     return $output;
  706: }
  707: 
  708: sub username_check {
  709:     my ($username,$domain,$domdesc,$courseid) = @_;
  710:     my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
  711:     $newuser = 1;
  712:     my $checkhash;
  713:     my $checks = { 'username' => 1 };
  714:     $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser };
  715:     &Apache::loncommon::user_rule_check($checkhash,$checks,\%alerts,\%rulematch,
  716:                                         \%inst_results,\%curr_rules,\%got_rules);
  717:     if (ref($alerts{'username'}) eq 'HASH') {
  718:         if (ref($alerts{'username'}{$domain}) eq 'HASH') {
  719:             if ($alerts{'username'}{$domain}{$username}) {
  720:                 my ($userchkmsg,$checkfail);
  721:                 if (ref($curr_rules{$domain}) eq 'HASH') {
  722:                     $userchkmsg =
  723:                         &Apache::loncommon::instrule_disallow_msg('username',$domdesc,1).
  724:                         &Apache::loncommon::user_rule_formats($domain,$domdesc,
  725:                                 $curr_rules{$domain}{'username'},'username');
  726:                     if ($userchkmsg) {
  727:                         $checkfail = 1;
  728:                     }
  729:                 }
  730:                 return ($userchkmsg,$checkfail);
  731:             }
  732:         }
  733:     }
  734:     my $submit_text = &mt('Create LON-CAPA account');
  735:     # FIXME need a cookie to confirm credentials were validated.
  736:     my $output = '<form method="post" action="/adm/createaccount">'.
  737:                  &Apache::loncreateuser::personal_data_display($username,$domain,1,
  738:                                     undef,$inst_results{$username.':'.$domain}).
  739:                 '<br /><br /><input type="hidden" name="uname" value="'.$username.'" />'."\n".
  740:                 '<input type="hidden" name="udom" value="'.$domain.'" />'."\n".
  741:                 '<input type="hidden" name="phase" value="username_activation" />';
  742:     if ($courseid ne '') {
  743:         $output .= '<input type="hidden" name="courseid" value="'.$courseid.'" />';
  744:     }
  745:     $output .= '<input type="submit" name="newaccount" value="'.
  746:                $submit_text.'" /></form>';
  747:     return ($output,'');
  748: }
  749: 
  750: sub username_activation {
  751:     my ($r,$username,$domain,$domdesc,$lonhost,$courseid) = @_;
  752:     my $output;
  753:     my $error     = '<span class="LC_error">'.&mt('Error:').' ';
  754:     my $end       = '</span><br /><br />';
  755:     my $rtnlink   = '<a href="javascript:history.back();" />'.
  756:                     &mt('Return to previous page').'</a>'.
  757:                     &Apache::loncommon::end_page();
  758:     my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
  759:     if ((($domdefaults{'auth_def'} =~/^krb(4|5)$/) && 
  760:          ($domdefaults{'auth_arg_def'} ne '')) || 
  761:         ($domdefaults{'auth_def'} eq 'localauth')) {
  762:         if ($env{'form.cid'} ne '') {
  763:             my ($result,$userchkmsg) = &check_id($username,$domain,$domdesc);
  764:             if ($result eq 'fail') {
  765:                 $output = $error.&mt('Invalid ID format').$end.
  766:                           $userchkmsg.$rtnlink;
  767:                 return ('fail',$output);
  768:             }
  769:         }
  770:         # Call modifyuser
  771:         my $result =
  772:             &Apache::lonnet::modifyuser($domain,$username,$env{'form.cid'},
  773:                           $domdefaults{'auth_def'},
  774:                           $domdefaults{'auth_arg_def'},$env{'form.cfirstname'},
  775:                           $env{'form.cmiddlename'},$env{'form.clastname'},
  776:                           $env{'form.cgeneration'},undef,undef,
  777:                           $env{'form.cpermanentemail'});
  778:         if ($result eq 'ok') {
  779:             $output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain);
  780:             my %form = &start_session($r,$username,$domain,$lonhost,$courseid);
  781:             my $nostart = 1;
  782:             return ('ok',$output,$nostart);
  783:         } else {
  784:             $output = &mt('Account creation failed for username: [_1] in domain: [_2].',$username,$domain).'<br /><span class="LC_error">'.&mt('Error: [_1]',$result).'</span>';
  785:             return ('fail',$output);
  786:         }
  787:     } else {
  788:         $output = &mt('User account creation is not available for the current default authentication type.')."\n";
  789:         return('fail',$output);
  790:     }
  791: }
  792: 
  793: sub check_id {
  794:     my ($username,$domain,$domdesc) = @_;
  795:     # Check ID format
  796:     my (%alerts,%rulematch,%inst_results,%curr_rules,%checkhash);
  797:     my %checks = ('id' => 1);
  798:     %{$checkhash{$username.':'.$domain}} = (
  799:                                             'newuser' => 1,
  800:                                             'id' => $env{'form.cid'},
  801:                                            );
  802:     &Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts,
  803:                                         \%rulematch,\%inst_results,\%curr_rules);
  804:     if (ref($alerts{'id'}) eq 'HASH') {
  805:         if (ref($alerts{'id'}{$domain}) eq 'HASH') {
  806:             if ($alerts{'id'}{$domain}{$env{'form.cid'}}) {
  807:                 my $userchkmsg;
  808:                 if (ref($curr_rules{$domain}) eq 'HASH') {
  809:                     $userchkmsg  =
  810:                         &Apache::loncommon::instrule_disallow_msg('id',
  811:                                                            $domdesc,1).
  812:                         &Apache::loncommon::user_rule_formats($domain,
  813:                               $domdesc,$curr_rules{$domain}{'id'},'id');
  814:                 }
  815:                 return ('fail',$userchkmsg);
  816:             }
  817:         }
  818:     }
  819:     return; 
  820: }
  821: 
  822: sub invalid_state {
  823:     my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_;
  824:     my $msg;
  825:     if ($error eq 'baduseremail') {
  826:         $msg = &mt('The e-mail address you provided does not appear to be a valid address.');
  827:     } elsif ($error eq 'existinguser') {
  828:         $msg = &mt('The e-mail address you provided is already in use as a username in this LON-CAPA domain.');
  829:     } elsif ($error eq 'userrules') {
  830:         $msg = &mt('Username rules for this LON-CAPA domain do not allow the e-mail address you provided to be used as a username.');
  831:     } elsif ($error eq 'userformat') {
  832:         $msg = &mt('The e-mail address you provided may not be used as a username in this LON-CAPA domain.');
  833:     } elsif ($error eq 'captcha') {
  834:         $msg = &mt('Validation of the code your entered failed.');
  835:     } elsif ($error eq 'noemails') {
  836:         $msg = &mt('Creation of a new user account using an e-mail address as username is not permitted in this LON-CAPA domain.');
  837:     }
  838:     if ($msgtext) {
  839:         $msg .= '<br />'.$msgtext;
  840:     }
  841:     if ($contact_email ne '') {
  842:         my $escuri = &HTML::Entities::encode('/adm/createaccount','&<>"');
  843:         $msg .= '<br />'.&mt('You may wish to contact the [_1]LON-CAPA helpdesk[_2] for the [_3] domain.','<a href="/adm/helpdesk?origurl='.$escuri.'">','</a>',$domdesc);
  844:     } else {
  845:         $msg .= '<br />'.&mt('You may wish to send an e-mail to the server administrator: [_1] for the [_2] domain.',$Apache::lonnet::perlvar{'AdminEmail'},$domdesc);
  846:     }
  847:     return $msg;
  848: }
  849: 
  850: sub create_captcha {
  851:     my ($output_dir,$db_dir) = @_;
  852:     my %captcha_params = &captcha_settings();
  853:     my $captcha = Authen::Captcha->new(
  854:                                        output_folder => $captcha_params{'output_dir'},
  855:                                        data_folder   => $captcha_params{'db_dir'},
  856:                                       );
  857:     my $md5sum = $captcha->generate_code($captcha_params{'numchars'});
  858:     my $output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n".
  859:                  &mt('Type in the letters/numbers shown below').'&nbsp;'.
  860:                  '<input type="text" size="5" name="code" value="" /><br />'.
  861:                  '<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png">';
  862:     return $output;
  863: }
  864: 
  865: sub captcha_settings {
  866:     my %captcha_params = ( 
  867:                            output_dir     => "/home/httpd/html/captcha",
  868:                            www_output_dir => "/captcha",
  869:                            db_dir         => "/home/www/captchadb",
  870:                            numchars       => '5',
  871:                          );
  872:     return %captcha_params;
  873: }
  874: 
  875: sub getkeys {
  876:     my ($lkey,$ukey) = @_;
  877:     my $lextkey=hex($lkey);
  878:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
  879: 
  880:     my $uextkey=hex($ukey);
  881:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
  882:     return ($lextkey,$uextkey);
  883: }
  884: 
  885: sub serverform {
  886:     my ($logtoken,$lonhost,$mailtoken,$courseid) = @_;
  887:     my $output .= <<ENDSERVERFORM;
  888:   <form name="server" method="post" target="_top">
  889:    <input type="hidden" name="logtoken" value="$logtoken" />
  890:    <input type="hidden" name="token" value="$mailtoken" />
  891:    <input type="hidden" name="serverid" value="$lonhost" />
  892:    <input type="hidden" name="uname" value="" />
  893:    <input type="hidden" name="upass" value="" />
  894:    <input type="hidden" name="phase" value="username_validation" />
  895:    <input type="hidden" name="courseid" value="$courseid" />
  896:   </form>
  897: ENDSERVERFORM
  898:     return $output;
  899: }
  900: 
  901: sub process_credentials {
  902:     my ($logtoken,$lonhost) = @_;
  903:     my $tmpinfo=Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
  904:     my ($retrieved,$output,$upass);
  905:     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
  906:         $output = &mt('Information needed to verify your login information is missing, inaccessible or expired.')
  907:                  .'<br />'.&mt('You may need to reload the previous page to obtain a new token.');
  908:         return ($retrieved,$output,$upass); 
  909:     } else {
  910:         my $reply = &Apache::lonnet::reply('tmpdel:'.$logtoken,$lonhost);
  911:         if ($reply eq 'ok') {
  912:             $retrieved = 'ok';
  913:         } else {
  914:             $output = &mt('Session could not be opened.');
  915:         }
  916:     }
  917:     my ($key,$caller)=split(/&/,$tmpinfo);
  918:     if ($caller eq 'createaccount') {
  919:         $upass = &Apache::lonpreferences::des_decrypt($key,$env{'form.upass'});
  920:     } else {
  921:         $output = &mt('Unable to retrieve your log-in information - unexpected context');
  922:     }
  923:     return ($retrieved,$output,$upass);
  924: }
  925: 
  926: sub guest_format_check {
  927:     my ($useremail,$domain,$cancreate,$settings) = @_;
  928:     my ($login,$format_match,$format_msg,@user_rules);
  929:     if (ref($settings) eq 'HASH') {
  930:         if (ref($settings->{'email_rule'}) eq 'ARRAY') {
  931:             push(@user_rules,@{$settings->{'email_rule'}});
  932:         }
  933:     }
  934:     if (@user_rules > 0) {
  935:         my %rule_check = 
  936:             &Apache::lonnet::inst_rulecheck($domain,$useremail,undef,
  937:                                             'selfcreate',\@user_rules);
  938:         if (keys(%rule_check) > 0) {
  939:             foreach my $item (keys(%rule_check)) {
  940:                 if ($rule_check{$item}) {
  941:                     $format_match = 1;   
  942:                     last;
  943:                 }
  944:             }
  945:         }
  946:     }
  947:     if ($format_match) {
  948:         ($login) = ($useremail =~ /^([^\@]+)\@/);
  949:         $format_msg = '<br />'.&mt("Your e-mail address uses the same internet domain as your institution's LON-CAPA service.").'<br />'.&mt('Creation of a LON-CAPA account with this type of e-mail address as username is not permitted.').'<br />';
  950:         if (ref($cancreate) eq 'ARRAY') {
  951:             if (grep(/^login$/,@{$cancreate})) {
  952:                 $format_msg .= &mt('You should request creation of a LON-CAPA account for a log-in ID of "[_1]" at your institution instead.',$login).'<br />'; 
  953:             }
  954:         }
  955:     }
  956:     return $format_msg;
  957: }
  958: 
  959: 1;

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