// 'username',
udom => 'domain',
@@ -460,7 +512,7 @@ sub print_username_form {
$domain,'createaccount').'';
}
}
- if (grep(/^email(|approval)$/,@{$cancreate})) {
+ if (grep(/^email$/,@{$cancreate})) {
$output .= ''.&mt('Create account with an e-mail address as your username').'
';
my ($captchaform,$error,$captcha) = &Apache::loncommon::captcha_display('usercreation',$lonhost);
if ($error) {
@@ -481,10 +533,9 @@ sub print_username_form {
} else {
my $prompt = $lt{'plse'};
if (ref($emailusername) eq 'HASH') {
- foreach my $key (keys(%{$emailusername})) {
- if ($emailusername->{$key}) {
+ if (ref($emailusername->{$usertype}) eq 'HASH') {
+ if (keys(%{$emailusername->{$usertype}}) > 0) {
$prompt = $lt{'info'};
- last;
}
}
}
@@ -492,7 +543,8 @@ sub print_username_form {
$lt{'yopw'}.'
';
}
$output .= &print_dataentry_form($r,$domain,$lonhost,$include,$now,$captchaform,
- $courseid,$gotlondes,$emailusername,$captcha);
+ $courseid,$gotlondes,$emailusername,$captcha,
+ $usertype);
}
$output .= '';
}
@@ -558,10 +610,10 @@ sub login_box {
sub process_email_request {
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate,
- $server,$settings,$emailusername,$courseid) = @_;
+ $server,$settings,$emailusername,$courseid,$usertype) = @_;
my $output;
if (ref($cancreate) eq 'ARRAY') {
- if (!grep(/^email(|approval)$/,@{$cancreate})) {
+ if (!grep(/^email$/,@{$cancreate})) {
$output = &invalid_state('noemails',$domdesc,
$contact_name,$contact_email);
return $output;
@@ -612,7 +664,7 @@ sub process_email_request {
}
}
$output = &send_token($domain,$useremail,$server,$domdesc,$contact_name,
- $contact_email,$courseid,$emailusername);
+ $contact_email,$courseid,$emailusername,$usertype);
}
return $output;
}
@@ -632,7 +684,8 @@ sub call_rulecheck {
}
sub send_token {
- my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername) = @_;
+ my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid,$emailusername,
+ $usertype) = @_;
my $msg = ''.&mt('Account creation status').'
'.
&mt('Thank you for your request to create a new LON-CAPA account.').
'
';
@@ -660,9 +713,14 @@ sub send_token {
'tmpinfo' => $tmpinfo);
if (ref($emailusername) eq 'HASH') {
- foreach my $item (keys(%{$emailusername})) {
- $info{$item} = $env{'form.'.$item};
- $info{$item} =~ s/(`)//g;
+ if (ref($emailusername->{$usertype}) eq 'HASH') {
+ foreach my $item (keys(%{$emailusername->{$usertype}})) {
+ $info{$item} = $env{'form.'.$item};
+ $info{$item} =~ s/(`)//g;
+ }
+ unless ($usertype eq 'default') {
+ $info{'inststatus'} = $usertype;
+ }
}
}
my $token = &Apache::lonnet::tmpput(\%info,$server,'createaccount');
@@ -698,7 +756,7 @@ sub send_token {
sub process_mailtoken {
my ($r,$token,$contact_name,$contact_email,$domain,$domdesc,$lonhost,
- $include,$start_page,$cancreate,$settings) = @_;
+ $include,$start_page,$cancreate,$settings,$usertype) = @_;
my ($msg,$nostart,$noend,$redirect);
my %data = &Apache::lonnet::tmpget($token);
my $now = time;
@@ -715,36 +773,46 @@ sub process_mailtoken {
if ($now - $data{'time'} < 7200) {
# Check if request should be queued.
if (ref($cancreate) eq 'ARRAY') {
+ my $disposition;
if (grep(/^email$/,@{$cancreate})) {
- my ($result,$output,$uhome) =
- &create_account($r,$domain,$domdesc,\%data);
- 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 $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
- $mailmsg,$contact_name,
- $contact_email);
- if ($mailresult eq 'ok') {
- $msg .= &mt('An e-mail confirming creation of your new LON-CAPA account has been sent to [_1].',$data{'username'});
- } else {
- $msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'});
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'cancreate'}) eq 'HASH') {
+ if (ref($settings->{'cancreate'}{'selfcreateprocessing'}) eq 'HASH') {
+ $disposition = $settings->{'cancreate'}{'selfcreateprocessing'}{$usertype};
+ }
}
- $redirect = &start_session($r,$data{'username'},$domain,$uhome,
- $data{'courseid'},$token);
- $nostart = 1;
- $noend = 1;
+ }
+ if ($disposition eq 'approval') {
+ $msg = &store_request($domain,$data{'username'},'approval',\%data,$settings);
+ my $delete = &Apache::lonnet::tmpdel($token);
} else {
- $msg .= &mt('A problem occurred when attempting to create your new LON-CAPA account.')
- .'
'.$output;
- if (($contact_name ne '') && ($contact_email ne '')) {
- $msg .= &mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);
+ my ($result,$output,$uhome) =
+ &create_account($r,$domain,$domdesc,\%data);
+ 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 $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'},
+ $mailmsg,$contact_name,
+ $contact_email);
+ if ($mailresult eq 'ok') {
+ $msg .= &mt('An e-mail confirming creation of your new LON-CAPA account has been sent to [_1].',$data{'username'});
+ } else {
+ $msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'});
+ }
+ $redirect = &start_session($r,$data{'username'},$domain,$uhome,
+ $data{'courseid'},$token);
+ $nostart = 1;
+ $noend = 1;
+ } else {
+ $msg .= &mt('A problem occurred when attempting to create your new LON-CAPA account.')
+ .'
'.$output;
+ if (($contact_name ne '') && ($contact_email ne '')) {
+ $msg .= &mt('Please contact the [_1] ([_2]) for assistance.',$contact_name,$contact_email);
+ }
}
+ my $delete = &Apache::lonnet::tmpdel($token);
}
- my $delete = &Apache::lonnet::tmpdel($token);
- } elsif (grep(/^emailapproval$/,@{$cancreate})) {
- $msg = &store_request($domain,$data{'username'},'approval',\%data,$settings);
- my $delete = &Apache::lonnet::tmpdel($token);
} else {
$msg = &invalid_state('noemails',$domdesc,$contact_name,$contact_email);
}
@@ -789,7 +857,8 @@ 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,$captcha) = @_;
+ my ($r,$domain,$lonhost,$include,$now,$captchaform,$courseid,$gotlondes,$emailusername,$captcha,
+ $usertype) = @_;
my ($error,$output);
unless ($gotlondes) {
if (open(my $jsh,"<$include/londes.js")) {
@@ -797,7 +866,7 @@ sub print_dataentry_form {
$r->print($line);
}
close($jsh);
- $output = &javascript_setforms($now,$emailusername,$captcha)."\n";
+ $output = &javascript_setforms($now,$emailusername,$captcha,$usertype)."\n";
$gotlondes = 1;
}
}
@@ -813,8 +882,11 @@ sub print_dataentry_form {
$output .= ''."\n";
}
if (ref($emailusername) eq 'HASH') {
- foreach my $field (sort(keys(%{$emailusername}))) {
- $output .= ''."\n";
+ if (ref($emailusername->{$usertype}) eq 'HASH') {
+ foreach my $field (sort(keys(%{$emailusername->{$usertype}}))) {
+ $output .= ''."\n";
+ }
+ $output .= ''."\n";
}
}
if ($captcha eq 'original') {
@@ -843,11 +915,12 @@ ENDSERVERFORM
my $endclientform = ''."\n".
''."\n".
''."\n".
- '';
+ ''."\n".
+ ''.&mt('Fields marked [_1]*[_2] are required.','','').'
';
my ($datatable,$rowcount) =
&Apache::loncreateuser::personal_data_display('',$domain,'email','selfcreate',
'','',$now,$captchaform,
- $emailusername);
+ $emailusername,$usertype);
if ($rowcount) {
$output .= ''.$beginclientform.$datatable.$endclientform;
} else {
@@ -919,7 +992,7 @@ sub create_account {
my $output;
if (ref($dataref) eq 'HASH') {
my ($username,$encpass,$serverid,$courseid,$id,$firstname,$middlename,$lastname,
- $generation);
+ $generation,$inststatus);
$username = $dataref->{'username'};
$encpass = $dataref->{'upass'};
$serverid = $dataref->{'serverid'};
@@ -929,7 +1002,8 @@ sub create_account {
$middlename = $dataref->{'middlename'};
$lastname = $dataref->{'lastname'};
$generation = $dataref->{'generation'};
-
+ $inststatus = $dataref->{'inststatus'};
+
my $currhome = &Apache::lonnet::homeserver($username,$domain);
unless ($currhome eq 'no_host') {
$output = &mt('User account requested for username: [_1] in domain: [_2] already exists.',$username,$domain);
@@ -967,6 +1041,9 @@ sub create_account {
# Now that the user account exists, retrieve the homeserver, and include it in the output.
my $uhome = &Apache::lonnet::homeserver($username,$domain);
+ unless (($inststatus eq 'default') || ($inststatus eq '')) {
+ &Apache::lonnet::put('environment',{inststatus => $inststatus},$domain,$username);
+ }
$output .= '
'.&mt('Home server: [_1]',$uhome).' '.
&Apache::lonnet::hostname($uhome).'
';
return ('ok',$output,$uhome);
@@ -1531,7 +1608,7 @@ sub sso_logout_frag {
sub catreturn_js {
return <<"ENDSCRIPT";
ENDSCRIPT