version 1.4, 2001/04/03 22:03:55
|
version 1.8, 2001/05/02 21:35:15
|
Line 11
|
Line 11
|
# 03/23 Guy Albertelli |
# 03/23 Guy Albertelli |
# 03/24,03/29 Gerd Kortemeyer) |
# 03/24,03/29 Gerd Kortemeyer) |
# |
# |
# 03/31,04/03 Gerd Kortemeyer |
# 03/31,04/03,05/02 Gerd Kortemeyer |
|
|
package Apache::lonretrieve; |
package Apache::lonretrieve; |
|
|
Line 31 sub phaseone {
|
Line 31 sub phaseone {
|
my $resdir=$resfn; |
my $resdir=$resfn; |
$resdir=~s/\/[^\/]+$/\//; |
$resdir=~s/\/[^\/]+$/\//; |
|
|
$fn=~/^\/(.+)\.(\w+)$/; |
$fn=~/\/([^\/]+)\.(\w+)$/; |
my $main=$1; |
my $main=$1; |
my $suffix=$2; |
my $suffix=$2; |
|
|
|
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="'.$fn.'">'. |
'<input type=hidden name=filename value="'.$fn.'">'. |
'<input type=hidden name=phase value=two>'. |
'<input type=hidden name=phase value=two>'. |
Line 54 sub phaseone {
|
Line 55 sub phaseone {
|
$version.'"></td><th>'.$version.'</th><td>'. |
$version.'"></td><th>'.$version.'</th><td>'. |
localtime($rmtime).'</td><td>'. |
localtime($rmtime).'</td><td>'. |
'<a href="'.$urldir.$filename.'.meta" target=cat>'. |
'<a href="'.$urldir.$filename.'.meta" target=cat>'. |
'Metadata Version '.$version.'</a></td></tr>'); |
'Metadata Version '.$version); |
|
if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') { |
|
$r->print( |
|
' <a target=cat href="/adm/diff?filename='.$fn. |
|
'&versionone=priv&versiontwo='.$version. |
|
'">Diffs with Version '.$version.'</a>'); |
|
} |
|
$r->print('</a></td></tr>'); |
} |
} |
} |
} |
closedir(DIR); |
closedir(DIR); |
Line 69 sub phaseone {
|
Line 77 sub phaseone {
|
'<font size=+1 color=red>Retrieval of an old version will '. |
'<font size=+1 color=red>Retrieval of an old version will '. |
'overwrite the file currently in construction space</font><p>'. |
'overwrite the file currently in construction space</font><p>'. |
'<input type=submit value="Retrieve version"></form>'); |
'<input type=submit value="Retrieve version"></form>'); |
|
} else { |
|
$r->print('<h3>No previous versions published.</h3>'); |
|
} |
} |
} |
|
|
sub phasetwo { |
sub phasetwo { |
Line 82 sub phasetwo {
|
Line 93 sub phasetwo {
|
} |
} |
my $logfile; |
my $logfile; |
my $ctarget='/home/'.$uname.'/public_html'.$fn; |
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')) { |
unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) { |
$r->print( |
$r->print( |
'<font color=red>No write permission to user directory, FAIL</font>'); |
'<font color=red>No write permission to user directory, FAIL</font>'); |
} |
} |
print $logfile |
print $logfile |
"\n\n================= Retrieve ".localtime()." ================\n". |
"\n\n================= Retrieve ".localtime()." ================\n". |
"Version $version\n\n"; |
"Version: $version\nSource: $csource\nTarget: $ctarget\n"; |
|
$r->print('<p>Copying file: '); |
|
if (copy($csource,$ctarget)) { |
|
$r->print('ok<p>'); |
|
print $logfile "Copied sucessfully.\n\n"; |
|
} else { |
|
my $error=$!; |
|
$r->print('fail, '.$error.'<p>'); |
|
print $logfile "Copy failed: $error\n\n"; |
|
} |
|
$r->print('<font size=+2><a href="/priv/'.$uname.$fn. |
|
'">Back to '.$fn.'</a></font>'); |
} else { |
} else { |
$r->print( |
$r->print( |
'<font size=+1 color=red>Please pick a version to retrieve</font><p>'); |
'<font size=+1 color=red>Please pick a version to retrieve</font><p>'); |
Line 143 sub handler {
|
Line 169 sub handler {
|
$r->print('</body></html>'); |
$r->print('</body></html>'); |
return OK; |
return OK; |
} |
} |
|
|
|
1; |
|
__END__ |