version 1.17, 2009/08/18 20:06:51
|
version 1.23, 2009/08/22 21:08:39
|
Line 116 use LONCAPA qw(:DEFAULT :match);
|
Line 116 use LONCAPA qw(:DEFAULT :match);
|
|
|
sub handler { |
sub handler { |
my ($r) = @_; |
my ($r) = @_; |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
if ($r->header_only) { |
if ($r->header_only) { |
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
return OK; |
return OK; |
} |
} |
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
my $dom = &get_course_dom(); |
my $dom = &get_course_dom(); |
Line 159 sub handler {
|
Line 157 sub handler {
|
$states{'view'} = ['pick_request','details','cancel','removal']; |
$states{'view'} = ['pick_request','details','cancel','removal']; |
$states{'log'} = ['filter','display']; |
$states{'log'} = ['filter','display']; |
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
$states{'new'} = ['courseinfo','enrollment','personnel','review','process']; |
|
|
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { |
unless ($env{'form.state'} eq 'crstype') { |
unless ($env{'form.state'} eq 'crstype') { |
unshift (@{$states{'new'}},'codepick'); |
unshift(@{$states{'new'}},'codepick'); |
} |
} |
} |
} |
|
|
Line 429 sub check_can_request {
|
Line 428 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 445 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 791 sub print_request_form {
|
Line 792 sub print_request_form {
|
$message = '<div class="LC_warning">'. |
$message = '<div class="LC_warning">'. |
&mt('No course was found matching your choice of institutional course category.'); |
&mt('No course was found matching your choice of institutional course category.'); |
} |
} |
unless ($code_chk eq 'ok') { |
unless ($code_chk eq 'valid') { |
$prev = 'crstype'; |
$prev = 'crstype'; |
} |
} |
$r->print($message); |
$r->print($message); |
Line 809 sub print_request_form {
|
Line 810 sub print_request_form {
|
$r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker. |
$r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker. |
&Apache::lonhtmlcommon::end_pick_box().'</div>'); |
&Apache::lonhtmlcommon::end_pick_box().'</div>'); |
} else { |
} else { |
|
$next = $states->{$action}[$page+2]; |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} |
} |
} else { |
} else { |
|
if ($crstype eq 'official') { |
|
$next = $states->{$action}[$page+2]; |
|
} |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} |
} |
} elsif ($prev eq 'codepick') { |
} elsif ($prev eq 'codepick') { |
|
if ($env{'form.instcode'} eq '') { |
|
$prev = $states->{$action}[$page-2]; |
|
} |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
} elsif ($state eq 'enrollment') { |
} elsif ($state eq 'enrollment') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
Line 1464 sub print_review {
|
Line 1472 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 1757 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 1835 sub print_request_outcome {
|
Line 1873 sub print_request_outcome {
|
} |
} |
} |
} |
} |
} |
$xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}; |
$crosslistings{$i}{'instcode'} = $xlistinfo; |
$crosslistings{$i}{'inst'} = $xlistinfo; |
$crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'}; |
$crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'}; |
$crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'}; |
} |
} |
} |
} |
Line 1962 sub print_request_outcome {
|
Line 2000 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 1986 sub print_request_outcome {
|
Line 2024 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') { |
my $inststatuslist; |
my ($inststatuslist,$validationchk,$validation); |
if (@inststatuses > 0) { |
if (@inststatuses > 0) { |
$inststatuslist = join(',',@inststatuses); |
$inststatuslist = join(',',@inststatuses); |
} |
} |
Line 1994 sub print_request_outcome {
|
Line 2032 sub print_request_outcome {
|
if (@instsections > 0) { |
if (@instsections > 0) { |
$instseclist = join(',',@instsections); |
$instseclist = join(',',@instsections); |
} |
} |
my $validation = |
$validationchk = |
&Apache::lonnet::auto_validate_instcode('',$dom,$instcode, |
&Apache::lonnet::auto_courserequest_validation($dom, |
$env{'user.name'}.':'.$env{'user.domain'},$inststatuslist, |
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
$instseclist); |
$inststatuslist,$instcode,$instseclist); |
if ($validation eq 'valid') { |
if ($validationchk =~ /:/) { |
$disposition = 'process'; |
($validation,$message) = split(':',$validationchk); |
} elsif ($validation eq 'rejected') { |
} else { |
$disposition = 'rejected'; |
$validation = $validationchk; |
} elsif ($validation eq 'pending') { |
} |
$disposition = 'pending'; |
if ($validation =~ /^error(.*)$/) { |
} elsif ($disposition eq 'approval') { |
|
$disposition = 'approval'; |
|
} elsif ($disposition =~ /^error(.*)$/) { |
|
$disposition = 'approval'; |
$disposition = 'approval'; |
$validationerror = $1; |
$validationerror = $1; |
} else { |
} else { |
$disposition = 'approval'; |
$disposition = $validation; |
} |
} |
} else { |
} else { |
$disposition = 'approval'; |
$disposition = 'approval'; |
Line 2114 sub print_request_outcome {
|
Line 2149 sub print_request_outcome {
|
¬ification_information($disposition,$req_notifylist,$cnum,$now); |
¬ification_information($disposition,$req_notifylist,$cnum,$now); |
} |
} |
if ($validationerror ne '') { |
if ($validationerror ne '') { |
$output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: {_1].',$validationerror).'</p>'; |
$output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>'; |
} |
} |
} |
} |
return $output; |
return $output; |
Line 2161 sub get_processtype {
|
Line 2196 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 2174 sub get_processtype {
|
Line 2209 sub get_processtype {
|
if (ref($domconfig->{'requestcourses'}) eq 'HASH') { |
if (ref($domconfig->{'requestcourses'}) eq 'HASH') { |
%settings = %{$domconfig->{'requestcourses'}}; |
%settings = %{$domconfig->{'requestcourses'}}; |
if (ref($settings{$crstype}) eq 'HASH') { |
if (ref($settings{$crstype}) eq 'HASH') { |
if (($env{'user.adv'}) && (exists($settings{$crstype}{'_LC_adv'}))) { |
if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) { |
$val = $settings{$crstype}{'_LC_adv'}; |
$val = $settings{$crstype}{'_LC_adv'}; |
@{$inststatuses} = ('_LC_adv_'); |
@{$inststatuses} = ('_LC_adv_'); |
} else { |
} else { |
Line 2227 sub get_processtype {
|
Line 2262 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_'); |
} |
} |
Line 2327 sub retrieve_settings {
|
Line 2368 sub retrieve_settings {
|
my %crscode = ( |
my %crscode = ( |
$i => $reqinfo{'crosslistings'}{$i}{'instcode'}, |
$i => $reqinfo{'crosslistings'}{$i}{'instcode'}, |
); |
); |
&extract_instcode($dom,'crosslist',\%crscode,$1,$xlistsec); |
&extract_instcode($dom,'crosslist',\%crscode,$i,$xlistsec); |
} |
} |
} |
} |
} |
} |
Line 2353 sub retrieve_settings {
|
Line 2394 sub retrieve_settings {
|
if (grep(/^\Q$sec\E/,@currsec)) { |
if (grep(/^\Q$sec\E/,@currsec)) { |
$env{'form.person_'.$i.'_sec'} = $sec; |
$env{'form.person_'.$i.'_sec'} = $sec; |
} else { |
} else { |
push (@newsecs,$sec); |
push(@newsecs,$sec); |
} |
} |
} |
} |
} |
} |