--- loncom/interface/createaccount.pm 2008/07/17 12:10:05 1.22
+++ loncom/interface/createaccount.pm 2008/12/05 19:22:58 1.26
@@ -3,7 +3,7 @@
# institutional log-in ID (institutional authentication required - localauth
# or kerberos) or an e-mail address.
#
-# $Id: createaccount.pm,v 1.22 2008/07/17 12:10:05 raeburn Exp $
+# $Id: createaccount.pm,v 1.26 2008/12/05 19:22:58 schafran Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -263,7 +263,7 @@ sub print_footer {
&Apache::lonhtmlcommon::echo_form_input(['backto','logtoken',
'token','serverid','uname','upass','phase','create_with_email',
'code','useremail','crypt','cfirstname','clastname',
- 'cmiddlename','cgeneration','cpermanentemail','cid]).
+ 'cmiddlename','cgeneration','cpermanentemail','cid']).
'');
}
$r->print(&Apache::loncommon::end_page());
@@ -381,7 +381,7 @@ sub print_username_form {
my %lt = &Apache::lonlocal::texthash(
unam => 'username',
udom => 'domain',
- uemail => 'Email address in LON-CAPA',
+ uemail => 'E-mail address in LON-CAPA',
proc => 'Proceed');
my $output;
if (ref($cancreate) eq 'ARRAY') {
@@ -517,17 +517,13 @@ sub process_email_request {
$contact_email,$captcha_hash{$captcha_chk});
return $output;
}
- my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);
my $uhome=&Apache::lonnet::homeserver($useremail,$domain);
if ($uhome eq 'no_host') {
- my $checkhash;
- my $checks = { 'username' => 1 };
- $checkhash->{$useremail.':'.$domain} = { 'newuser' => 1, };
- &Apache::loncommon::user_rule_check($checkhash,$checks,
- \%alerts,\%rulematch,\%inst_results,\%curr_rules,
- \%got_rules);
- if (ref($alerts{'useremail'}) eq 'HASH') {
- if (ref($alerts{'useremail'}{$domain}) eq 'HASH') {
+ my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts);
+ &call_rulecheck($useremail,$domain,\%alerts,\%rulematch,
+ \%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}) {
$output = &invalid_state('userrules',$domdesc,
$contact_name,$contact_email);
@@ -552,6 +548,20 @@ sub process_email_request {
return $output;
}
+sub call_rulecheck {
+ my ($uname,$udom,$alerts,$rulematch,$inst_results,$curr_rules,
+ $got_rules,$tocheck) = @_;
+ my ($checkhash,$checks);
+ $checkhash->{$uname.':'.$udom} = { 'newuser' => 1, };
+ if ($tocheck eq 'username') {
+ $checks = { 'username' => 1 };
+ }
+ &Apache::loncommon::user_rule_check($checkhash,$checks,
+ $alerts,$rulematch,$inst_results,$curr_rules,
+ $got_rules);
+ return;
+}
+
sub send_token {
my ($domain,$email,$server,$domdesc,$contact_name,$contact_email,$courseid) = @_;
my $msg = '
'.&mt('Account creation status').'
'.
@@ -698,7 +708,7 @@ sub print_dataentry_form {
'lastname' => "Last Name",
'generation' => "Generation",
'permanentemail' => "Permanent e-mail address",
- 'id' => "ID/Student Number",
+ 'id' => "Student/Employee ID",
'lg' => "Login Data"
);
my %textboxsize = (
@@ -866,14 +876,10 @@ sub login_failure_msg {
sub username_check {
my ($username,$domain,$domdesc,$courseid,$lonhost,$contact_email,$contact_name,
$sso_logout) = @_;
- my (%rulematch,%inst_results,$newuser,$checkfail,$rowcount,$editable,$output,$msg,
+ my (%rulematch,%inst_results,$checkfail,$rowcount,$editable,$output,$msg,
%alerts,%curr_rules,%got_rules);
- $newuser = 1;
- my $checkhash;
- my $checks = { 'username' => 1 };
- $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser };
- &Apache::loncommon::user_rule_check($checkhash,$checks,\%alerts,\%rulematch,
- \%inst_results,\%curr_rules,\%got_rules);
+ &call_rulecheck($username,$domain,\%alerts,\%rulematch,
+ \%inst_results,\%curr_rules,%got_rules,'username');
if (ref($alerts{'username'}) eq 'HASH') {
if (ref($alerts{'username'}{$domain}) eq 'HASH') {
if ($alerts{'username'}{$domain}{$username}) {
@@ -999,13 +1005,32 @@ sub username_activation {
}
}
# Call modifyuser
+ my (%rulematch,%inst_results,%curr_rules,%got_rules,%alerts,%info);
+ &call_rulecheck($username,$domain,\%alerts,\%rulematch,
+ \%inst_results,\%curr_rules,%got_rules);
+ my @userinfo = ('firstname','middlename','lastname','generation',
+ 'permanentemail','id');
+ my %canmodify =
+ &Apache::loncreateuser::selfcreate_canmodify('selfcreate',$domain,
+ \@userinfo,\%inst_results);
+ foreach my $item (@userinfo) {
+ if ($canmodify{$item}) {
+ $info{$item} = $env{'form.c'.$item};
+ } else {
+ $info{$item} = $inst_results{$username.':'.$domain}{$item};
+ }
+ }
+ if (ref($inst_results{$username.':'.$domain}{'inststatus'}) eq 'ARRAY') {
+ my @inststatuses = @{$inst_results{$username.':'.$domain}{'inststatus'}};
+ $info{'inststatus'} = join(':',map { &escape($_); } @inststatuses);
+ }
my $result =
- &Apache::lonnet::modifyuser($domain,$username,$env{'form.courseid'},
+ &Apache::lonnet::modifyuser($domain,$username,$env{'form.cid'},
$domdefaults{'auth_def'},
- $domdefaults{'auth_arg_def'},$env{'form.cfirstname'},
- $env{'form.cmiddlename'},$env{'form.clastname'},
- $env{'form.cgeneration'},undef,undef,
- $env{'form.cpermanentemail'});
+ $domdefaults{'auth_arg_def'},$info{'firstname'},
+ $info{'middlename'},$info{'lastname'},
+ $info{'generation'},undef,undef,
+ $info{'permanentemail'},$info{'inststatus'});
if ($result eq 'ok') {
my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'});
$output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain);
@@ -1059,7 +1084,7 @@ sub invalid_state {
} 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.');
} 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') {
$msg = &mt('The e-mail address you provided may not be used as a username at this LON-CAPA institution.');
} elsif ($error eq 'captcha') {