--- loncom/publisher/loncfile.pm 2001/06/23 18:26:40 1.1 +++ loncom/publisher/loncfile.pm 2001/06/23 20:09:06 1.3 @@ -27,114 +27,88 @@ use Apache::loncacc; sub phaseone { my ($r,$fn,$uname,$udom)=@_; - my $docroot=$r->dir_config('lonDocRoot'); - my $urldir='/res/'.$udom.'/'.$uname.$fn; - $urldir=~s/\/[^\/]+$/\//; + $fn=~/(.*)\/([^\/]+)\.(\w+)$/; + my $dir=$1; + my $main=$2; + my $suffix=$3; - my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn; - my $resdir=$resfn; - $resdir=~s/\/[^\/]+$/\//; + my $conspace='/home/'.$uname.'/public_html'.$fn; - $fn=~/\/([^\/]+)\.(\w+)$/; - my $main=$1; - my $suffix=$2; - - if (-e $resfn) { - $r->print('
'); -} else { - $r->print('Warning: change of MIME type!'); + } + if (-e + '/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) { + $r->print( + '
Warning: target file exists!'); + } + $r->print('
Rename '.$fn.' to '. + $dir.'/'.$ENV{'form.newfilename'}.'?'); + } else { + $r->print('
No new filename specified.'); + return; + } } else { - $r->print('
No such file.'); + return; } - my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn; - unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) { - $r->print( - 'No write permission to user directory, FAIL'); + } elsif ($ENV{'form.action'} eq 'delete') { + if (-e $conspace) { + $r->print('
Delete '.$fn.'?'); + } else { + $r->print('
No such file.'); + return; } - print $logfile -"\n\n================= Retrieve ".localtime()." ================\n". -"Version: $version\nSource: $csource\nTarget: $ctarget\n"; - $r->print('
Copying file: '); - if (copy($csource,$ctarget)) { - $r->print('ok
'); - print $logfile "Copied sucessfully.\n\n"; + } elsif ($ENV{'form.action'} eq 'copy') { + if (-e $conspace) { + if ($ENV{'form.newfilename'}) { + $ENV{'form.newfilename'}=~/(.*)\/([^\/]+)\.(\w+)$/; + if ($3 ne $suffix) { + $r->print( + '
Warning: change of MIME type!'); + } + if (-e + '/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) { + $r->print( + '
Warning: target file exists!'); + } + $r->print('
Copy '.$fn.' to '. + $dir.'/'.$ENV{'form.newfilename'}.'?'); + } else { + $r->print('
No new filename specified.'); + return; + } } else { - my $error=$!; - $r->print('fail, '.$error.'
'); - print $logfile "Copy failed: $error\n\n"; + $r->print('
No such file.'); + return; + } + } elsif ($ENV{'form.action'} eq 'newdir') { + if (-e $conspace) { + $r->print('
Directory exists.'); + return; } - $r->print('Back to '.$fn.''); - } else { - $r->print( - 'Please pick a version to retrieve
'); - &phaseone($r,$fn,$uname,$udom); + } + $r->print('
'); +} + +sub phasetwo { + my ($r,$fn,$uname,$udom)=@_; + if ($ENV{'form.action'} eq 'rename') { + } elsif ($ENV{'form.action'} eq 'delete') { + } elsif ($ENV{'form.action'} eq 'copy') { + } elsif ($ENV{'form.action'} eq 'newdir') { + } } sub handler { @@ -190,11 +164,22 @@ sub handler { ''); } - + if ($ENV{'form.action'} eq 'delete') { + $r->print('
Unknown Action