';
if ($context eq 'crosslist') {
$output .= ''.&mt('Include?').' '.
@@ -2370,6 +2985,26 @@ sub coursecode_form {
return $output;
}
+sub sections_form {
+ my ($dom,$instcode,$num) = @_;
+ my $rowtitle;
+ if ($instcode eq '') {
+ $rowtitle = &mt('Sections');
+ } else {
+ $rowtitle = &mt('Sections of [_1]',$instcode);
+ }
+ return &Apache::lonhtmlcommon::row_title($rowtitle).
+ ''.
+ &Apache::lonhtmlcommon::row_closure(1);
+}
+
sub get_course_dom {
my $codedom = &Apache::lonnet::default_login_domain();
if ($env{'form.showdom'} ne '') {
@@ -2481,6 +3116,10 @@ sub print_request_outcome {
}
$now = time;
$crstype = $env{'form.crstype'};
+ my $ccrole = 'cc';
+ if ($crstype eq 'community') {
+ $ccrole = 'co';
+ }
my @instsections;
if ($crstype eq 'official') {
if (&Apache::lonnet::auto_run('',$dom)) {
@@ -2495,6 +3134,10 @@ sub print_request_outcome {
push(@instsections,$sec);
}
$sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
+ $sections{$i}{'loncapa'} =~ s/\W//g;
+ if ($sections{$i}{'loncapa'} eq 'none') {
+ $sections{$i}{'loncapa'} = '';
+ }
}
}
}
@@ -2520,6 +3163,7 @@ sub print_request_outcome {
$enrollstart = '';
$enrollend = '';
}
+ my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg,%skipped);
for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
my $uname = $env{'form.person_'.$i.'_uname'};
my $udom = $env{'form.person_'.$i.'_dom'};
@@ -2531,6 +3175,56 @@ sub print_request_outcome {
lastname => $env{'form.person_'.$i.'_lastname'},
emailaddr => $env{'form.person_'.$i.'_emailaddr'},
};
+ if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
+ 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)$/)) {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ } else {
+ $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
+ $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
+ }
+ } else {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ }
+ } else {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ }
+ }
}
my $role = $env{'form.person_'.$i.'_role'};
unless ($role eq '') {
@@ -2542,7 +3236,7 @@ sub print_request_outcome {
} else {
@{$personnel{$uname.':'.$udom}{'roles'}} = ($role);
}
- if ($role eq 'cc') {
+ if ($role eq $ccrole) {
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = ();
} else {
my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
@@ -2576,6 +3270,11 @@ sub print_request_outcome {
push(@baduname,$uname.':'.$udom);
}
}
+ if (keys(%skipped)) {
+ foreach my $key (keys(%skipped)) {
+ delete($personnel{$key});
+ }
+ }
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
my $autodrops = 0;
if ($env{'form.autodrops'}) {
@@ -2583,10 +3282,7 @@ sub print_request_outcome {
}
my $autoadds = 0;
if ($env{'form.autoadds'}) {
- $autodrops = $env{'form.autoadds'};
- }
- if ($env{'form.autoadds'}) {
- $autodrops = $env{'form.autoadds'};
+ $autoadds = $env{'form.autoadds'};
}
my $instcode = '';
if (exists($env{'form.instcode'})) {
@@ -2594,14 +3290,16 @@ sub print_request_outcome {
}
my $clonecrs = '';
my $clonedom = '';
- if (($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
+ if (($env{'form.cloning'}) &&
+ ($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
($env{'form.clonedom'} =~ /^($match_domain)$/)) {
my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
$env{'form.clonedom'});
if ($clonehome ne 'no_host') {
my $canclone =
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
- $env{'user.domain'},$env{'form.clonecrs'}, $env{'form.clonedom'});
+ $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
+ $crstype);
if ($canclone) {
$clonecrs = $env{'form.clonecrs'};
$clonedom = $env{'form.clonedom'};
@@ -2634,7 +3332,10 @@ sub print_request_outcome {
personnel => \%personnel,
};
my (@inststatuses,$storeresult,$creationresult);
- my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
+ my $val =
+ &Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'},
+ $env{'user.domain'},$env{'user.adv'},
+ $dom,$crstype,\@inststatuses,\%domconfig);
if ($val eq '') {
if ($crstype eq 'official') {
$output = &mt('You are not permitted to request creation of official courses.');
@@ -2692,7 +3393,11 @@ sub print_request_outcome {
$reqstatus = $disposition;
my ($modified,$queued);
if ($disposition eq 'rejected') {
- $output = &mt('Your course request was rejected.');
+ if ($crstype eq 'community') {
+ $output = &mt('Your community request was rejected.');
+ } else {
+ $output = &mt('Your course request was rejected.');
+ }
if ($message) {
$output .= ''.$message.' ';
}
@@ -2700,11 +3405,11 @@ sub print_request_outcome {
} elsif ($disposition eq 'process') {
my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles);
- my @roles = &Apache::lonuserutils::roles_by_context('course');
my $type = 'Course';
if ($crstype eq 'community') {
$type = 'Community';
}
+ my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
foreach my $role (@roles) {
$longroles{$role}=&Apache::lonnet::plaintext($role,$type);
}
@@ -2716,14 +3421,22 @@ sub print_request_outcome {
$reqstatus = 'created';
my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details,
\%longroles);
- $output = ''.&mt('Your course request has been processed and the course has been created.').
- ' '.$role_result.' ';
+ if ($crstype eq 'community') {
+ $output = ''.&mt('Your community request has been processed and the community has been created.');
+ } else {
+ $output = ' '.&mt('Your course request has been processed and the course has been created.');
+ }
+ $output .= ' '.$role_result.' ';
$creationresult = 'created';
} else {
- $output = ''.
- &mt('An error occurred when processing your course request.').
- ' '.
- &mt('You may want to review the request details and submit the request again.').
+ $output = '';
+ if ($crstype eq 'community') {
+ $output .= &mt('An error occurred when processing your community request.');
+ } else {
+ $output .= &mt('An error occurred when processing your course request.');
+ }
+ $output .= ' '.
+ &mt('You may want to review the request details and submit the request again.').
'';
$creationresult = 'error';
}
@@ -2738,6 +3451,9 @@ sub print_request_outcome {
description => $env{'form.cdescr'},
},
};
+ if ($crstype eq 'official') {
+ $request->{$requestid}->{'instcode'} = $instcode;
+ }
my $statuskey = 'status:'.$dom.':'.$cnum;
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
$env{'user.domain'},$env{'user.name'});
@@ -2756,7 +3472,12 @@ sub print_request_outcome {
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,
$dom);
if ($putresult eq 'ok') {
- $output = &mt('Your course request has been recorded.').' '.
+ if ($crstype eq 'community') {
+ $output .= &mt('Your community request has been recorded.');
+ } else {
+ $output .= &mt('Your course request has been recorded.')
+ }
+ $output .= ' '.
¬ification_information($disposition,$req_notifylist,
$cnum,$now);
} else {
@@ -2767,32 +3488,22 @@ sub print_request_outcome {
}
}
}
- my ($statusresult);
- if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- $storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
- 'courserequests');
- if ($storeresult eq 'ok') {
- my %status = (
- 'status:'.$dom.':'.$cnum => $reqstatus,
- );
- $statusresult = &Apache::lonnet::put('courserequests',\%status);
- }
- } else {
- $storeresult = 'error: invalid requestkey format';
- }
- if ($storeresult ne 'ok') {
- $output .= ''.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).' ';
- &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
- } elsif ($statusresult ne 'ok') {
- $output .= ''.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).' ';
- &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
- }
+ ($storeresult,my $updateresult) =
+ &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
+ $cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'});
if ($modified && $queued && $storeresult eq 'ok') {
- $output .= ''.&mt('Your course request has been updated').' '.
- ¬ification_information($disposition,$req_notifylist,$cnum,$now);
+ if ($crstype eq 'community') {
+ $output .= ''.&mt('Your community request has been updated').' ';
+ } else {
+ $output .= ''.&mt('Your course request has been updated').' ';
+ }
+ $output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now);
}
if ($validationerror ne '') {
- $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'';
+ $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).' ';
+ }
+ if ($updateresult) {
+ $output .= $updateresult;
}
}
if ($creationresult ne '') {
@@ -2809,23 +3520,34 @@ sub update_requestors_roles {
my $owner = $env{'user.name'}.':'.$env{'user.domain'};
if (ref($details) eq 'HASH') {
if (ref($details->{'personnel'}) eq 'HASH') {
+ my $ccrole = 'cc';
+ if ($crstype eq 'community') {
+ $ccrole = 'co';
+ }
unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
$details->{'personnel'}{$owner} = {
- 'roles' => ['cc'],
- 'cc' => { 'usec' => [] },
+ 'roles' => [$ccrole],
+ $ccrole => { 'usec' => [] },
};
}
my @roles;
if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
@roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
- unless (grep(/^cc$/,@roles)) {
- push(@roles,'cc');
+ unless (grep(/^\Q$ccrole\E$/,@roles)) {
+ push(@roles,$ccrole);
}
} else {
- @roles = ('cc');
+ @roles = ($ccrole);
}
foreach my $role (@roles) {
- my $start = $now;
+ my $refresh=$env{'user.refresh.time'};
+ if ($refresh eq '') {
+ $refresh = $env{'user.login.time'};
+ }
+ if ($refresh eq '') {
+ $refresh = $now;
+ }
+ my $start = $refresh-1;
my $end = '0';
if ($role eq 'st') {
if ($details->{'accessstart'} ne '') {
@@ -2836,7 +3558,7 @@ sub update_requestors_roles {
}
}
my @usecs;
- if ($role ne 'cc') {
+ if ($role ne $ccrole) {
if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
@usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
}
@@ -2901,15 +3623,27 @@ sub update_requestors_roles {
}
if ($active) {
if ($numactive == 1) {
- $output = &mt('Use the following link to enter the course:');
+ if ($crstype eq 'Community') {
+ $output = &mt('Use the following link to enter the community:');
+ } else {
+ $output = &mt('Use the following link to enter the course:');
+ }
} else {
- $output = &mt('Use the following links to your new roles to enter the course:');
+ if ($crstype eq 'Community') {
+ $output = &mt('Use the following links to your new roles to enter the community:');
+ } else {
+ $output = &mt('Use the following links to your new roles to enter the course:');
+ }
}
$output .= ' ';
}
if ($future) {
- $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'})).
- ' ';
+ if ($crstype eq 'Community') {
+ $output .= &mt('The following community [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'}))
+ } else {
+ $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'}));
+ }
+ $output .= ' ';
}
return $output;
}
@@ -2945,128 +3679,43 @@ sub notification_information {
'';
} else {
$output .= ''.
- &mt('Your request status is: [_1].',$disposition).
- ' '
+ &mt('Your request status is: [_1].',$disposition).
+ '';
}
return $output;
}
-sub get_processtype {
- my ($dom,$crstype,$inststatuses,$domconfig) = @_;
- return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
- my (%userenv,%settings,$val);
- my @options = ('autolimit','validate','approval');
- if ($dom eq $env{'user.domain'}) {
- %userenv =
- &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
- 'requestcourses.'.$crstype,'inststatus');
- if ($userenv{'requestcourses.'.$crstype}) {
- $val = $userenv{'requestcourses.'.$crstype};
- @{$inststatuses} = ('_custom_');
- } else {
- my ($task,%alltasks);
- if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
- %settings = %{$domconfig->{'requestcourses'}};
- if (ref($settings{$crstype}) eq 'HASH') {
- if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
- $val = $settings{$crstype}{'_LC_adv'};
- @{$inststatuses} = ('_LC_adv_');
- } else {
- if ($userenv{'inststatus'} ne '') {
- @{$inststatuses} = split(',',$userenv{'inststatus'});
- } else {
- @{$inststatuses} = ('default');
- }
- foreach my $status (@{$inststatuses}) {
- if (exists($settings{$crstype}{$status})) {
- my $value = $settings{$crstype}{$status};
- next unless ($value);
- unless (exists($alltasks{$value})) {
- if (ref($alltasks{$value}) eq 'ARRAY') {
- unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
- push(@{$alltasks{$value}},$status);
- }
- } else {
- @{$alltasks{$value}} = ($status);
- }
- }
- }
- }
- my $maxlimit = 0;
-
- foreach my $key (sort(keys(%alltasks))) {
- if ($key =~ /^autolimit=(\d*)$/) {
- if ($1 eq '') {
- $val ='autolimit=';
- last;
- } elsif ($1 > $maxlimit) {
- $maxlimit = $1;
- }
- }
- }
- if ($maxlimit) {
- $val = 'autolimit='.$maxlimit;
- } else {
- foreach my $option (@options) {
- if ($alltasks{$option}) {
- $val = $option;
- last;
- }
- }
- }
- }
- }
- }
- }
- } else {
- %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},
- $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'});
- if ($userenv{'reqcrsotherdom.'.$crstype}) {
- my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
- my $optregex = join('|',@options);
- foreach my $item (@doms) {
- my ($extdom,$extopt) = split(':',$item);
- if ($extdom eq $dom) {
- if ($extopt =~ /^($optregex)(=?\d*)$/) {
- $val = $1.$2;
- }
- last;
- }
- }
- @{$inststatuses} = ('_external_');
- }
- }
- return $val;
-}
-
sub check_autolimit {
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
- 'userroles',['active','future'],['cc'],[$dom]);
+ 'userroles',['active','future'],['cc','co'],[$dom]);
my ($types,$typename) = &Apache::loncommon::course_types();
my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);
- my %count;
- if (ref($types) eq 'ARRAY') {
- foreach my $type (@{$types}) {
- $count{$type} = 0;
- }
- }
+ my $count = 0;
foreach my $key (keys(%requests)) {
my ($cdom,$cnum) = split('_',$key);
- if (exists($crsroles{$cnum.':'.$cdom.':cc'})) {
- if (ref($requests{$key}) eq 'HASH') {
- my $type = $requests{$key}{'crstype'};
- if ($type =~ /^official|unofficial|community$/) {
- $count{$type} ++;
- }
+ if (ref($requests{$key}) eq 'HASH') {
+ next if ($requests{$key}{'crstype'} ne $crstype);
+ if (($crstype eq 'community') &&
+ (exists($crsroles{$cnum.':'.$cdom.':co'}))) {
+ $count ++;
+ } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) &&
+ (exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
+ $count ++;
}
}
}
- if ($count{$crstype} < $limit) {
+ if ($count < $limit) {
return 'process';
} else {
if (ref($typename) eq 'HASH') {
- $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').' '.&mt("Your $typename->{$crstype} limit is [_1].",$limit);
+ if ($crstype eq 'community') {
+ $$message = &mt('Your request has not been processed because you have reached the limit for the number of communities.').
+ ' '.&mt("Your limit is [_1].",$limit);
+ } else {
+ $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').
+ ' '.&mt("Your $typename->{$crstype} limit is [_1].",$limit);
+ }
}
return 'rejected';
}
@@ -3096,18 +3745,23 @@ sub retrieve_settings {
}
$env{'form.clonecrs'} = $reqinfo{'clonecrs'};
$env{'form.clonedom'} = $reqinfo{'clonedom'};
+ if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
+ $env{'form.cloning'} = 1;
+ }
$env{'form.datemode'} = $reqinfo{'datemode'};
$env{'form.dateshift'} = $reqinfo{'dateshift'};
- if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {
- $env{'form.sectotal'} = $reqinfo{'sectotal'};
- $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
- $env{'form.autoadds'} = $reqinfo{'autoadds'};
- $env{'form.autdrops'} = $reqinfo{'autodrops'};
- $env{'form.instcode'} = $reqinfo{'instcode'};
- my $crscode = {
- $cnum => $reqinfo{'instcode'},
- };
- &extract_instcode($dom,'instcode',$crscode,$cnum);
+ if ($reqinfo{'crstype'} eq 'official') {
+ $env{'form.autoadds'} = $reqinfo{'autoadds'};
+ $env{'form.autodrops'} = $reqinfo{'autodrops'};
+ if ($reqinfo{'instcode'} ne '') {
+ $env{'form.sectotal'} = $reqinfo{'sectotal'};
+ $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
+ $env{'form.instcode'} = $reqinfo{'instcode'};
+ my $crscode = {
+ $cnum => $reqinfo{'instcode'},
+ };
+ &extract_instcode($dom,'instcode',$crscode,$cnum);
+ }
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
|