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

raeburn raeburn@source.lon-capa.org
Sun, 21 Feb 2010 02:38:32 -0000


raeburn		Sun Feb 21 02:38:32 2010 EDT

  Modified files:              
    /loncom/interface	loncommon.pm loncoursequeueadmin.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Bug 6176. Owners of courses can clone them even if they no longer have an
    active Course Coordinator role.
  - New subroutine in lonnet.pm - &is_course_owner() returns 1 if user is
    the owner of the specified course.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.941 loncom/interface/loncommon.pm:1.942
--- loncom/interface/loncommon.pm:1.941	Mon Feb 15 16:41:31 2010
+++ loncom/interface/loncommon.pm	Sun Feb 21 02:38:23 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.941 2010/02/15 16:41:31 bisitz Exp $
+# $Id: loncommon.pm,v 1.942 2010/02/21 02:38:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -10033,8 +10033,10 @@
                                          'userroles',['active'],[$ccrole],
 					 [$args->{'clonedomain'}]);
 	        if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
-		    $can_clone = 1;
-	        } else {
+                    $can_clone = 1;
+                } elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'},$args->{'ccuname'},$args->{'ccdomain'})) {
+                    $can_clone = 1;
+                } else {
                     if ($args->{'type'} eq 'Community') {
                         $clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
                     } else {
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.17 loncom/interface/loncoursequeueadmin.pm:1.18
--- loncom/interface/loncoursequeueadmin.pm:1.17	Fri Jan 29 13:18:38 2010
+++ loncom/interface/loncoursequeueadmin.pm	Sun Feb 21 02:38:23 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Utilities to administer domain course requests and course self-enroll requests 
 #
-# $Id: loncoursequeueadmin.pm,v 1.17 2010/01/29 13:18:38 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.18 2010/02/21 02:38:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1039,6 +1039,11 @@
                 $canclone = 1;
             }
         }
+        unless ($canclone) {
+            if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) {
+                $can_clone = 1;
+            }
+        }
     }
     return $canclone;
 }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1049 loncom/lonnet/perl/lonnet.pm:1.1050
--- loncom/lonnet/perl/lonnet.pm:1.1049	Sat Jan 16 13:46:05 2010
+++ loncom/lonnet/perl/lonnet.pm	Sun Feb 21 02:38:31 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1049 2010/01/16 13:46:05 raeburn Exp $
+# $Id: lonnet.pm,v 1.1050 2010/02/21 02:38:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4813,6 +4813,27 @@
     }
 }
 
+sub is_course_owner {
+    my ($cdom,$cnum,$udom,$uname) = @_;
+    if (($udom eq '') || ($uname eq '')) {
+        $udom = $env{'user.domain'};
+        $uname = $env{'user.name'};
+    }
+    unless (($udom eq '') || ($uname eq '')) {
+        if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'})) {
+            if ($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'} eq $uname.':'.$udom) {
+                return 1;
+            } else {
+                my %courseinfo = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);
+                if ($courseinfo{'internal.courseowner'} eq $uname.':'.$udom) {
+                    return 1;
+                }
+            }
+        }
+    }
+    return;
+}
+
 sub is_advanced_user {
     my ($udom,$uname) = @_;
     my %roleshash = &get_my_roles($uname,$udom,'userroles',undef,undef,undef,1);