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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 05 Sep 2008 00:08:47 -0000


raeburn		Thu Sep  4 20:08:47 2008 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Using the paste buffer with an item from Supplemental Docs with a title containing an embedded timestamp and the identity of editor would result in escaped HTML tags in the title after pasting.
  - Add new item in %env - docs.markedcopy_supplemental - containing the original item title (includes embedded information).
  - Behavior on pasting depends on whether item is pasted into a folder in the Main Documents area or in the Supplemental Documents area.   
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.310 loncom/interface/londocs.pm:1.311
--- loncom/interface/londocs.pm:1.310	Thu Sep  4 13:50:47 2008
+++ loncom/interface/londocs.pm	Thu Sep  4 20:08:46 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.310 2008/09/04 17:50:47 raeburn Exp $
+# $Id: londocs.pm,v 1.311 2008/09/05 00:08:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1208,7 +1208,10 @@
 # Mark for copying
     my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
     if (&is_supplemental_title($title)) {
+        &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
 	($title) = &parse_supplemental_title($title);
+    } elsif ($env{'docs.markedcopy_supplemental'}) {
+        &Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
     }
     $url=~s{http(:|:)//https(:|:)//}{https$2//};
 
@@ -1257,7 +1260,7 @@
 }
 
 sub do_paste_from_buffer {
-    my ($coursenum,$coursedom) = @_;
+    my ($coursenum,$coursedom,$folder) = @_;
 
     return 0 if (!$env{'form.pastemarked'});
 
@@ -1299,6 +1302,20 @@
     $url       = &LONCAPA::map::qtunescape($url);
 # Now insert the URL at the bottom
     my $newidx = &LONCAPA::map::getresidx($url);
+    if ($env{'docs.markedcopy_supplemental'}) {
+        if ($folder =~ /^supplemental/) {
+            $title = $env{'docs.markedcopy_supplemental'};
+        } else {
+            (undef,undef,$title) = 
+                &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
+        }
+    } else {
+        if ($folder=~/^supplemental/) {
+           $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+                  $env{'user.domain'}.'___&&&___'.$title;
+        }
+    }
+
     $LONCAPA::map::resources[$newidx]= 	$title.':'.$url.':'.$ext.':normal:res';
     push(@LONCAPA::map::order, $newidx);
 # Store the result
@@ -1419,7 +1436,7 @@
 	}
 	    
 	if ($env{'form.pastemarked'}) {
-	    &do_paste_from_buffer($coursenum,$coursedom);
+	    &do_paste_from_buffer($coursenum,$coursedom,$folder);
 	    ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
 	    return $errtext if ($fatal);
 	}