# The LearningOnline Network # Allow visitors to create a user account with the username being either an # institutional log-in ID (institutional authentication required - localauth # or kerberos) or an e-mail address. # # $Id: createaccount.pm,v 1.20 2008/07/14 08:26:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # package Apache::createaccount; use strict; use Apache::Constants qw(:common); use Apache::lonacc; use Apache::lonnet; use Apache::loncommon; use Apache::lonhtmlcommon; use Apache::lonlocal; use Apache::lonauth; use Apache::resetpw; use Authen::Captcha; use DynaLoader; # for Crypt::DES version use Crypt::DES; use LONCAPA qw(:DEFAULT :match); use HTML::Entities; sub handler { my $r = shift; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; if ($r->header_only) { return OK; } my $domain; my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown'); my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain'); if ($sso_username ne '' && $sso_domain ne '') { $domain = $sso_domain; } else { $domain = &Apache::lonnet::default_login_domain(); } my $domdesc = &Apache::lonnet::domain($domain,'description'); my $contact_name = &mt('LON-CAPA helpdesk'); my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; my $contacts = &Apache::loncommon::build_recipient_list(undef,'helpdeskmail', $domain,$origmail); my ($contact_email) = split(',',$contacts); my $lonhost = $r->dir_config('lonHostID'); my $include = $r->dir_config('lonIncludes'); 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); if ($handle ne '') { $start_page = &Apache::loncommon::start_page('Already logged in'); my $end_page = &Apache::loncommon::end_page(); $r->print($start_page."\n".'
'.&mt('Please either [_1]continue the current session[_2] or [_3]logout[_4].','','','',''). '
'.$end_page); return OK; } my $courseid; if (defined($env{'form.courseid'})) { $courseid = &validate_course($env{'form.courseid'}); } if ($env{'form.phase'} eq 'selfenroll_login') { if ($env{'form.udom'} ne '') { $domain = $env{'form.udom'}; } my ($result,$output) = &username_validation($r,$env{'form.uname'},$domain,$domdesc, $contact_name,$contact_email,$courseid, $lonhost); if ($result eq 'existingaccount') { $r->print($output); $r->print(&Apache::loncommon::end_page()); return OK; } else { $start_page = &Apache::loncommon::start_page('Self-enroll in a LON-CAPA course','', {'no_inline_link' => 1,}); &print_header($r,$start_page); $r->print($output.&Apache::loncommon::end_page()); return OK; } } $start_page = &Apache::loncommon::start_page('Create a user account in LON-CAPA','', {'no_inline_link' => 1,}); my @cancreate; my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain); if (ref($domconfig{'usercreation'}) eq 'HASH') { if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { if (ref($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}) eq 'ARRAY') { @cancreate = @{$domconfig{'usercreation'}{'cancreate'}{'selfcreate'}}; } elsif (($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') && ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne '')) { @cancreate = ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'}); } } } if (@cancreate == 0) { &print_header($r,$start_page); my $output = '