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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 02 Mar 2004 16:48:27 -0000


albertel		Tue Mar  2 11:48:27 2004 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - BUG#2545, move and rename are not exactly the same
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.51 loncom/publisher/loncfile.pm:1.52
--- loncom/publisher/loncfile.pm:1.51	Tue Feb 17 17:06:10 2004
+++ loncom/publisher/loncfile.pm	Tue Mar  2 11:48:27 2004
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.51 2004/02/17 22:06:10 raeburn Exp $
+# $Id: loncfile.pm,v 1.52 2004/03/02 16:48:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -406,13 +406,15 @@
 =cut  
 
 sub Rename1 {
-    my ($request, $user, $domain, $fn, $newfilename) = @_;
+    my ($request, $user, $domain, $fn, $newfilename, $style) = @_;
 
     if(-e $fn) {
 	if($newfilename) {
 	    # is dest a dir
-	    if (-d $newfilename) {
-		if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
+	    if ($style eq 'move') {
+		if (-d $newfilename) {
+		    if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
+		}
 	    }
 	    if ($newfilename =~ m|/[^\.]+$|) {
 		#no extension add on original extension
@@ -441,9 +443,15 @@
 				'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
 		return;
 	    }
+	    my $action;
+	    if ($style eq 'rename') {
+		$action=&mt('Rename');
+	    } else {
+		$action=&mt('Move');
+	    }
 	    $request->print('<input type="hidden" name="newfilename" value="'.
 			    $newfilename.
-			    '" /><p>'.&mt('Rename').' '.&display($fn).
+			    '" /><p>'.$action.' '.&display($fn).
 			    '</tt><br />to '.&display($newfilename).'?</p>');
 	    &CloseForm1($request, $fn);
 	} else {
@@ -742,7 +750,9 @@
       '<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />');
   
   if ($ENV{'form.action'} eq 'rename') {
-      &Rename1($r, $uname, $udom, $fn, $newfilename);
+      &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename');
+  } elsif ($ENV{'form.action'} eq 'move') {
+      &Rename1($r, $uname, $udom, $fn, $newfilename, 'move');
   } elsif ($ENV{'form.action'} eq 'delete') { 
       &Delete1($r, $uname, $udom, $fn);
   } elsif ($ENV{'form.action'} eq 'decompress') {
@@ -1236,6 +1246,8 @@
       $r->print('<h3>'.&mt('Delete').'</h3>');
   } elsif ($ENV{'form.action'} eq 'rename') {
       $r->print('<h3>'.&mt('Rename').'</h3>');
+  } elsif ($ENV{'form.action'} eq 'move') {
+      $r->print('<h3>'.&mt('Move').'</h3>');
   } elsif ($ENV{'form.action'} eq 'newdir') {
       $r->print('<h3>'.&mt('New Directory').'</h3>');
   } elsif ($ENV{'form.action'} eq 'decompress') {