'.$end_page);
return OK;
}
@@ -105,10 +112,16 @@ sub handler {
if ($env{'form.udom'} ne '') {
$domain = $env{'form.udom'};
}
+
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
+ my ($cancreate,$statustocreate) =
+ &get_creation_controls($domain,$domconfig{'usercreation'});
+
my ($result,$output) =
&username_validation($r,$env{'form.uname'},$domain,$domdesc,
$contact_name,$contact_email,$courseid,
- $lonhost);
+ $lonhost,$statustocreate);
if ($result eq 'existingaccount') {
$r->print($output);
&print_footer($r);
@@ -126,24 +139,14 @@ sub handler {
$start_page =
&Apache::loncommon::start_page($title,$js,
{'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) {
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
+ my ($cancreate,$statustocreate) = &get_creation_controls($domain,$domconfig{'usercreation'});
+ if (@{$cancreate} == 0) {
&print_header($r,$start_page,$courseid);
my $output = '
'.&mt('Account creation unavailable').'
'.
''.
- &mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted at this institution ([_1]).',$domdesc).'
';
+ &mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted for [_1].',$domdesc).'
';
$r->print($output);
&print_footer($r);
return OK;
@@ -153,12 +156,13 @@ sub handler {
&print_header($r,$start_page,$courseid);
my ($msg,$sso_logout);
$sso_logout = &sso_logout_frag($r,$domain);
- if (grep(/^sso$/,@cancreate)) {
+ if (grep(/^sso$/,@{$cancreate})) {
$msg = '
'.&mt('Account creation').'
'.
&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 at this institution.").' ';
$msg .= &username_check($sso_username,$domain,$domdesc,$courseid,
- $lonhost,$contact_email,$contact_name,$sso_logout);
+ $lonhost,$contact_email,$contact_name,
+ $sso_logout,$statustocreate);
} else {
$msg = '
'.&mt('Account creation unavailable').'
'.
''.&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 at this institution, and you are not permitted to create one.").'
'.&mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email).''.
@@ -208,7 +212,7 @@ sub handler {
(my $result,$output) =
&username_validation($r,$env{'form.uname'},$domain,$domdesc,
$contact_name,$contact_email,$courseid,
- $lonhost);
+ $lonhost,$statustocreate);
if ($result eq 'existingaccount') {
$r->print($output);
&print_footer($r);
@@ -219,21 +223,21 @@ sub handler {
} elsif ($env{'form.create_with_email'}) {
&print_header($r,$start_page,$courseid);
$output = &process_email_request($env{'form.useremail'},$domain,$domdesc,
- $contact_name,$contact_email,\@cancreate,
+ $contact_name,$contact_email,$cancreate,
$lonhost,$domconfig{'usercreation'},
$courseid);
} elsif (!$token) {
&print_header($r,$start_page,$courseid);
my $now=time;
- if (grep(/^login$/,@cancreate)) {
+ if (grep(/^login$/,@{$cancreate})) {
my $jsh=Apache::File->new($include."/londes.js");
$r->print(<$jsh>);
$r->print(&javascript_setforms($now));
}
- if (grep(/^email$/,@cancreate)) {
+ if (grep(/^email$/,@{$cancreate})) {
$r->print(&javascript_validmail());
}
- $output = &print_username_form($domain,$domdesc,\@cancreate,$now,$lonhost,
+ $output = &print_username_form($domain,$domdesc,$cancreate,$now,$lonhost,
$courseid);
}
$r->print($output);
@@ -241,6 +245,15 @@ sub handler {
return OK;
}
+sub get_custom_name {
+ my ($domain) = @_;
+ if ($domain eq 'relate') {
+ return 'Learn-Physics';
+ } else {
+ return lc($domain);
+ }
+}
+
sub print_header {
my ($r,$start_page,$courseid) = @_;
$r->print($start_page);
@@ -273,7 +286,7 @@ sub selfenroll_crumbs {
my ($r,$courseid,$desc) = @_;
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:ToCatalog('backupcrumbs','')",
- text=>"Course Catalog"});
+ text=>"Course/Community Catalog"});
if ($env{'form.coursenum'} ne '') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:ToCatalog('backupcrumbs','details')",
@@ -281,7 +294,7 @@ sub selfenroll_crumbs {
}
my $last_crumb;
if ($desc ne '') {
- $last_crumb = &mt('Self-enroll in [_1]',''.$desc.'');
+ $last_crumb = &mt('Self-enroll in [_1]',"$desc");
} else {
$last_crumb = &mt('Self-enroll');
}
@@ -306,9 +319,10 @@ sub validate_course {
sub javascript_setforms {
my ($now) = @_;
my $js = <
+
ENDSCRIPT
@@ -368,6 +382,13 @@ function validate_email() {
if (validmail(field) == false) {
alert("$lt{'email'}: "+field.value+" $lt{'notv'}.");
return false;
+ } else {
+ var emailaddr = field.value;
+ var lcemail = emailaddr.toLowerCase();
+ if (emailaddr != lcemail) {
+ field.value = lcemail;
+ alert("Learn-Physics usernames are all lower case.\\nAccordingly your username will be "+lcemail+" once activated.");
+ }
}
return true;
}
@@ -396,35 +417,51 @@ sub print_username_form {
}
}
if (grep(/^email$/,@{$cancreate})) {
- $output .= '
'.&mt('Create account with an e-mail address as your username').'
';
- 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('Create account with an e-mail address as your username').'
'.
+ &mt('You are about to sign-up for a Learn Physics account so you can take the pre-requisite test for enrollment in the online course.').' '.
+ &mt('Your performance on the test will help both you and us gauge your readiness to take the course.').' '.
+ &mt('Although the pre-test exam will be the basis for admitting people into the course, we can only accommodate a limited number of students.').' '.
+ &mt('We will e-mail you with instructions on how to access the course by the end of February, if we are able to accommodate you.').' ';
+ my $captchaform = &create_recaptcha();
+ if ($captchaform) {
+ my $submit_text = &mt('Sign-up');
+ my $emailform = '';
+ if (grep(/^login$/,@{$cancreate})) {
+ $output .= &mt('Provide your e-mail address to sign up for a Learn Physics account if you do not have a log-in ID at your institution.',' ').'
';
}
}
if ($output eq '') {
@@ -444,35 +481,35 @@ sub login_box {
);
my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
- my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
+ my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',
$lonhost);
$output = &serverform($logtoken,$lonhost,undef,$courseid,$context);
- my $unameform = '';
- my $upassform = '';
- $output .= '';
return $output;
}
@@ -480,7 +517,7 @@ sub login_box {
sub process_email_request {
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate,
$server,$settings,$courseid) = @_;
- $useremail = $env{'form.useremail'};
+ $useremail = lc($env{'form.useremail'});
my $output;
if (ref($cancreate) eq 'ARRAY') {
if (!grep(/^email$/,@{$cancreate})) {
@@ -495,33 +532,28 @@ sub process_email_request {
my $uhome = &Apache::lonnet::homeserver($useremail,$domain);
if ($uhome ne 'no_host') {
$output = &invalid_state('existinguser',$domdesc,
- $contact_name,$contact_email);
+ $contact_name,$contact_email,'',$useremail);
return $output;
} else {
- my $code = $env{'form.code'};
- my $md5sum = $env{'form.crypt'};
- my %captcha_params = &captcha_settings();
- my $captcha = Authen::Captcha->new(
- output_folder => $captcha_params{'output_dir'},
- data_folder => $captcha_params{'db_dir'},
- );
- my $captcha_chk = $captcha->check_code($code,$md5sum);
- my %captcha_hash = (
- 0 => 'Code not checked (file error)',
- -1 => 'Failed: code expired',
- -2 => 'Failed: invalid code (not in database)',
- -3 => 'Failed: invalid code (code does not match crypt)',
- );
- if ($captcha_chk != 1) {
+ my $captcha = Captcha::reCAPTCHA->new;
+ my $captcha_result =
+ $captcha->check_answer(
+ 'PRIVATEKEY',
+ $ENV{'REMOTE_ADDR'},
+ $env{'form.recaptcha_challenge_field'},
+ $env{'form.recaptcha_response_field'},
+ );
+ if (!$captcha_result->{is_valid}) {
$output = &invalid_state('captcha',$domdesc,$contact_name,
- $contact_email,$captcha_hash{$captcha_chk});
+ $contact_email);
+
return $output;
}
my $uhome=&Apache::lonnet::homeserver($useremail,$domain);
if ($uhome eq 'no_host') {
my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);
&call_rulecheck($useremail,$domain,\%alerts,\%rulematch,
- \%inst_results,\%curr_rules,%got_rules,'username');
+ \%inst_results,\%curr_rules,\%got_rules,'username');
if (ref($alerts{'username'}) eq 'HASH') {
if (ref($alerts{'username'}{$domain}) eq 'HASH') {
if ($alerts{'username'}{$domain}{$useremail}) {
@@ -573,17 +605,17 @@ sub send_token {
'domain' => $domain,
'username' => $email,
'courseid' => $courseid);
- my $token = &Apache::lonnet::tmpput(\%info,$server);
+ my $token = &Apache::lonnet::tmpput(\%info,$server,'createaccount');
if ($token !~ /^error/ && $token ne 'no_such_host') {
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).' '.
- &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);
+ my $showtime = localtime(time);
+ my $mailmsg = &mt('A request was submitted on [_1] for creation of a [_1] account.',$showtime,$domdesc).). "\n".
+ &mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]',
+ "\n\n".&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token);
my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name,
$contact_email);
if ($result eq 'ok') {
- $msg .= &mt('A message has been sent to the e-mail address you provided.').' '.&mt('The message includes the web address for the link you will use to complete the account creation process.').' '.&mt("The link included in the message will be valid for the next [_1]two[_2] hours.",'','');
+ $msg .= &mt('A message has been sent to the e-mail address you provided.').' '.&mt('The message includes the web address for the link you will use to complete the sign-up process.').' '.&mt("The link included in the message will be valid for the next [_1]two[_2] hours.",'','');
} else {
$msg .= ''.
&mt('An error occurred when sending a message to the e-mail address you provided.').' '.
@@ -619,7 +651,7 @@ sub process_mailtoken {
if ($result eq 'ok') {
$msg = $output;
my $shownow = &Apache::lonlocal::locallocaltime($now);
- my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] 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";
+ my $mailmsg = &mt('A [_1] account 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";
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
$mailmsg,$contact_name,
$contact_email);
@@ -697,87 +729,110 @@ sub print_dataentry_form {
$output .= &javascript_setforms($now)."\n".&javascript_checkpass($now);
my ($lkey,$ukey) = &Apache::lonpreferences::des_keys();
my ($lextkey,$uextkey) = &getkeys($lkey,$ukey);
- my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount',
+ my $logtoken=Apache::lonnet::reply('tmpput:'.$ukey.$lkey.'&createaccount:createaccount',
$lonhost);
- my @userinfo = ('firstname','middlename','lastname','generation','id',
- 'permanentemail');
- my %lt=&Apache::lonlocal::texthash(
- 'pd' => "Personal Data",
- 'firstname' => "First Name",
- 'middlename' => "Middle Name",
- 'lastname' => "Last Name",
- 'generation' => "Generation",
- 'permanentemail' => "Permanent e-mail address",
- 'id' => "Student/Employee ID",
- 'lg' => "Login Data"
- );
- my %textboxsize = (
- firstname => '15',
- middlename => '15',
- lastname => '15',
- generation => '5',
- id => '15',
- );
- my $genhelp=&Apache::loncommon::help_open_topic('Generation');
- $output .= '