[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 04 Aug 2003 20:08:23 -0000
www Mon Aug 4 16:08:23 2003 EDT
Modified files:
/loncom/publisher loncfile.pm
Log:
Bug #2018: looks like it works.
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.37 loncom/publisher/loncfile.pm:1.38
--- loncom/publisher/loncfile.pm:1.37 Mon Aug 4 13:45:06 2003
+++ loncom/publisher/loncfile.pm Mon Aug 4 16:08:23 2003
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.37 2003/08/04 17:45:06 www Exp $
+# $Id: loncfile.pm,v 1.38 2003/08/04 20:08:23 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -819,27 +819,13 @@
" new file ".$newfile."\n");
&Debug($request, "Target is: ".$directory.'/'.
$newfile);
-
- if(-e $oldfile) {
- my $dest;
-
- if ($oldfile =~ m|/$|) {
- #renaming a dir
- $oldfile =~ s|/$||;
- $dest=$directory;
- $dest=~s|(/)([^/]*)$|$1|;
- $dest.='/'.$newfile;
- } else {
- $dest=$directory.'/'.$newfile;
- }
-
- unless(rename($oldfile,$dest)) {
+ if (-e $oldfile) {
+ unless (rename($oldfile,$newfile)) {
$request->print('<font color="red">Error: '.$!.'</font>');
return 0;
- } else {}
+ }
} else {
- $request->print("<p> No such file: /home".$user.'/public_html'.
- $oldfile.' </p></form>');
+ $request->print("<p> No such file: ".&display($oldfile).'</p></form>');
return 0;
}
return 1;
@@ -1047,13 +1033,7 @@
if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
return;
}
- # Prepend the directory to the new name to form the basis of the
- # url of the new resource.
- #
- #renaming a dir
- #remove last element for current dir
- if ($fn =~ m|/$|) { $dir =~ s|/[^/]*$||; }
- $dest = $dir."/".$ENV{'form.newfilename'};
+ $dest = &url($ENV{'form.newfilename'});
}
} elsif ($ENV{'form.action'} eq 'delete') {
if(!&Delete2($r, $uname, $ENV{'form.newfilename'})) {
@@ -1076,38 +1056,13 @@
}
} elsif ($ENV{'form.action'} eq 'newdir') {
- #
- # Since the newfilename form field is construction space
- # relative, ew need to prepend the current path; now in $fn.
- #
- my $newdir= $fn.$ENV{'form.newfilename'};
+ my $newdir= $ENV{'form.newfilename'};
if(!&NewDir2($r, $uname, $newdir)) {
return;
}
$dest = $newdir."/"
}
- #
- # Substitute for priv for the first home in $dir to get our
- # construction space path.
- #
- $dest=&MakeFinalUrl($r,$dest);
-
- $r->print('<h3><a href="'.$dest.'">Done</a></h3>');
-}
-
-sub MakeFinalUrl {
- my($r,$dest)=@_;
- &Debug($r, "Final url is: $dest");
- $dest =~ s|/home/|/priv/|;
- $dest =~ s|/public_html||;
-
- my $base = &File::Basename::basename($dest);
- my $dpath= &File::Basename::dirname($dest);
- if ($base eq '.') { $base=''; }
- $dest = &HTML::Entities::encode($dpath.'/'.$base);
-
- &Debug($r, "Final url after rewrite: $dest");
- return $dest;
+ $r->print('<h3><a href="'.&url($dest).'">Done</a></h3>');
}
sub handler {