--- loncom/publisher/loncfile.pm 2004/02/17 22:06:10 1.51 +++ 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.51 2004/02/17 22:06:10 raeburn 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).'?

'); &CloseForm1($request, $fn); } else { @@ -742,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') { @@ -1062,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, @@ -1236,6 +1254,8 @@ function writeDone() { $r->print('

'.&mt('Delete').'

'); } elsif ($ENV{'form.action'} eq 'rename') { $r->print('

'.&mt('Rename').'

'); + } elsif ($ENV{'form.action'} eq 'move') { + $r->print('

'.&mt('Move').'

'); } elsif ($ENV{'form.action'} eq 'newdir') { $r->print('

'.&mt('New Directory').'

'); } elsif ($ENV{'form.action'} eq 'decompress') {