[LON-CAPA-cvs] cvs: loncom / lond /interface lonpickcourse.pm /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Fri, 25 Jun 2010 04:37:55 -0000


This is a MIME encoded message

--raeburn1277440675
Content-Type: text/plain

raeburn		Fri Jun 25 04:37:55 2010 EDT

  Modified files:              
    /loncom	lond 
    /loncom/interface	lonpickcourse.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - DC can override course-specific cloning rights: 
    (a) when DC creates a single course in a domain:
      (All courses in that domain are cloneable for all course owners).
    (b) when DC creates a single community in a domain:
      (All communities in that domain are cloneable for all community owners).
  
  
--raeburn1277440675
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100625043755.txt"

Index: loncom/lond
diff -u loncom/lond:1.444 loncom/lond:1.445
--- loncom/lond:1.444	Fri Jun 18 19:19:33 2010
+++ loncom/lond	Fri Jun 25 04:37:44 2010
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.444 2010/06/18 19:19:33 raeburn Exp $
+# $Id: lond,v 1.445 2010/06/25 04:37:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -58,7 +58,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.444 $'; #' stupid emacs
+my $VERSION='$Revision: 1.445 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -3728,6 +3728,9 @@
 #                 createdafter - include courses for which creation date followed this date.
 #                 creationcontext - include courses created in specified context 
 #
+#                 domcloner - flag to indicate if user can create CCs in course's domain.
+#                             If so, ability to clone course is automatic. 
+#
 #     $client  - The socket open on the client.
 # Returns:
 #    1     - Continue processing.
@@ -3740,7 +3743,7 @@
     my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter,
         $typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter,$showhidden,
         $caller,$cloner,$cc_clone_list,$cloneonly,$createdbefore,$createdafter,
-        $creationcontext) =split(/:/,$tail);
+        $creationcontext,$domcloner) =split(/:/,$tail);
     my $now = time;
     my ($cloneruname,$clonerudom,%cc_clone);
     if (defined($description)) {
@@ -3813,7 +3816,6 @@
     } else {
         $creationcontext = '.';
     }
-    
     my $unpack = 1;
     if ($description eq '.' && $instcodefilter eq '.' && $coursefilter eq '.' && 
         $typefilter eq '.') {
@@ -3844,7 +3846,9 @@
                     next if ($since > 1);
                 }
                 $is_hash =  1;
-                if (defined($clonerudom)) {
+                if ($domcloner) {
+                    $canclone = 1;
+                } elsif (defined($clonerudom)) {
                     if ($items->{'cloners'}) {
                         my @cloneable = split(',',$items->{'cloners'});
                         if (@cloneable) {
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.97 loncom/interface/lonpickcourse.pm:1.98
--- loncom/interface/lonpickcourse.pm:1.97	Sat Jun 19 01:28:35 2010
+++ loncom/interface/lonpickcourse.pm	Fri Jun 25 04:37:49 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.97 2010/06/19 01:28:35 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.98 2010/06/25 04:37:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -183,8 +183,15 @@
 # ---------------------------------------------------------------- Get the data
     if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || 
          $onlyown) {
+        my $domcloner;
+        if ($env{'form.form'} eq 'ccrs') {
+            if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) &&
+                (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
+                $domcloner = 1;
+            }
+        }
         my %courses = &search_courses($r,$type,$onlyown,$filter,$numtitles,
-                                      $cloneruname,$clonerudom);
+                                      $cloneruname,$clonerudom,$domcloner);
         if ($nohost) {
             $r->print ('<span class="LC_warning">'.
                        &mt('User does not exist - username: [_1], domain: [_2].',
@@ -405,8 +412,16 @@
                 $instcode = $courses{$course}{'inst_code'};
                 $ttype = $courses{$course}{'type'};
                 if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
-                    if ($cc_cloneable{$courses{$course}{'cnum'}.':'.$courses{$course}{'domain'}}) {
-                        $canclone = 1;
+                    if ($env{'form.form'} eq 'ccrs') {
+                        if (($env{'request.role.domain'} eq $cdom) &&
+                            (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
+                            $canclone = 1;
+                        }
+                    }
+                    unless ($canclone) { 
+                        if ($cc_cloneable{$cnum.':'.$cdom}) {
+                            $canclone = 1;
+                        }
                     }
                     unless ($canclone) {
                         my $cloners = $courses{$course}{'cloners'};
@@ -865,7 +880,7 @@
 }
 
 sub search_courses {
-    my ($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom) = @_;
+    my ($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner) = @_;
     my (%courses,%showcourses,$cloner,$ccrole);
     if ($type eq 'Community') {
         $ccrole = 'co';
@@ -924,7 +939,8 @@
                                           undef,undef,$type,$regexpok,undef,undef,
                                           undef,undef,$cloner,$env{'form.cc_clone'},
                                           $filter->{'cloneableonly'},
-                                          $createdbefore,$createdafter);
+                                          $createdbefore,$createdafter,undef,
+                                          $domcloner);
         if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) {
             my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'},
                                                          $filter->{'persondomfilter'},
@@ -1204,10 +1220,12 @@
 
 =item *
 X<search_courses()>
-B<search_courses($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom)>:
+B<search_courses($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,
+                 $domcloner)>:
 
 
-Input: 7 -  request object, course type, search scope: only courses in which user has active role (1), or any course (0); anonymous hash of criteria and their values; for institutional codes - number of categories; optional username of new course owner, optional domain of new course owner). Last two needed when search is for courses to clone from course request form, or course creation form (DC).   
+Input: 8 -  request object, course type, search scope: only courses in which user has active role (1), or any course (0); anonymous hash of criteria and their values; for institutional codes - number of categories; optional username of new course owner, optional domain of new course owner). Last two needed when search is for courses to clone from course request form, or course creation form (DC). Optional "domcloner" flag (has value=1 if user has ccc priv in  
+domain being filtered by (used when DC is using course creation form).
 
 Output: 1 - %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type.
 
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1070 loncom/lonnet/perl/lonnet.pm:1.1071
--- loncom/lonnet/perl/lonnet.pm:1.1070	Fri Jun  4 00:14:15 2010
+++ loncom/lonnet/perl/lonnet.pm	Fri Jun 25 04:37:54 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1070 2010/06/04 00:14:15 www Exp $
+# $Id: lonnet.pm,v 1.1071 2010/06/25 04:37:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3035,7 +3035,7 @@
     my ($domfilter,$descfilter,$sincefilter,$instcodefilter,$ownerfilter,
         $coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok,
         $selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone,
-        $cloneonly,$createdbefore,$createdafter,$creationcontext)=@_;
+        $cloneonly,$createdbefore,$createdafter,$creationcontext,$domcloner)=@_;
     my $as_hash = 1;
     my %returnhash;
     if (!$domfilter) { $domfilter=''; }
@@ -3057,7 +3057,8 @@
                          $showhidden.':'.$caller.':'.&escape($cloner).':'.
                          &escape($cc_clone).':'.$cloneonly.':'.
                          &escape($createdbefore).':'.&escape($createdafter).':'.
-                         &escape($creationcontext),$tryserver);
+                         &escape($creationcontext).':'.$domcloner,
+                         $tryserver);
                 my @pairs=split(/\&/,$rep);
                 foreach my $item (@pairs) {
                     my ($key,$value)=split(/\=/,$item,2);

--raeburn1277440675--