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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 27 Feb 2004 19:11:08 -0000


This is a MIME encoded message

--albertel1077909068
Content-Type: text/plain

albertel		Fri Feb 27 14:11:08 2004 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - BUG#2514, londocs.pm was throwing awway folder names after reorders, renames, removals, or imports
  - additionally it was dereferencing things so that the title 'New F " older #:&' was breaking after 2 actions occured,
  
  
--albertel1077909068
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040227141108.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.108 loncom/interface/londocs.pm:1.109
--- loncom/interface/londocs.pm:1.108	Fri Feb 27 13:16:54 2004
+++ loncom/interface/londocs.pm	Fri Feb 27 14:11:08 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.108 2004/02/27 18:16:54 albertel Exp $
+# $Id: londocs.pm,v 1.109 2004/02/27 19:11:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -411,38 +411,42 @@
     my ($index,$title,$url,$folder,$allowed,$residx)=@_;
     $title=~s/\&colon\;/\:/g;
     $title=&HTML::Entities::encode(&HTML::Entities::decode(
-     &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
+     &Apache::lonnet::unescape($title)),'"<>&\'');
     my $renametitle=$title;
     my $foldertitle=$title;
-    if ($title=~
- /^(\d+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(.*)$/
-	) { 
-            $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
-            $renametitle=$4;
-            $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
-                &Apache::loncommon::plainname($2,$3).': <br />'.
-		$foldertitle;
-	}
+    if ($title=~ /^(\d+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(.*)$/	) { 
+	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+	$renametitle=$4;
+	$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
+	    &Apache::loncommon::plainname($2,$3).': <br />'.
+	    $foldertitle;
+    }
     $renametitle=~s/\&quot\;/\\\"/g;
     my $line='<tr>';
 # Edit commands
-     if ($allowed) {
-	 my %lt=('up' => 'Move Up',
-		 'dw' => 'Move Down',
-		 'rm' => 'Remove',
-		 'rn' => 'Rename');
-      $line.=(<<END);
+    if ($allowed) {
+	my %lt=('up' => 'Move Up',
+		'dw' => 'Move Down',
+		'rm' => 'Remove',
+		'rn' => 'Rename');
+	my ($foldername,$htmlfoldername);
+	if ($ENV{'form.foldername'}) {
+	    $foldername='&foldername='.
+		&Apache::lonnet::escape($ENV{'form.foldername'});
+	    $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'});
+	}
+	$line.=(<<END);
 <td><table border='0' cellspacing='2' cellpadding='0'>
 <tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
+<a href='/adm/coursedocs?folder=$folder&cmd=up_$index$foldername'>
 <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
 <tr><td bgcolor="#DDDDDD">
-<a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
+<a href='/adm/coursedocs?folder=$folder&cmd=down_$index$foldername'>
 <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
 </table></td><td bgcolor="#DDDDDD">
-<a href='javascript:removeres("$folder","$index","$renametitle");'>
+<a href='javascript:removeres("$folder","$index","$renametitle","$htmlfoldername");'>
 <font size="-2" color="#990000">$lt{'rm'}</font></a>
-<a href='javascript:changename("$folder","$index","$renametitle");'>
+<a href='javascript:changename("$folder","$index","$renametitle","$htmlfoldername");'>
 <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
 END
     }
@@ -1018,20 +1022,22 @@
     '";this.document.forms.'+form+'.submit();');
 }
 
-function changename(folder,index,oldtitle) {
+function changename(folder,index,oldtitle,foldername) {
     var title=prompt('New Title',oldtitle);
     if (title) {
 	this.document.forms.renameform.title.value=title;
 	this.document.forms.renameform.cmd.value='rename_'+index;
 	this.document.forms.renameform.folder.value=folder;
+	this.document.forms.renameform.foldername.value=foldername;
         this.document.forms.renameform.submit();
     }
 }
 
-function removeres(folder,index,oldtitle) {
+function removeres(folder,index,oldtitle,foldername) {
     if (confirm('Remove "'+oldtitle+'"?')) {
 	this.document.forms.renameform.cmd.value='del_'+index;
 	this.document.forms.renameform.folder.value=folder;
+	this.document.forms.renameform.foldername.value=foldername;
         this.document.forms.renameform.submit();
     }
 }
@@ -1083,10 +1089,12 @@
 <input type="hidden" name="title" />
 <input type="hidden" name="cmd" />
 <input type="hidden" name="folder" />
+<input type="hidden" name="foldername" />
 </form>
 <form name="simpleedit" method="post" action="/adm/coursedocs">
 <input type=hidden name="importdetail" value="">
 <input type="hidden" name="folder" />
+<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 </form>
 <form action="/adm/coursedocs" method="post" name="courseverify">
 <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
@@ -1102,6 +1110,7 @@
 		     &mt('Editing the Table of Contents for your Course')));
     }
 # --------------------------------------------------------- Standard documents
+    my $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'});
     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
     if (($standard) && ($allowed) && (!$forcesupplement)) {
        $r->print('<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Main Course Documents').
@@ -1135,7 +1144,7 @@
 $lt{'title'}:<br />
 <input type="text" size="50" name="comment">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type="hidden" name="cmd" value="upload_default">
 <input type="submit" value="$lt{'upld'}">
 <nobr>
@@ -1146,7 +1155,7 @@
 <td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=button onClick=
 "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
 <nobr>
@@ -1166,7 +1175,7 @@
 </td><td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="newfolder">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newfolder" type="button"
@@ -1176,7 +1185,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newext">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newext" type="button" onClick="javascript:makenewext('newext');"
@@ -1185,7 +1194,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newsyl">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 <nobr>
@@ -1195,7 +1204,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newnav">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" 
 value="Navigate Content=/adm/navmaps">
 <nobr>
@@ -1205,7 +1214,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newsmppg">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newsmppg" type="button" value="$lt{'sipa'}"
@@ -1214,7 +1223,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newsmpproblem">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
@@ -1223,7 +1232,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newexamupload">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newexamupload" type="button" value="$lt{'scuf'}"
@@ -1233,7 +1242,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newbul">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newbulletin" type="button" value="$lt{'bull'}"
@@ -1243,7 +1252,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newaboutme">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">
 <nobr>
@@ -1253,7 +1262,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
@@ -1290,7 +1299,7 @@
 <textarea cols=50 rows=4 name='comment'>
 </textarea>
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type="hidden" name="cmd" value="upload_supplemental">
 <nobr>
 <input type="submit" value="$lt{'upld'}">
@@ -1301,7 +1310,7 @@
 <td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="supnewfolder">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newfolder" type="button"
@@ -1311,7 +1320,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="supnewext">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" value="">
 <nobr>
 <input name="newext" type="button" 
@@ -1321,7 +1330,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="supnewsyl">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 <nobr>
@@ -1331,7 +1340,7 @@
 </form>
 <form action="/adm/coursedocs" method="post" name="subnewaboutme">
 <input type="hidden" name="folder" value="$folder">
-<input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
+<input type="hidden" name="foldername" value="$htmlfoldername">
 <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">
 <nobr>

--albertel1077909068--