version 1.77, 2014/04/09 10:50:07
|
version 1.78, 2014/04/16 14:40:17
|
Line 1526 sub print_request_form {
|
Line 1526 sub print_request_form {
|
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
\%cat_order,\@code_order); |
\%cat_order,\@code_order); |
} |
} |
my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles, |
my $lonhost = $r->dir_config('lonHostID'); |
|
my ($storeresult,$result) = &print_request_outcome($lonhost,$dom,\@codetitles, |
\@code_order,$instcredits); |
\@code_order,$instcredits); |
$r->print($result); |
$r->print($result); |
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
if (($storeresult eq 'ok') || ($storeresult eq 'created')) { |
Line 3335 sub display_navbuttons {
|
Line 3336 sub display_navbuttons {
|
} |
} |
|
|
sub print_request_outcome { |
sub print_request_outcome { |
my ($dom,$codetitles,$code_order,$instcredits) = @_; |
my ($lonhost,$dom,$codetitles,$code_order,$instcredits) = @_; |
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend, |
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend, |
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig, |
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig, |
$uniquecode); |
$uniquecode); |
Line 3580 sub print_request_outcome {
|
Line 3581 sub print_request_outcome {
|
accessend => $accessend, |
accessend => $accessend, |
personnel => \%personnel, |
personnel => \%personnel, |
}; |
}; |
my ($result,$output) = &process_request($dom,$cnum,$crstype,$now,$details,$instcode, |
my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode, |
$req_notifylist,\@instsections,\%domconfig); |
$req_notifylist,\@instsections,\%domconfig); |
return ($result,$output); |
return ($result,$output); |
} |
} |
|
|
sub process_request { |
sub process_request { |
my ($dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,$domconfig) = @_; |
my ($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections, |
|
$domconfig) = @_; |
my (@inststatuses,$storeresult,$creationresult,$output); |
my (@inststatuses,$storeresult,$creationresult,$output); |
my $val = |
my $val = |
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'}, |
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'}, |
Line 3606 sub process_request {
|
Line 3608 sub process_request {
|
} |
} |
$storeresult = 'notpermitted'; |
$storeresult = 'notpermitted'; |
} else { |
} else { |
my ($disposition,$message,$reqstatus); |
my ($disposition,$message,$reqstatus,$coursedesc); |
my %reqhash = ( |
my %reqhash = ( |
reqtime => $now, |
reqtime => $now, |
crstype => $crstype, |
crstype => $crstype, |
Line 3614 sub process_request {
|
Line 3616 sub process_request {
|
); |
); |
my $requestkey = $dom.'_'.$cnum; |
my $requestkey = $dom.'_'.$cnum; |
my $validationerror; |
my $validationerror; |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
if (ref($details) eq 'HASH') { |
|
$coursedesc = $details->{'cdescr'}; |
|
} |
if ($val eq 'autolimit=') { |
if ($val eq 'autolimit=') { |
$disposition = 'process'; |
$disposition = 'process'; |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
} elsif ($val =~ /^autolimit=(\d+)$/) { |
Line 3621 sub process_request {
|
Line 3628 sub process_request {
|
$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,$validationchk,$validation); |
my ($inststatuslist,$validationchk,$validation,%custominfo); |
if (@inststatuses > 0) { |
if (@inststatuses > 0) { |
$inststatuslist = join(',',@inststatuses); |
$inststatuslist = join(',',@inststatuses); |
} |
} |
Line 3631 sub process_request {
|
Line 3638 sub process_request {
|
$instseclist = join(',',@{$instsections}); |
$instseclist = join(',',@{$instsections}); |
} |
} |
} |
} |
|
my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'}, |
|
$env{'user.domain'},$fullname,$coursedesc); |
|
if (ref($preprocess) eq 'HASH') { |
|
if (ref($preprocess->{'formitems'}) eq 'HASH') { |
|
foreach my $key (keys(%{$preprocess->{'formitems'}})) { |
|
if ($preprocess->{'formitems'}->{$key} eq 'multiple') { |
|
if (exists($env{'form.'.$key})) { |
|
@{$custominfo{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key}); |
|
} |
|
} else { |
|
if (exists($env{'form.'.$key})) { |
|
$custominfo{$key} = $env{'form.'.$key}; |
|
} |
|
} |
|
} |
|
} |
|
} |
$validationchk = |
$validationchk = |
&Apache::lonnet::auto_courserequest_validation($dom, |
&Apache::lonnet::auto_courserequest_validation($dom, |
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
$env{'user.name'}.':'.$env{'user.domain'},$crstype, |
$inststatuslist,$instcode,$instseclist); |
$inststatuslist,$instcode,$instseclist,\%custominfo); |
if ($validationchk =~ /:/) { |
if ($validationchk =~ /:/) { |
($validation,$message) = split(':',$validationchk); |
($validation,$message) = split(':',$validationchk); |
} else { |
} else { |
Line 3651 sub process_request {
|
Line 3675 sub process_request {
|
} |
} |
$reqhash{'disposition'} = $disposition; |
$reqhash{'disposition'} = $disposition; |
$reqstatus = $disposition; |
$reqstatus = $disposition; |
my ($modified,$queued,$coursedesc,%customitems); |
my ($modified,$queued,$coursedesc,$token,%customitems); |
unless ($disposition eq 'rejected') { |
unless ($disposition eq 'rejected') { |
if (ref($details) eq 'HASH') { |
|
$coursedesc = $details->{'cdescr'}; |
|
} |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'}, |
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'}, |
$env{'user.domain'},$fullname,$coursedesc); |
$env{'user.domain'},$fullname,$coursedesc); |
if (ref($inprocess) eq 'HASH') { |
if (ref($inprocess) eq 'HASH') { |
Line 3742 sub process_request {
|
Line 3761 sub process_request {
|
crstype => $crstype, |
crstype => $crstype, |
ownername => $env{'user.name'}, |
ownername => $env{'user.name'}, |
ownerdom => $env{'user.domain'}, |
ownerdom => $env{'user.domain'}, |
description => $env{'form.cdescr'}, |
description => $env{'form.cdescr'}, |
|
lonhost => $lonhost, |
}, |
}, |
}; |
}; |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
Line 3760 sub process_request {
|
Line 3780 sub process_request {
|
if (($queuehash{$cnum.'_approval'} ne '') || |
if (($queuehash{$cnum.'_approval'} ne '') || |
($queuehash{$cnum.'_pending'} ne '')) { |
($queuehash{$cnum.'_pending'} ne '')) { |
$queued = 1; |
$queued = 1; |
|
if (ref($queuehash{$cnum.'_pending'}) eq 'HASH') { |
|
$token = $queuehash{$cnum.'_pending'}{'token'}; |
|
} |
} |
} |
} |
} |
unless ($queued) { |
unless ($queued) { |
|
if (($disposition eq 'pending') && ($crstype ne 'official')) { |
|
my %reqinfo = ( |
|
$cnum.':'.$dom => $now.':'.$env{'user.name'}.':'.$env{'user.domain'}, |
|
); |
|
$token = &Apache::lonnet::tmpput(\%reqinfo,$lonhost); |
|
$request->{$requestid}->{'token'} = $token; |
|
} |
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request, |
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request, |
$dom); |
$dom); |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
Line 3771 sub process_request {
|
Line 3801 sub process_request {
|
} else { |
} else { |
$output .= &mt('Your course request has been recorded.') |
$output .= &mt('Your course request has been recorded.') |
} |
} |
$output .= '<br />'. |
unless ($disposition eq 'pending') { |
¬ification_information($disposition,$req_notifylist, |
$output .= '<br />'. |
$dom,$cnum,$now); |
¬ification_information($disposition,$req_notifylist, |
|
$dom,$cnum,$now); |
|
} |
} else { |
} else { |
$reqstatus = 'domainerror'; |
$reqstatus = 'domainerror'; |
$reqhash{'disposition'} = $disposition; |
$reqhash{'disposition'} = $disposition; |
Line 3785 sub process_request {
|
Line 3817 sub process_request {
|
($storeresult,my $updateresult) = |
($storeresult,my $updateresult) = |
&Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom, |
&Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom, |
$cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'}); |
$cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'}); |
if ($modified && $queued && $storeresult eq 'ok') { |
if ($storeresult eq 'ok') { |
if ($crstype eq 'community') { |
my $postprocess; |
$output .= '<p>'.&mt('Your community request has been updated').'</p>'; |
if (($disposition eq 'approval') || ($disposition eq 'pending')) { |
} else { |
my $updateaction = $disposition; |
$output .= '<p>'.&mt('Your course request has been updated').'</p>'; |
if ($disposition eq 'approval') { |
} |
$updateaction = 'queued'; |
$output .= ¬ification_information($disposition,$req_notifylist,$dom,$cnum,$now); |
} |
if ($disposition eq 'approval') { |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
$env{'user.domain'}); |
$env{'user.domain'}); |
my $postprocess = |
$postprocess = |
&Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'queued',$env{'user.name'}, |
&Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$updateaction,$env{'user.name'}, |
$env{'user.domain'},$fullname,$env{'form.cdescr'}); |
$env{'user.domain'},$fullname,$env{'form.cdescr'}); |
|
} |
|
if ($modified && $queued) { |
|
if ($crstype eq 'community') { |
|
$output .= '<p>'.&mt('Your community request has been updated').'</p>'; |
|
} else { |
|
$output .= '<p>'.&mt('Your course request has been updated').'</p>'; |
|
} |
|
if ($disposition eq 'approval') { |
|
$output .= ¬ification_information($disposition,$req_notifylist,$dom,$cnum,$now); |
|
} |
|
} |
|
if ($disposition eq 'approval') { |
if ((ref($postprocess) eq 'HASH') && |
if ((ref($postprocess) eq 'HASH') && |
((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) { |
((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) { |
¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
} |
} |
|
} elsif ($disposition eq 'pending') { |
|
my $pendingform; |
|
if ($crstype ne 'official') { |
|
$pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token, |
|
$lonhost,$env{'form.cdescr'}); |
|
} |
|
if ($pendingform) { |
|
$output .= $pendingform; |
|
} else { |
|
$output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess); |
|
} |
} |
} |
} |
} |
if ($validationerror ne '') { |
if ($validationerror ne '') { |
Line 4002 sub notification_information {
|
Line 4056 sub notification_information {
|
} |
} |
} |
} |
} elsif ($disposition eq 'pending') { |
} elsif ($disposition eq 'pending') { |
$output .= '<div class="LC_info">'. |
my $pending_default = '<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>'; |
|
if (ref($postprocess) eq 'HASH') { |
|
if ($postprocess->{'pendingweb'}) { |
|
$output .= $postprocess->{'pendingweb'}; |
|
} else { |
|
$output .= $pending_default; |
|
} |
|
} else { |
|
$output .= $pending_default; |
|
} |
} elsif ($disposition eq 'created') { |
} elsif ($disposition eq 'created') { |
if (($code) || ((ref($postprocess) eq 'HASH') && |
if (($code) || ((ref($postprocess) eq 'HASH') && |
((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) { |
((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) { |
Line 4058 sub notification_information {
|
Line 4121 sub notification_information {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub pending_validation_form { |
|
my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_; |
|
my $output; |
|
my %postvalues = ( |
|
'owner' => $env{'user.name'}.':'.$env{'user.domain'}, |
|
'course' => $cdom.'_'.$cnum, |
|
'coursetype' => $crstype, |
|
); |
|
my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom); |
|
|
|
if (ref($domconfig{'requestcourses'}) eq 'HASH') { |
|
my ($url,$buttontext,$code,@fields); |
|
if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { |
|
$postvalues{'description'} = $cdesc; |
|
$url = $domconfig{'requestcourses'}{'validation'}{'url'}; |
|
if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') { |
|
@fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}}; |
|
} |
|
$buttontext = $domconfig{'requestcourses'}{'validation'}{'button'}; |
|
$output .= $domconfig{'requestcourses'}{'validation'}{'markup'}; |
|
if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) { |
|
$output .= '<form name="crsreqvalidation" action="'.$url.'" method="post">'."\n"; |
|
foreach my $field (@fields) { |
|
if ($postvalues{$field}) { |
|
$output .= '<input type="hidden" name="'.$field.'" value="'.$postvalues{$field}.'" />'."\n"; |
|
} |
|
} |
|
if ($buttontext eq '') { |
|
if ($crstype eq 'community') { |
|
$buttontext = &mt('Create community'); |
|
} else { |
|
$buttontext = &mt('Create course'); |
|
} |
|
} |
|
my $protocol = $Apache::lonnet::protocol{$lonhost}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
|
my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl'; |
|
$output .= '<input type="hidden" name="crscreator" value="'.$crscreator.'" />'."\n". |
|
'<input type="hidden" name="token" value="'.$token.'" />'."\n". |
|
'<input type="submit" name="validate" value="'.$buttontext.'" />'."\n". |
|
'</form>'."\n"; |
|
} |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub check_autolimit { |
sub check_autolimit { |
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
Line 4585 sub process_textbook_request {
|
Line 4695 sub process_textbook_request {
|
} |
} |
} |
} |
} |
} |
my $crstype = 'textbook'; |
|
my $now = time; |
my $now = time; |
my $reqtype = $env{'form.cloning'}; |
my $reqtype = $env{'form.cloning'}; |
my (@inststatuses,$storeresult,$creationresult); |
my (@inststatuses,$storeresult,$creationresult); |
Line 4650 sub process_textbook_request {
|
Line 4759 sub process_textbook_request {
|
$details->{datemode} = $env{'form.datemode'}; |
$details->{datemode} = $env{'form.datemode'}; |
$details->{dateshift} = $env{'form.dateshift'}; |
$details->{dateshift} = $env{'form.dateshift'}; |
} |
} |
my ($result,$output) = &process_request($dom,$cnum,$crstype,$now,$details,'',$req_notifylist,[],$domconfig); |
my $lonhost = $r->dir_config('lonHostID'); |
|
my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,'', |
|
$req_notifylist,[],$domconfig); |
$r->print($output); |
$r->print($output); |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
if (&Apache::loncoursequeueadmin::author_prompt()) { |
&print_author_prompt($r,$action,$cnum,$dom,$crstype,$result); |
&print_author_prompt($r,$action,$cnum,$dom,$crstype,$result); |