--- loncom/publisher/lonretrieve.pm 2005/01/05 17:38:27 1.26
+++ loncom/publisher/lonretrieve.pm 2006/01/31 22:37:04 1.29
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to retrieve an old version of a file
#
-# $Id: lonretrieve.pm,v 1.26 2005/01/05 17:38:27 www Exp $
+# $Id: lonretrieve.pm,v 1.29 2006/01/31 22:37:04 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,6 +37,7 @@ use Apache::Constants qw(:common :http :
use Apache::loncacc;
use Apache::loncommon();
use Apache::lonlocal;
+use Apache::lonnet;
# ------------------------------------ Interface for selecting previous version
sub phaseone {
@@ -62,9 +63,17 @@ sub phaseone {
&mt('Version').''.
'
'.&mt('Published on ...').'
'.
'
'.&mt('Metadata').'
');
- my $filename;
+
opendir(DIR,$resdir);
- while ($filename=readdir(DIR)) {
+ my @files = grep(/^\Q$main\E\.(\d+)\.\Q$suffix\E$/,readdir(DIR));
+ @files = sort {
+ my ($aver) = ($a=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
+ my ($bver) = ($b=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
+ return $aver <=> $bver;
+ } (@files);
+ closedir(DIR);
+
+ foreach my $filename (@files) {
if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
my $version=$1;
my $rmtime=&Apache::lonnet::metadata($resdir.'/'.$filename,'lastrevisiondate');
@@ -86,7 +95,7 @@ sub phaseone {
closedir(DIR);
my $rmtime=&Apache::lonnet::metadata($resfn,'lastrevisiondate');
$r->print('
'.
- '
'.&mt('Currently public version').'
'.localtime($rmtime).
+ '
'.&mt('Currently published version').'
'.localtime($rmtime).
'
'.
&mt('Metadata current version').'');
if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
@@ -110,8 +119,8 @@ sub phaseone {
# ---------------------------------- Interface for presenting specified version
sub phasetwo {
my ($r,$fn,$uname,$udom)=@_;
- if ($ENV{'form.version'}) {
- my $version=$ENV{'form.version'};
+ if ($env{'form.version'}) {
+ my $version=$env{'form.version'};
if ($version eq 'new') {
$r->print('
'.&mt('Retrieving current (most recent) version').'
');
} else {
@@ -162,17 +171,17 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['filename']);
- if ($ENV{'form.filename'}) {
- $fn=$ENV{'form.filename'};
+ if ($env{'form.filename'}) {
+ $fn=$env{'form.filename'};
$fn=~s/^http\:\/\/[^\/]+//;
} else {
- $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' unspecified filename for retrieval', $r->filename);
return HTTP_NOT_FOUND;
}
unless ($fn) {
- $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' trying to retrieve non-existing file', $r->filename);
return HTTP_NOT_FOUND;
}
@@ -185,7 +194,7 @@ sub handler {
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
unless (($uname) && ($udom)) {
$r->log_reason($uname.' at '.$udom.
- ' trying to publish file '.$ENV{'form.filename'}.
+ ' trying to publish file '.$env{'form.filename'}.
' ('.$fn.') - not authorized',
$r->filename);
return HTTP_NOT_ACCEPTABLE;
@@ -203,14 +212,14 @@ sub handler {
$r->print('
'.&mt('Retrieve previous versions of').' '.$fn.'
');
- if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
$r->print('
'.&mt('Co-Author').': '.$uname.
&mt(' at ').$udom.
'
');
}
- if ($ENV{'form.phase'} eq 'two') {
+ if ($env{'form.phase'} eq 'two') {
&phasetwo($r,$fn,$uname,$udom);
} else {
&phaseone($r,$fn,$uname,$udom);