--- loncom/publisher/loncfile.pm 2001/06/23 18:51:32 1.2 +++ 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('
'. + $r->print(''. ''. ''. - ''. - ''. - ''); - my $filename; - opendir(DIR,$resdir); - while ($filename=readdir(DIR)) { - if ($filename=~/^$main\.(\d+)\.$suffix$/) { - my $version=$1; - my ($rdev,$rino,$rmode,$rnlink, - $ruid,$rgid,$rrdev,$rsize, - $ratime,$rmtime,$rctime, - $rblksize,$rblocks)=stat($resdir.'/'.$filename); - $r->print(''); - } - } - closedir(DIR); - my ($rdev,$rino,$rmode,$rnlink, - $ruid,$rgid,$rrdev,$rsize, - $ratime,$rmtime,$rctime, - $rblksize,$rblocks)=stat($resfn); - $r->print(''. - '
SelectVersionBecame this version on ...Metadata
'.$version.''. - localtime($rmtime).''. - ''. - 'Metadata Version '.$version.''); - if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') { - $r->print( - '  Diffs with Version '.$version.''); - } - $r->print('
Current'.localtime($rmtime). - ''. - 'Metadata current version'); - if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') { - $r->print( - '  Diffs with current Version'); - } - $r->print('

'. - 'Retrieval of an old version will '. - 'overwrite the file currently in construction space

'. - '

'); -} else { - $r->print('

No previous versions published.

'); -} -} - -sub phasetwo { - my ($r,$fn,$uname,$udom)=@_; - if ($ENV{'form.version'}) { - my $version=$ENV{'form.version'}; - if ($version eq 'new') { - $r->print('

Retrieving current (most recent) version

'); + ''); + if ($ENV{'form.action'} eq 'rename') { + 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('

Rename '.$fn.' to '. + $dir.'/'.$ENV{'form.newfilename'}.'?'); + } else { + $r->print('

No new filename specified.'); + return; + } } else { - $r->print('

Retrieving old version '.$version.'

'); + $r->print('

No such file.'); + return; } - my $logfile; - my $ctarget='/home/'.$uname.'/public_html'.$fn; - my $vfn=$fn; - if ($version ne 'new') { - $vfn=~s/\.(\w+)$/\.$version\.$1/; - } - 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; } - $r->print('Back to '.$fn.''); - } else { - $r->print( - 'Please pick a version to retrieve

'); - &phaseone($r,$fn,$uname,$udom); + } elsif ($ENV{'form.action'} eq 'newdir') { + if (-e $conspace) { + $r->print('

Directory exists.'); + return; + } + } + $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 { @@ -205,7 +179,7 @@ sub handler { if ($ENV{'form.phase'} eq 'two') { # &phasetwo($r,$fn,$uname,$udom); } else { -# &phaseone($r,$fn,$uname,$udom); + &phaseone($r,$fn,$uname,$udom); } $r->print('');