Diff for /loncom/publisher/loncfile.pm between versions 1.2 and 1.3

version 1.2, 2001/06/23 18:51:32 version 1.3, 2001/06/23 20:09:06
Line 27  use Apache::loncacc; Line 27  use Apache::loncacc;
   
 sub phaseone {  sub phaseone {
     my ($r,$fn,$uname,$udom)=@_;      my ($r,$fn,$uname,$udom)=@_;
     my $docroot=$r->dir_config('lonDocRoot');  
   
     my $urldir='/res/'.$udom.'/'.$uname.$fn;      $fn=~/(.*)\/([^\/]+)\.(\w+)$/;
     $urldir=~s/\/[^\/]+$/\//;      my $dir=$1;
       my $main=$2;
       my $suffix=$3;
   
     my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;      my $conspace='/home/'.$uname.'/public_html'.$fn;
     my $resdir=$resfn;  
     $resdir=~s/\/[^\/]+$/\//;  
   
     $fn=~/\/([^\/]+)\.(\w+)$/;      $r->print('<form action=/adm/cfile method=post>'.
     my $main=$1;  
     my $suffix=$2;  
   
     if (-e $resfn) {    
     $r->print('<form action=/adm/retrieve method=post>'.  
       '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.        '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.
               '<input type=hidden name=phase value=two>'.                '<input type=hidden name=phase value=two>'.
               '<table border=2><tr><th>Select</th><th>Version</th>'.                '<input type=hidden name=action value='.$ENV{'form.action'}.'>');
               '<th>Became this version on ...</th>'.      if ($ENV{'form.action'} eq 'rename') {
               '<th>Metadata</th></tr>');   if (-e $conspace) {
     my $filename;      if ($ENV{'form.newfilename'}) {
     opendir(DIR,$resdir);                 $ENV{'form.newfilename'}=~/(.*)\/([^\/]+)\.(\w+)$/;
     while ($filename=readdir(DIR)) {                 if ($3 ne $suffix) {
         if ($filename=~/^$main\.(\d+)\.$suffix$/) {     $r->print(
    my $version=$1;                      '<p><font color=red>Warning: change of MIME type!</font>');
            my ($rdev,$rino,$rmode,$rnlink,                 }
                 $ruid,$rgid,$rrdev,$rsize,                 if (-e 
                 $ratime,$rmtime,$rctime,                  '/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) {
                 $rblksize,$rblocks)=stat($resdir.'/'.$filename);     $r->print(
            $r->print('<tr><td><input type=radio name=version value="'.                      '<p><font color=red>Warning: target file exists!</font>');
                      $version.'"></td><th>'.$version.'</th><td>'.                 }
                      localtime($rmtime).'</td><td>'.         $r->print('<p>Rename <tt>'.$fn.'</tt> to <tt>'.
                      '<a href="'.$urldir.$filename.'.meta" target=cat>'.                           $dir.'/'.$ENV{'form.newfilename'}.'</tt>?');
                      'Metadata Version '.$version.'</a>');      } else {
            if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') {         $r->print('<p>No new filename specified.</form>');
                $r->print(                 return;
                     '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.      }
                         $uname.$fn.  
                         '&versionone=priv&versiontwo='.$version.  
                         '">Diffs with Version '.$version.'</a>');  
            }  
            $r->print('</a></td></tr>');  
         }  
     }  
     closedir(DIR);  
     my ($rdev,$rino,$rmode,$rnlink,  
         $ruid,$rgid,$rrdev,$rsize,  
         $ratime,$rmtime,$rctime,  
         $rblksize,$rblocks)=stat($resfn);  
     $r->print('<tr><td><input type=radio name=version value="new"></td>'.  
               '<th>Current</th><td>'.localtime($rmtime).  
            '</td><td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'.  
               'Metadata current version</a>');             
            if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') {  
                $r->print(  
                     '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.  
                         $uname.$fn.  
                         '&versionone=priv'.  
                         '">Diffs with current Version</a>');  
            }  
            $r->print('</td></tr></table><p>'.  
            '<font size=+1 color=red>Retrieval of an old version will '.  
            'overwrite the file currently in construction space</font><p>'.  
            '<input type=submit value="Retrieve version"></form>');  
 } else {  
     $r->print('<h3>No previous versions published.</h3>');  
 }  
 }  
   
 sub phasetwo {  
     my ($r,$fn,$uname,$udom)=@_;  
     if ($ENV{'form.version'}) {  
         my $version=$ENV{'form.version'};  
  if ($version eq 'new') {  
     $r->print('<h3>Retrieving current (most recent) version</h3>');  
         } else {          } else {
             $r->print('<h3>Retrieving old version '.$version.'</h3>');      $r->print('<p>No such file.</form>');
               return;
         }          }
         my $logfile;      } elsif ($ENV{'form.action'} eq 'delete') { 
         my $ctarget='/home/'.$uname.'/public_html'.$fn;   if (-e $conspace) {
         my $vfn=$fn;              $r->print('<p>Delete <tt>'.$fn.'</tt>?');
         if ($version ne 'new') {          } else {
     $vfn=~s/\.(\w+)$/\.$version\.$1/;      $r->print('<p>No such file.</form>');
         }              return;
         my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn;  
         unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) {  
   $r->print(  
          '<font color=red>No write permission to user directory, FAIL</font>');  
         }          }
         print $logfile       } elsif ($ENV{'form.action'} eq 'copy') { 
 "\n\n================= Retrieve ".localtime()." ================\n".   if (-e $conspace) {
 "Version: $version\nSource: $csource\nTarget: $ctarget\n";      if ($ENV{'form.newfilename'}) {
         $r->print('<p>Copying file: ');                 $ENV{'form.newfilename'}=~/(.*)\/([^\/]+)\.(\w+)$/;
         if (copy($csource,$ctarget)) {                 if ($3 ne $suffix) {
     $r->print('ok<p>');     $r->print(
             print $logfile "Copied sucessfully.\n\n";                      '<p><font color=red>Warning: change of MIME type!</font>');
                  }
                  if (-e 
                   '/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) {
      $r->print(
                       '<p><font color=red>Warning: target file exists!</font>');
                  }
          $r->print('<p>Copy <tt>'.$fn.'</tt> to <tt>'.
                            $dir.'/'.$ENV{'form.newfilename'}.'</tt>?');
       } else {
          $r->print('<p>No new filename specified.</form>');
                  return;
       }
         } else {          } else {
             my $error=$!;      $r->print('<p>No such file.</form>');
     $r->print('fail, '.$error.'<p>');              return;
             print $logfile "Copy failed: $error\n\n";  
         }          }
         $r->print('<font size=+2><a href="/priv/'.$uname.$fn.      } elsif ($ENV{'form.action'} eq 'newdir') {
                   '">Back to '.$fn.'</a></font>');    if (-e $conspace) {
     } else {              $r->print('<p>Directory exists.</form>');
        $r->print(              return;
    '<font size=+1 color=red>Please pick a version to retrieve</font><p>');          }
        &phaseone($r,$fn,$uname,$udom);         
     }      }
       $r->print('<p><input type=submit value=Continue></form>'); 
   }
   
   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 {  sub handler {
Line 205  sub handler { Line 179  sub handler {
   if ($ENV{'form.phase'} eq 'two') {    if ($ENV{'form.phase'} eq 'two') {
 #      &phasetwo($r,$fn,$uname,$udom);  #      &phasetwo($r,$fn,$uname,$udom);
   } else {    } else {
 #      &phaseone($r,$fn,$uname,$udom);        &phaseone($r,$fn,$uname,$udom);
   }    }
   
   $r->print('</body></html>');    $r->print('</body></html>');

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>