[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm

raeburn raeburn@source.lon-capa.org
Thu, 20 Aug 2009 20:43:08 -0000


raeburn		Thu Aug 20 20:43:08 2009 EDT

  Modified files:              
    /loncom/interface	loncoursequeueadmin.pm 
  Log:
  - When checking to see whether approved course requests should be processed,
    need to accommodate cases where requestor's domain is different from course's domain - additional check beyond call to &usertools_access() needed.
  
  
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.4 loncom/interface/loncoursequeueadmin.pm:1.5
--- loncom/interface/loncoursequeueadmin.pm:1.4	Mon Aug 17 04:39:15 2009
+++ loncom/interface/loncoursequeueadmin.pm	Thu Aug 20 20:43:08 2009
@@ -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.5 2009/08/20 20:43:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -345,7 +345,8 @@
         $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;
@@ -482,8 +483,22 @@
                     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 @@
                             push(@processing_errors,$cnum);
                         }
                     } else {
-                        push(@processing_errors,$cnum);
+                        push(@nopermissions,$cnum);
                     }
                 } else {
                     push(@existing,$cnum);
@@ -749,6 +764,19 @@
             $output .= '</ul></p>';
         }
     }
+    if (@nopermissions) {
+        $output .= '<p>'.&mt('The following course creation requests could not be processed because the course owner does hot have rights to create this type of course:').'<ul>';
+        foreach my $cnum (@nopermissions) {
+            my $showcourse;
+            if (ref($requesthash{$cnum.'_approval'})) {
+                $showcourse = $requesthash{$cnum.'_approval'}{'description'};
+            } else {
+                $showcourse = $cnum;
+            }
+            $output .= '<li>'.$showcourse.'</li>';
+        }
+        $output .= '</ul></p>';
+    }
     if (@processing_errors) {
         if ($context eq 'course') {
             $output .= '<p>'.&mt('The following enrollment requests could not be processed because an error occurred:').'<ul>';