version 1.16, 2009/08/18 01:41:37
|
version 1.19, 2009/08/20 21:15:37
|
Line 429 sub check_can_request {
|
Line 429 sub check_can_request {
|
my ($dom,$can_request) = @_; |
my ($dom,$can_request) = @_; |
my $canreq = 0; |
my $canreq = 0; |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &course_types(); |
|
my @options = ('approval','validate','autolimit'); |
|
my $optregex = join('|',@options); |
if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { |
if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { |
foreach my $type (@{$types}) { |
foreach my $type (@{$types}) { |
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
Line 444 sub check_can_request {
|
Line 446 sub check_can_request {
|
if (@curr > 0) { |
if (@curr > 0) { |
$canreq ++; |
$canreq ++; |
unless ($dom eq $env{'user.domain'}) { |
unless ($dom eq $env{'user.domain'}) { |
if (grep(/^\Q$dom\E$/,@curr)) { |
if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) { |
$can_request->{$type} = 1; |
$can_request->{$type} = 1; |
} |
} |
} |
} |
Line 775 sub print_request_form {
|
Line 777 sub print_request_form {
|
} |
} |
if ($instcode ne '') { |
if ($instcode ne '') { |
$code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode); |
$code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode); |
if ($code_chk eq 'ok') { |
if ($code_chk eq 'valid') { |
$message = '<div class="LC_info">'. |
$message = '<div class="LC_info">'. |
&mt('The chosen course category [_1] is valid.','<b>'. |
&mt('The chosen course category [_1] is valid.','<b>'. |
$instcode.'</b>').'</div>'; |
$instcode.'</b>').'</div>'; |
Line 1464 sub print_review {
|
Line 1466 sub print_review {
|
$inst_values .= '<td>'.$courseenv{'description'}.' '; |
$inst_values .= '<td>'.$courseenv{'description'}.' '; |
my $cloneinst = $courseenv{'internal.coursecode'}; |
my $cloneinst = $courseenv{'internal.coursecode'}; |
if ($cloneinst ne '') { |
if ($cloneinst ne '') { |
$inst_values .= &mt('([_1] in [_2])',$cloneinst,$env{'form.clonedom'}); |
$inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'}; |
} else { |
} else { |
$inst_values .= &mt('(from [_1])',$env{'form.clonedom'}); |
$inst_values .= &mt('from').' '.$env{'form.clonedom'}; |
} |
} |
$inst_values .= '</td><td>'; |
$inst_values .= '</td><td>'; |
if ($env{'form.datemode'} eq 'preserve') { |
if ($env{'form.datemode'} eq 'preserve') { |
Line 1749 sub coursecode_form {
|
Line 1751 sub coursecode_form {
|
|
|
sub get_course_dom { |
sub get_course_dom { |
my $codedom = &Apache::lonnet::default_login_domain(); |
my $codedom = &Apache::lonnet::default_login_domain(); |
|
if ($env{'form.showdom'} ne '') { |
|
if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { |
|
return $env{'form.showdom'}; |
|
} |
|
} |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
|
my ($types,$typename) = &course_types(); |
|
if (ref($types) eq 'ARRAY') { |
|
foreach my $type (@{$types}) { |
|
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'},$type, |
|
undef,'requestcourses')) { |
|
return $env{'user.domain'}; |
|
} |
|
} |
|
my @possible_doms; |
|
foreach my $type (@{$types}) { |
|
my $dom_str = $env{'environment.reqcrsotherdom.'.$type}; |
|
if ($dom_str ne '') { |
|
my @domains = split(',',$dom_str); |
|
foreach my $entry (@domains) { |
|
my ($extdom,$extopt) = split(':',$entry); |
|
if ($extdom eq $env{'request.role.domain'}) { |
|
return $extdom; |
|
} |
|
unless(grep(/^\Q$extdom\E$/,@possible_doms)) { |
|
push(@possible_doms,$extdom); |
|
} |
|
} |
|
} |
|
} |
|
if (@possible_doms) { |
|
@possible_doms = sort(@possible_doms); |
|
return $possible_doms[0]; |
|
} |
|
} |
$codedom = $env{'user.domain'}; |
$codedom = $env{'user.domain'}; |
if ($env{'request.role.domain'} ne '') { |
if ($env{'request.role.domain'} ne '') { |
$codedom = $env{'request.role.domain'}; |
$codedom = $env{'request.role.domain'}; |
} |
} |
} |
} |
if ($env{'form.showdom'} ne '') { |
|
if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { |
|
$codedom = $env{'form.showdom'}; |
|
} |
|
} |
|
return $codedom; |
return $codedom; |
} |
} |
|
|
Line 1808 sub print_request_outcome {
|
Line 1840 sub print_request_outcome {
|
} |
} |
$now = time; |
$now = time; |
$crstype = $env{'form.crstype'}; |
$crstype = $env{'form.crstype'}; |
|
my @instsections; |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
if (&Apache::lonnet::auto_run('',$dom)) { |
if (&Apache::lonnet::auto_run('',$dom)) { |
($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend'); |
($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend'); |
Line 1815 sub print_request_outcome {
|
Line 1848 sub print_request_outcome {
|
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
if ($env{'form.sec_'.$i}) { |
if ($env{'form.sec_'.$i}) { |
if ($env{'form.secnum_'.$i} ne '') { |
if ($env{'form.secnum_'.$i} ne '') { |
$sections{$i}{'inst'} = $env{'form.secnum_'.$i}; |
my $sec = $env{'form.secnum_'.$i}; |
|
$sections{$i}{'inst'} = $sec; |
|
if (($sec ne '') && (!grep(/^\Q$sec\E$/,@instsections))) { |
|
push(@instsections,$sec); |
|
} |
$sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i}; |
$sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i}; |
} |
} |
} |
} |
Line 1957 sub print_request_outcome {
|
Line 1994 sub print_request_outcome {
|
my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); |
my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig); |
if ($val eq '') { |
if ($val eq '') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
$output = &mt('You are not permitted to request creation of official courses'); |
$output = &mt('You are not permitted to request creation of official courses.'); |
} elsif ($crstype eq 'unofficial') { |
} elsif ($crstype eq 'unofficial') { |
$output = &mt('You are not permitted to request creation of unofficial courses'); |
$output = &mt('You are not permitted to request creation of unofficial courses.'); |
} elsif ($crstype eq 'community') { |
} elsif ($crstype eq 'community') { |
$output = &mt('You are not permitted to request creation of communities'); |
$output = &mt('You are not permitted to request creation of communities'); |
} else { |
} else { |
Line 1973 sub print_request_outcome {
|
Line 2010 sub print_request_outcome {
|
details => $details, |
details => $details, |
); |
); |
my $requestkey = $dom.'_'.$cnum; |
my $requestkey = $dom.'_'.$cnum; |
|
my $validationerror; |
if ($val eq 'autolimit=') { |
if ($val eq 'autolimit=') { |
$disposition = 'process'; |
$disposition = 'process'; |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
Line 1980 sub print_request_outcome {
|
Line 2018 sub print_request_outcome {
|
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'}, |
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'}, |
$dom,$crstype,$limit,\$message); |
$dom,$crstype,$limit,\$message); |
} elsif ($val eq 'validate') { |
} elsif ($val eq 'validate') { |
$disposition = |
my $inststatuslist; |
&Apache::lonnet::auto_courserequest_validation($dom,$details, |
if (@inststatuses > 0) { |
\@inststatuses,\$message); |
$inststatuslist = join(',',@inststatuses); |
|
} |
|
my $instseclist; |
|
if (@instsections > 0) { |
|
$instseclist = join(',',@instsections); |
|
} |
|
my $validation = |
|
&Apache::lonnet::auto_validate_instcode('',$dom,$instcode, |
|
$env{'user.name'}.':'.$env{'user.domain'},$inststatuslist, |
|
$instseclist); |
|
if ($validation eq 'valid') { |
|
$disposition = 'process'; |
|
} elsif ($validation eq 'rejected') { |
|
$disposition = 'rejected'; |
|
} elsif ($validation eq 'pending') { |
|
$disposition = 'pending'; |
|
} elsif ($disposition eq 'approval') { |
|
$disposition = 'approval'; |
|
} elsif ($disposition =~ /^error(.*)$/) { |
|
$disposition = 'approval'; |
|
$validationerror = $1; |
|
} else { |
|
$disposition = 'approval'; |
|
} |
} else { |
} else { |
$disposition = 'approval'; |
$disposition = 'approval'; |
} |
} |
Line 2035 sub print_request_outcome {
|
Line 2096 sub print_request_outcome {
|
my $statuskey = 'status:'.$dom.':'.$cnum; |
my $statuskey = 'status:'.$dom.':'.$cnum; |
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey], |
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey], |
$env{'user.domain'},$env{'user.name'}); |
$env{'user.domain'},$env{'user.name'}); |
if (exists($userreqhash{$statuskey})) { |
if ($userreqhash{$statuskey} ne '') { |
$modified = 1; |
$modified = 1; |
my %queuehash = &Apache::lonnet::get_dom('courserequestqueue', |
my %queuehash = &Apache::lonnet::get_dom('courserequestqueue', |
[$cnum.'_approval', |
[$cnum.'_approval', |
$cnum.'_pending'],$dom); |
$cnum.'_pending'],$dom); |
if ((exists($queuehash{$cnum.'_approval'})) || |
if (($queuehash{$cnum.'_approval'} ne '') || |
(exists($queuehash{$cnum.'_pending'}))) { |
($queuehash{$cnum.'_pending'} ne '')) { |
$queued = 1; |
$queued = 1; |
} |
} |
} |
} |
Line 2084 sub print_request_outcome {
|
Line 2145 sub print_request_outcome {
|
$output .= '<p>'.&mt('Your course request has been updated').'</p>'. |
$output .= '<p>'.&mt('Your course request has been updated').'</p>'. |
¬ification_information($disposition,$req_notifylist,$cnum,$now); |
¬ification_information($disposition,$req_notifylist,$cnum,$now); |
} |
} |
|
if ($validationerror ne '') { |
|
$output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>'; |
|
} |
} |
} |
return $output; |
return $output; |
} |
} |
Line 2111 sub notification_information {
|
Line 2175 sub notification_information {
|
my $sender = $env{'user.name'}.':'.$env{'user.domain'}; |
my $sender = $env{'user.name'}.':'.$env{'user.domain'}; |
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender); |
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender); |
} |
} |
} else { |
} elsif ($disposition eq 'pending') { |
$output .= '<div class="LC_info">'. |
$output .= '<div class="LC_info">'. |
&mt('Your request has been placed in a queue pending administrative action.').'<br />'. |
&mt('Your request has been placed in a queue pending administrative action.').'<br />'. |
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'. |
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'. |
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.'). |
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.'). |
'</div>'; |
'</div>'; |
|
} else { |
|
$output .= '<div class="LC_warning">'. |
|
&mt('Your request status is: [_1].',$disposition). |
|
'</div>' |
} |
} |
return $output; |
return $output; |
} |
} |
Line 2125 sub get_processtype {
|
Line 2193 sub get_processtype {
|
my ($dom,$crstype,$inststatuses,$domconfig) = @_; |
my ($dom,$crstype,$inststatuses,$domconfig) = @_; |
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); |
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); |
my (%userenv,%settings,$val); |
my (%userenv,%settings,$val); |
my @options = ('autolimit','validate','approve'); |
my @options = ('autolimit','validate','approval'); |
if ($dom eq $env{'user.domain'}) { |
if ($dom eq $env{'user.domain'}) { |
%userenv = |
%userenv = |
&Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
&Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, |
Line 2191 sub get_processtype {
|
Line 2259 sub get_processtype {
|
} else { |
} else { |
%userenv = &Apache::lonnet::userenvironment($env{'user.domain'}, |
%userenv = &Apache::lonnet::userenvironment($env{'user.domain'}, |
$env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'}); |
$env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'}); |
if ($userenv{'reqcrsotherdom'}) { |
if ($userenv{'reqcrsotherdom.'.$crstype}) { |
my @doms = split(',',$userenv{'reqcrsotherdom'}); |
my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype}); |
my $optregex = join('|',@options); |
my $optregex = join('|',@options); |
if (grep(/^\Q$dom\E:($optregex=?\d*)/,@doms)) { |
foreach my $item (@doms) { |
$val = $1; |
my ($extdom,$extopt) = split(':',$item); |
|
if ($extdom eq $dom) { |
|
if ($extopt =~ /^($optregex)(=?\d*)$/) { |
|
$val = $1.$2; |
|
} |
|
last; |
|
} |
} |
} |
@{$inststatuses} = ('_external_'); |
@{$inststatuses} = ('_external_'); |
} |
} |