--- loncom/interface/lonrequestcourse.pm 2010/06/08 16:37:20 1.52
+++ 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.52 2010/06/08 16:37:20 bisitz Exp $
+# $Id: lonrequestcourse.pm,v 1.60 2011/01/05 18:47:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -856,7 +856,7 @@ END
}
if ($action eq 'new') {
my $jsextra;
- if ($state eq 'courseinfo') {
+ if (($state eq 'courseinfo') || ($state eq 'codepick')) {
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
} elsif ($state eq 'enrollment') {
if (($env{'form.crstype'} eq 'official') &&
@@ -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 {
@@ -2534,8 +2571,8 @@ sub print_review {
if (($env{'form.cloning'}) &&
($env{'form.clonecrs'} =~ /^$match_name$/) &&
($env{'form.clonedom'} =~ /^$match_domain$/)) {
- my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
- $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
+ my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
+ $udom,$env{'form.clonecrs'},$env{'form.clonedom'},
$env{'form.crstype'});
if ($canclone) {
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
@@ -2783,15 +2820,16 @@ sub clone_form {
if ($crstype eq 'community') {
$type = 'Community';
}
- my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').' '.
- &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type);
my %lt = &clone_text();
my $output .=
- &Apache::lonhtmlcommon::row_title($lt{'cid'}).''.&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).''.&Apache::lonhtmlcommon::row_closure(1).
+ &Apache::loncommon::select_dom_form($dom,'clonedom').''.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_title($lt{'cid'}).' '.
+ &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type).
+ &Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::row_title($lt{'dsh'}).'