--- loncom/interface/loncoursequeueadmin.pm 2009/08/17 04:39:15 1.4 +++ loncom/interface/loncoursequeueadmin.pm 2009/09/04 23:01:58 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # Utilities to administer domain course requests and course self-enroll requests # -# $Id: loncoursequeueadmin.pm,v 1.4 2009/08/17 04:39:15 raeburn Exp $ +# $Id: loncoursequeueadmin.pm,v 1.8 2009/09/04 23:01:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -220,7 +220,7 @@ sub display_queued_requests { } else { $formaction = '/adm/createcourse'; $namespace = 'courserequestqueue'; - %requesthash = &Apache::lonnet::dump_dom($namespace,$dom,undef,'_approval'); + %requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_approval'); $nextelement = ''; } my ($output,%queue_by_date,%crstypes); @@ -293,8 +293,8 @@ sub display_queued_requests { } else { my ($cnum,$ownername,$ownerdom,$type,$cdesc)=split(/:/,$request,5); - $detailslink=''.$cdesc.''; + $detailslink=''.$cdesc.''; $crstype = $type; if (defined($crstypes{$type})) { $crstype = $crstypes{$type}; @@ -345,7 +345,8 @@ sub update_request_queue { $domdesc,$now,$sender,$approvedmsg,$rejectedmsg,$beneficiary, @existing,@missingreq,@invalidusers,@limitexceeded,@completed, @processing_errors,@warn_approves,@warn_rejects,@approvals, - @rejections,@rejectionerrors,%courseroles,%communityroles,%domdefs); + @rejections,@rejectionerrors,@nopermissions,%courseroles, + %communityroles,%domdefs); @approvals = &Apache::loncommon::get_env_multiple('form.approvereq'); @rejections = &Apache::loncommon::get_env_multiple('form.rejectreq'); $now = time; @@ -379,7 +380,7 @@ sub update_request_queue { $domdesc = &Apache::lonnet::domain($cdom); $namespace = 'courserequestqueue'; $beneficiary = 'courserequestor'; - %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom,undef,'_approval'); + %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom,'_approval'); my $chome = &Apache::lonnet::domain($cdom,'primary'); $hostname = &Apache::lonnet::hostname($chome); $protocol = $Apache::lonnet::protocol{$chome}; @@ -482,8 +483,22 @@ sub update_request_queue { if ($crstype eq 'community') { $longroles = \%communityroles; } - if (&Apache::lonnet::usertools_access($ownername,$ownerdom,$crstype, - undef,'requestcourses')) { + my $cancreate; + if ($cdom eq $ownerdom) { + if (&Apache::lonnet::usertools_access($ownername,$ownerdom,$crstype, + undef,'requestcourses')) { + $cancreate = 1; + } + } else { + my %userenv = &Apache::lonnet::userenvironment($ownerdom,$ownername,'reqcrsotherdom.'.$crstype); + if ($userenv{'reqcrsotherdom.'.$crstype}) { + my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype}); + if (grep(/^\Q$cdom\E:/,@doms)) { + $cancreate = 1; + } + } + } + if ($cancreate) { my $requestkey = $cdom.'_'.$cnum; my %history = &Apache::lonnet::restore($requestkey,'courserequests', @@ -531,7 +546,7 @@ sub update_request_queue { push(@processing_errors,$cnum); } } else { - push(@processing_errors,$cnum); + push(@nopermissions,$cnum); } } else { push(@existing,$cnum); @@ -749,6 +764,19 @@ sub update_request_queue { $output .= '
'; } } + if (@nopermissions) { + $output .= ''.&mt('The following course creation requests could not be processed because the course owner does hot have rights to create this type of course:').'
'.&mt('The following enrollment requests could not be processed because an error occurred:').'