--- loncom/publisher/loncfile.pm 2003/12/15 22:01:14 1.48
+++ 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.48 2003/12/15 22:01:14 taceyjo1 Exp $
+# $Id: loncfile.pm,v 1.53 2004/04/03 00:23:47 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -173,6 +173,28 @@ sub display {
return ''.$fn.'';
}
+
+# see if the file is
+# a) published (return 0 if not)
+# b) if, so obsolete (return 0 if not)
+
+sub obsolete_unpub {
+ my ($user,$domain,$construct)=@_;
+ my $published=$construct;
+ $published=~
+ s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//;
+ if (-e $published) {
+ if (&Apache::lonnet::metadata($published,'obsolete')) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+
+
=pod
=item exists($user, $domain, $file)
@@ -384,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
@@ -402,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 /
@@ -414,9 +446,20 @@ sub Rename1 {
$request->print('
'.&mt('Cancel').'');
return;
}
+ unless (&obsolete_unpub($user,$domain,$fn)) {
+ $request->print('
'.&mt('Rename').' '.&display($fn). + '" />
'.$action.' '.&display($fn).
'
to '.&display($newfilename).'?
'.&mt('Delete').' '.&display($fn).'?
'); &CloseForm1($request, $fn); } else { @@ -567,12 +615,17 @@ causes the newdir operation to transitio sub NewDir1 { - my ($request, $username, $domain, $fn, $newfilename) = @_; + my ($request, $username, $domain, $fn, $newfilename, $mode) = @_; my $result=&exists($username,$domain,$newfilename); if ($result) { $request->print(''.$result.''); } else { + if ($mode eq 'testbank') { + $request->print(''); + } elsif ($mode eq 'imsimport') { + $request->print(''); + } $request->print(''.&mt('Make new directory').' '. &display($newfilename).'?
'); @@ -705,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') { @@ -717,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' || @@ -1089,7 +1148,11 @@ sub phasetwo { } $dest = $newdir."/" } - $r->print('