[LON-CAPA-cvs] cvs: loncom /publisher lonupload.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 14 May 2004 14:53:31 -0000


www		Fri May 14 10:53:31 2004 EDT

  Modified files:              
    /loncom/publisher	lonupload.pm 
  Log:
  Bug #2927: "Back to Directory" also works on top-level
  
  
Index: loncom/publisher/lonupload.pm
diff -u loncom/publisher/lonupload.pm:1.26 loncom/publisher/lonupload.pm:1.27
--- loncom/publisher/lonupload.pm:1.26	Wed Mar 31 00:24:00 2004
+++ loncom/publisher/lonupload.pm	Fri May 14 10:53:31 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Handler to upload files into construction space
 #
-# $Id: lonupload.pm,v 1.26 2004/03/31 05:24:00 albertel Exp $
+# $Id: lonupload.pm,v 1.27 2004/05/14 14:53:31 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -180,6 +180,8 @@
 			  '<input type="submit" name="override" value="'.&mt('Yes').'" /></form>');
 	    } else {
 		my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp';
+		my $dirpath=$path.'/';
+		$dirpath=~s/\/+/\//g;
 		# Check for bad extension and disallow upload
 		if ($fn=~/\.(\w+)$/ && 
 		    (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
@@ -188,7 +190,7 @@
 			      '<font color="red">'.
 			      &mt('The extension on this file is reserved internally by LON-CAPA.').
 			      '</font>');
-		    $r->print('<br /><font size=+2><a href="'.$path.'">'.
+		    $r->print('<br /><font size=+2><a href="'.$dirpath.'">'.
 			      &mt('Back to Directory').'</a></font>');
 		} elsif ($fn=~/\.(\w+)$/ && 
 			 !defined(&Apache::loncommon::fileembstyle($1))) {
@@ -197,14 +199,14 @@
 			      '<font color="red">'.
 			      &mt('The extension on this file is not recognized by LON-CAPA.').
 			      '</font>');
-		    $r->print('<br /><font size="+2"><a href="'.$path.'">'.
+		    $r->print('<br /><font size="+2"><a href="'.$dirpath.'">'.
 			      &mt('Back to Directory').'</a></font>');
 		} elsif (-d $target) {
 		    $r->print('File <tt>'.$fn.'</tt> could not be copied.<br />'.
 			      '<font color="red">'.
 			      &mt('The target is an existing directory.').
 			      '</font><br />');
-		    $r->print('<font size="+2"><a href="'.$path.'">'.
+		    $r->print('<font size="+2"><a href="'.$dirpath.'">'.
 			      &mt('Back to Directory').'</a></font>');
 		} elsif (copy($source,$target)) {
 		    chmod(0660, $target); # Set permissions to rw-rw---.
@@ -215,7 +217,7 @@
                         $r->print(&mt('File copied.'));
 		        $r->print('<br /><font size="+2"><a href="'.$url.'">'.
 			      &mt('View file').'</a></font>');
-		        $r->print('<br /><font size="+2"><a href="'.$path.'">'.
+		        $r->print('<br /><font size="+2"><a href="'.$dirpath.'">'.
 			      &mt('Back to Directory').'</a></font><br />');
                     }
 		} else {