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

raeburn raeburn at source.lon-capa.org
Wed Aug 19 20:28:53 EDT 2015


raeburn		Thu Aug 20 00:28:53 2015 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Bug 6794
    - Pasting of simple page and discussion board items between courses.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.595 loncom/interface/londocs.pm:1.596
--- loncom/interface/londocs.pm:1.595	Thu Jun 18 20:19:06 2015
+++ loncom/interface/londocs.pm	Thu Aug 20 00:28:52 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.595 2015/06/18 20:19:06 musolffc Exp $
+# $Id: londocs.pm,v 1.596 2015/08/20 00:28:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1164,9 +1164,7 @@
                     if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
                         $othercourse = 1;
                         if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
-                            if ($canpaste) {
-                                $othercrs = '<br />'.&mt('(from another course)');
-                            }
+                            $othercrs = '<br />'.&mt('(from another course)');
                         } else {
                             $canpaste = 0;
                             $nopaste = &mt('Paste from another course unavailable.'); 
@@ -1180,10 +1178,20 @@
                         }
                         $is_uploaded_map = 1;
                     }
+                } elsif ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$}) {
+                    if ($cid ne $env{'request.course.id'}) {
+                        my ($srcdom,$srcnum) = split(/_/,$cid);
+                        if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
+                            $othercrs = '<br />'.&mt('(from another course)');
+                        } else {
+                            $canpaste = 0;
+                            $nopaste = &mt('Paste from another course unavailable.');
+                        }       
+                    }
                 }
-            }
-            if ($canpaste) {
-               push(@pasteable,$suffix);
+                if ($canpaste) {
+                    push(@pasteable,$suffix);
+                }  
             }
             my $buffer;
             if ($is_external) {
@@ -1473,6 +1481,7 @@
 
     foreach my $suffix (@topaste) {
         my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
+        my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
 # Supplemental content may only include certain types of content
 # Early out if pasted content is not supported in Supplemental area
         if ($folder =~ /^supplemental/) {
@@ -1494,8 +1503,19 @@
             }
             $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;
+        } elsif ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) {
+            my ($srcd,$srcn) = split(/_/,$cid);
+# When paste buffer was populated using an active role in a different course
+# check for mdc privilege in the course from which the resource was pasted
+            if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
+                unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
+                    $notincrs{$suffix} = 1;
+                    next;
+                }
+            }
+            $srcdom{$suffix} = $srcd;
+            $srcnum{$suffix} = $srcn;
         }
-
         push(@dopaste,$suffix);
         if ($url=~/\.(page|sequence)$/) {
             $is_map{$suffix} = 1; 
@@ -1593,6 +1613,7 @@
         }
         my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
         my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
+        my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix}); 
         my $oldurl = $url;
         if ($is_map{$suffix}) {
 # If pasting a map, check if map contains other maps
@@ -1653,13 +1674,21 @@
         }
         if ($url=~ m{/(bulletinboard|smppg)$}) {
             my $prefix = $1;
+            my $fromothercrs; 
             #need to copy the db contents to a new one, unless this is a move.
             my %info = (
                          src  => $url,
                          cdom => $coursedom,
                          cnum => $coursenum,
-            );
-            unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
+                       );
+            if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
+                unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
+                    $fromothercrs = 1;
+                    $info{'cdom'} = $srcdom{$suffix};
+                    $info{'cnum'} = $srcnum{$suffix};
+                }
+            }
+            unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
                 my (%lockerr,$msg); 
                 my ($newurl,$result,$errtext) =
                     &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
@@ -1920,8 +1949,8 @@
 sub dbcopy {
     my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
     my ($url,$result,$errtext);
-    $url = $dbref->{'src'};
     if (ref($dbref) eq 'HASH') {
+        $url = $dbref->{'src'};
         if ($url =~ m{/(smppg|bulletinboard)$}) {
             my $prefix = $1;
             if (($dbref->{'cdom'} =~ /^$match_domain$/) && 
@@ -1959,7 +1988,7 @@
                         my $photo = $contents{'uploaded.photourl'};
                         my ($subdir,$fname) =
                             ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
-                        my $newphoto; 
+                        my $newphoto;
                         if ($fname ne '') {
                             my $content = &Apache::lonnet::getfile($photo);
                             unless ($content eq '-1') {




More information about the LON-CAPA-cvs mailing list