--- loncom/interface/loncoursequeueadmin.pm 2009/08/17 04:39:15 1.4 +++ loncom/interface/loncoursequeueadmin.pm 2009/10/05 01:54:44 1.10 @@ -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.10 2009/10/05 01:54:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,13 +76,13 @@ sub send_selfserve_notification { if ($context eq 'coursemanagers') { $rawsubj = 'Self-enrollment requests processed'; push(@rawmsg,{ - mt => 'Enrollment requests in the following course: [_1]have been processed.', + mt => 'Enrollment requests in the following course: [_1] have been processed.', args => ["\n $contextdesc"], }); } elsif ($context eq 'domainmanagers') { $rawsubj = 'Course requests reviewed'; push(@rawmsg,{ - mt => 'Course creation requests in the following domain: [_1]have been reviewed.', + mt => 'Course creation requests in the following domain: [_1] have been reviewed.', args => ["\n $contextdesc"], }); if (ref($textstr) eq 'ARRAY') { @@ -188,7 +188,7 @@ sub send_selfserve_notification { @{$item->{args}})."\n"; } } - if ($context eq 'managers') { + if ($context eq 'coursemanagers') { if ($approvedlist) { $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist; } @@ -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:').'

'; + } if (@processing_errors) { if ($context eq 'course') { $output .= '

'.&mt('The following enrollment requests could not be processed because an error occurred:').'