--- loncom/interface/lonrequestcourse.pm 2010/11/19 00:01:25 1.59
+++ loncom/interface/lonrequestcourse.pm 2011/01/05 18:47:46 1.60
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.59 2010/11/19 00:01:25 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.60 2011/01/05 18:47:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1322,16 +1322,38 @@ sub print_request_form {
}
if ($skipuser) {
push(@disallowed,$i);
- $disallowmsg{$i} = &mt('[_1] was excluded because new users need be from the course domain',''.$personname.':'.$persondom.'');
+ $disallowmsg{$i} = &mt('[_1] was excluded because new users need to be from the course domain',''.$personname.':'.$persondom.'');
next;
}
}
- if (&get_cancreate_status($persondom,$personname,$dom)) {
- my ($allowed,$msg) =
+ my $usertype = &get_usertype($persondom,$personname,\%curr_rules,\%got_rules);
+ if (&Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype)) {
+ my ($allowed,$msg,$authtype,$authparam) =
&check_newuser_rules($persondom,$personname,
\%alerts,\%rulematch,\%inst_results,
\%curr_rules,\%got_rules);
if ($allowed) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($persondom);
+ if ($usertype eq 'official') {
+ if ($authtype eq '') {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ } elsif ($usertype eq 'unofficial') {
+ if ($authtype eq '') {
+ $authtype = 'internal';
+ $authparam = '';
+ }
+ } else {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ if (($authtype eq '') ||
+ (($authtype =~/^krb/) && ($authparam eq ''))) {
+ push(@disallowed,$i);
+ $disallowmsg{$i} = &mt('[_1] was excluded because institutional information is incomplete for this new user.',''.$personname.':'.$persondom.'');
+ next;
+ }
if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {
if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {
$env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};
@@ -1454,13 +1476,13 @@ sub print_request_form {
return;
}
-sub get_cancreate_status {
- my ($persondom,$personname,$dom) = @_;
+sub get_usertype {
+ my ($persondom,$personname,$curr_rules,$got_rules) = @_;
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($persondom,'username');
my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
- $rules);
- return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype);
+ $rules,$curr_rules,$got_rules);
+ return $usertype;
}
sub check_newuser_rules {
@@ -1468,7 +1490,7 @@ sub check_newuser_rules {
$got_rules) = @_;
my $allowed = 1;
my $newuser = 1;
- my ($checkhash,$userchkmsg);
+ my ($checkhash,$userchkmsg,$authtype,$authparam);
my $checks = { 'username' => 1 };
$checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
&Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
@@ -1490,7 +1512,22 @@ sub check_newuser_rules {
}
}
}
- return ($allowed,$userchkmsg);
+ if ($allowed) {
+ if (ref($rulematch) eq 'HASH') {
+ if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') {
+ my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'};
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($persondom,'username');
+ if (ref($rules) eq 'HASH') {
+ if (ref($rules->{$matchedrule}) eq 'HASH') {
+ $authtype = $rules->{$matchedrule}{'authtype'};
+ $authparam = $rules->{$matchedrule}{'authparm'};
+ }
+ }
+ }
+ }
+ }
+ return ($allowed,$userchkmsg,$authtype,$authparam);
}
sub get_excluded_elements {
@@ -3065,6 +3102,7 @@ sub print_request_outcome {
$enrollstart = '';
$enrollend = '';
}
+ my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg);
for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
my $uname = $env{'form.person_'.$i.'_uname'};
my $udom = $env{'form.person_'.$i.'_dom'};
@@ -3076,6 +3114,51 @@ sub print_request_outcome {
lastname => $env{'form.person_'.$i.'_lastname'},
emailaddr => $env{'form.person_'.$i.'_emailaddr'},
};
+ my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);
+ if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {
+ my ($allowed,$msg,$authtype,$authparam) =
+ &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,
+ \%inst_results,\%curr_rules,\%got_rules);
+ if ($allowed) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);
+ if ($usertype eq 'official') {
+ if ($authtype eq '') {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ } else {
+ if ($authtype eq 'loc') {
+ $authtype = 'localauth';
+ } elsif ($authtype eq 'int') {
+ $authtype = 'internal';
+ }
+ if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ }
+ } elsif ($usertype eq 'unofficial') {
+ if ($authtype eq '') {
+ $authtype = 'internal';
+ $authparam = '';
+ }
+ } else {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ if (($authtype eq '') ||
+ (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||
+ ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {
+ next;
+ } else {
+ $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
+ $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
+ }
+ } else {
+ next;
+ }
+ } else {
+ next;
+ }
}
my $role = $env{'form.person_'.$i.'_role'};
unless ($role eq '') {