--- loncom/publisher/loncfile.pm 2004/02/17 22:06:10 1.51
+++ loncom/publisher/loncfile.pm 2004/04/03 00:23:47 1.53
@@ -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.53 2004/04/03 00:23:47 www 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).'?