version 1.30, 2006/04/06 22:15:19
|
version 1.31, 2006/09/13 21:43:26
|
Line 51 sub phaseone {
|
Line 51 sub phaseone {
|
my $resdir=$resfn; |
my $resdir=$resfn; |
$resdir=~s/\/[^\/]+$/\//; |
$resdir=~s/\/[^\/]+$/\//; |
|
|
$fn=~/\/([^\/]+)\.(\w+)$/; |
my ($main,$suffix,$is_meta) = &get_file_info($fn); |
my $main=$1; |
|
my $suffix=$2; |
|
|
|
if (-e $resfn) { |
if (-e $resfn) { |
$r->print('<form action=/adm/retrieve method=post>'. |
$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>'.&mt('Select').'</th><th>'. |
'<table border=2><tr><th>'.&mt('Select').'</th><th>'. |
&mt('Version').'</th>'. |
&mt('Version').'</th>'. |
'<th>'.&mt('Published on ...').'</th>'. |
'<th>'.&mt('Published on ...').'</th>'); |
'<th>'.&mt('Metadata').'</th></tr>'); |
if (!$is_meta) { |
|
$r->print('<th>'.&mt('Metadata').'</th>'); |
|
} |
|
if ($is_meta |
|
|| &Apache::loncommon::fileembstyle($suffix) eq 'ssi') { |
|
$r->print('<th>'.&mt('Diffs').'</th>'); |
|
} |
|
$r->print('</tr>'); |
|
|
opendir(DIR,$resdir); |
opendir(DIR,$resdir); |
my @files = grep(/^\Q$main\E\.(\d+)\.\Q$suffix\E$/,readdir(DIR)); |
my @files = grep(/^\Q$main\E\.(\d+)\.\Q$suffix\E$/,readdir(DIR)); |
@files = sort { |
@files = sort { |
Line 79 sub phaseone {
|
Line 84 sub phaseone {
|
my $rmtime=&Apache::lonnet::metadata($resdir.'/'.$filename,'lastrevisiondate'); |
my $rmtime=&Apache::lonnet::metadata($resdir.'/'.$filename,'lastrevisiondate'); |
$r->print('<tr><td><input type=radio name=version value="'. |
$r->print('<tr><td><input type=radio name=version value="'. |
$version.'"></td><td>'.&mt('Previously published version').' '.$version.'</td><td>'. |
$version.'"></td><td>'.&mt('Previously published version').' '.$version.'</td><td>'. |
localtime($rmtime).'</td><td>'. |
localtime($rmtime).'</td>'); |
'<a href="'.$urldir.$filename.'.meta" target=cat>'. |
|
&mt('Metadata Version').' '.$version.'</a>'); |
if (!$is_meta) { |
if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') { |
$r->print('<td><a href="'.$urldir.$filename.'.meta" target=cat>'. |
|
&mt('Metadata Version').' '.$version.'</a></td>'); |
|
} |
|
if ($is_meta |
|
|| &Apache::loncommon::fileembstyle($suffix) eq 'ssi') { |
$r->print( |
$r->print( |
' <a target=cat href="/adm/diff?filename=/~'. |
'<td><a target=cat href="/adm/diff?filename=/~'. |
$uname.$fn. |
$uname.$fn. |
'&versiontwo=priv&versionone='.$version. |
'&versiontwo=priv&versionone='.$version. |
'">'.&mt('Diffs with Version').' '.$version.'</a>'); |
'">'.&mt('Diffs with Version').' '.$version. |
|
'</a></td>'); |
} |
} |
$r->print('</a></td></tr>'); |
$r->print('</tr>'); |
} |
} |
} |
} |
closedir(DIR); |
closedir(DIR); |
my $rmtime=&Apache::lonnet::metadata($resfn,'lastrevisiondate'); |
my $rmtime=&Apache::lonnet::metadata($resfn,'lastrevisiondate'); |
$r->print('<tr><td><input type=radio name=version value="new"></td>'. |
$r->print('<tr><td><input type=radio name=version value="new"></td>'. |
'<th>'.&mt('Currently published version').'</th><td>'.localtime($rmtime). |
'<th>'.&mt('Currently published version').'</th><td>'.localtime($rmtime). |
'</td><td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'. |
'</td>'); |
&mt('Metadata current version').'</a>'); |
if (!$is_meta) { |
if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') { |
$r->print('<td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'. |
|
&mt('Metadata current version').'</a></td>'); |
|
} |
|
if ($is_meta |
|
|| &Apache::loncommon::fileembstyle($suffix) eq 'ssi') { |
$r->print( |
$r->print( |
' <a target=cat href="/adm/diff?filename=/~'. |
'<td><a target=cat href="/adm/diff?filename=/~'. |
$uname.$fn. |
$uname.$fn. |
'&versiontwo=priv'. |
'&versiontwo=priv'. |
'">'.&mt('Diffs with current Version').'</a>'); |
'">'.&mt('Diffs with current Version').'</a></td>'); |
} |
} |
$r->print('</td></tr></table><p>'. |
$r->print('</tr></table><p>'. |
'<font size=+1 color=red>'. |
'<font size=+1 color=red>'. |
&mt('Retrieval of an old version will overwrite the file currently in construction space').'</font><p>'. |
&mt('Retrieval of an old version will overwrite the file currently in construction space').'</font><p>'. |
'<input type=submit value="'.&mt('Retrieve version').'"></form>'); |
'<input type=submit value="'.&mt('Retrieve version').'"></form>'); |
Line 126 sub phasetwo {
|
Line 140 sub phasetwo {
|
} else { |
} else { |
$r->print('<h3>'.&mt('Retrieving old version').' '.$version.'</h3>'); |
$r->print('<h3>'.&mt('Retrieving old version').' '.$version.'</h3>'); |
} |
} |
|
my ($main,$suffix,$is_meta) = &get_file_info($fn); |
|
|
my $logfile; |
my $logfile; |
my $ctarget='/home/'.$uname.'/public_html'.$fn; |
my $ctarget='/home/'.$uname.'/public_html'.$fn; |
my $vfn=$fn; |
my $vfn=$fn; |
if ($version ne 'new') { |
if ($version ne 'new') { |
$vfn=~s/\.(\w+)$/\.$version\.$1/; |
$vfn=~s/\.(\Q$suffix\E)$/\.$version\.$1/; |
} |
} |
|
|
my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn; |
my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn; |
unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) { |
|
|
my $logname = $ctarget; |
|
if ($is_meta) { $logname =~ s/\.meta$//; } |
|
$logname = $ctarget.'.log'; |
|
unless ($logfile=Apache::File->new('>>'.$logname)) { |
$r->print( |
$r->print( |
'<font color=red>'.&mt('No write permission to user directory, FAIL').'</font>'); |
'<font color=red>'.&mt('No write permission to user directory, FAIL').'</font>'); |
} |
} |
Line 141 sub phasetwo {
|
Line 162 sub phasetwo {
|
"\n\n================= Retrieve ".localtime()." ================\n". |
"\n\n================= Retrieve ".localtime()." ================\n". |
"Version: $version\nSource: $csource\nTarget: $ctarget\n"; |
"Version: $version\nSource: $csource\nTarget: $ctarget\n"; |
$r->print('<p>'.&mt('Copying file').': '); |
$r->print('<p>'.&mt('Copying file').': '); |
if (copy($csource,$ctarget)) { |
if (copy($csource,$ctarget)) { |
$r->print('ok<p>'); |
$r->print('ok<p>'); |
print $logfile "Copied sucessfully.\n\n"; |
print $logfile "Copied sucessfully.\n\n"; |
} else { |
} else { |
Line 158 sub phasetwo {
|
Line 179 sub phasetwo {
|
} |
} |
} |
} |
|
|
|
sub get_file_info { |
|
my ($fn) = @_; |
|
my ($main,$suffix) = ($fn=~/\/([^\/]+)\.(\w+)$/); |
|
my $is_meta=0; |
|
if ($suffix eq 'meta') { |
|
$is_meta = 1; |
|
($main,$suffix) = ($main=~/(.+)\.(\w+)$/); |
|
$suffix .= '.meta'; |
|
} |
|
return ($main,$suffix,$is_meta); |
|
} |
|
|
# ---------------------------------------------------------------- Main Handler |
# ---------------------------------------------------------------- Main Handler |
sub handler { |
sub handler { |
|
|