--- loncom/publisher/loncfile.pm 2004/01/05 16:48:50 1.50
+++ loncom/publisher/loncfile.pm 2004/05/26 22:15:19 1.54
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.50 2004/01/05 16:48:50 www Exp $
+# $Id: loncfile.pm,v 1.54 2004/05/26 22:15:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -406,13 +406,15 @@ new filename relative to the current dir
=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
@@ -424,6 +426,14 @@ sub Rename1 {
#renaming a dir, delete the trailing /
#remove second to last element for current dir
if (-d $fn) {
+ $newfilename=~/\.(\w+)$/;
+ if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
+ $request->print('
'.
+ &mt('Cannot change MIME type of a directory').
+ ''.
+ '
'.&mt('Cancel').'');
+ return;
+ }
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/;
}
$newfilename=~s://+:/:g; # remove duplicate /
@@ -441,9 +451,15 @@ sub Rename1 {
'
'.&mt('Cancel').'');
return;
}
+ my $action;
+ if ($style eq 'rename') {
+ $action=&mt('Rename');
+ } else {
+ $action=&mt('Move');
+ }
$request->print('
'.&mt('Rename').' '.&display($fn). + '" />
'.$action.' '.&display($fn).
'
to '.&display($newfilename).'?
'.&mt('Make new directory').' '. &display($newfilename).'?
'); @@ -737,7 +758,9 @@ sub phaseone { ''); 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') { @@ -749,7 +772,11 @@ sub phaseone { $r->print(''.&mt('No new filename specified.').'
'); } } elsif ($ENV{'form.action'} eq 'newdir') { - &NewDir1($r, $uname, $udom, $fn, $newfilename); + my $mode = ''; + if (exists($ENV{'form.callingmode'}) ) { + $mode = $ENV{'form.callingmode'}; + } + &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); } elsif ($ENV{'form.action'} eq 'newfile' || $ENV{'form.action'} eq 'newhtmlfile' || $ENV{'form.action'} eq 'newproblemfile' || @@ -1053,11 +1080,11 @@ sub phasetwo { if ($fn=~m:(.*)/([^/]+):) { $dir=$1; # Directory path $main=$2; # Filename. - } - if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions - $main=$`; #This is what is before the match (.) so it's just the main filename, yea it's nasty - $suffix=$1; #This is the actually filename extension if it exists - } + } + if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions + $main=$`; #This is what is before the match (.) so it's just the main filename, yea it's nasty + $suffix=$1; #This is the actually filename extension if it exists + } my $dest; # On success this is where we'll go. &Debug($r, @@ -1121,7 +1148,11 @@ sub phasetwo { } $dest = $newdir."/" } - $r->print('