--- loncom/publisher/lonretrieve.pm 2008/12/19 03:55:25 1.37
+++ loncom/publisher/lonretrieve.pm 2011/11/14 00:20:31 1.47
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to retrieve an old version of a file
#
-# $Id: lonretrieve.pm,v 1.37 2008/12/19 03:55:25 raeburn Exp $
+# $Id: lonretrieve.pm,v 1.47 2011/11/14 00:20:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -108,20 +108,18 @@ use LONCAPA();
# ------------------------------------ Interface for selecting previous version
sub phaseone {
my ($r,$fn,$uname,$udom)=@_;
- my $docroot=$r->dir_config('lonDocRoot');
- my $urldir='/res/'.$udom.'/'.$uname.$fn;
- $urldir=~s/\/[^\/]+$/\//;
+ my $urldir = "/res/$udom/$uname".$fn;
+ my $resfn = $r->dir_config('lonDocRoot').$urldir;
- my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
- my $resdir=$resfn;
- $resdir=~s/\/[^\/]+$/\//;
+ $urldir =~ s{[^/]+$}{};
+ my $resdir = $r->dir_config('lonDocRoot').$urldir;
my ($main,$suffix,$is_meta) = &get_file_info($fn);
if (-e $resfn) {
- $r->print('
');
+ $r->print(' ');
} else {
$r->print(''.&mt('No previous versions published.').'
');
}
- $r->print(''
- .&mt('Back to [_1]',''.$fn.' ')
- .'
');
+
+ my $dir = &Apache::loncommon::authorspace($fn)
+ .&File::Basename::dirname($fn)
+ .'/';
+ $r->print(' '
+ .&Apache::loncommon::head_subbox(
+ &Apache::lonhtmlcommon::start_funclist()
+ .&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .&mt('Back to Resource')
+ .' ')
+ .&Apache::lonhtmlcommon::add_item_funclist(
+ ''
+ .&mt('Back to Directory')
+ .' ')
+ .&Apache::lonhtmlcommon::end_funclist()
+ )
+ );
}
# ---------------------------------- Interface for presenting specified version
@@ -220,13 +234,13 @@ sub phasetwo {
my ($main,$suffix,$is_meta) = &get_file_info($fn);
my $logfile;
- my $ctarget='/home/'.$uname.'/public_html'.$fn;
+ my $ctarget=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$fn;
my $vfn=$fn;
if ($version ne 'new') {
$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;
my $logname = $ctarget;
if ($is_meta) { $logname =~ s/\.meta$//; }
@@ -253,8 +267,8 @@ sub phasetwo {
print $logfile "Copy failed: $error\n\n";
}
$r->print(''
- .''
- .&mt('Back to [_1]',$fn)
+ .''
+ .&mt('Back to Resource')
.'
');
} else {
$r->print(''.&mt('Please pick a version to retrieve:').'
');
@@ -289,7 +303,7 @@ sub handler {
if ($env{'form.filename'}) {
$fn=$env{'form.filename'};
- $fn=~s/^https?\:\/\/[^\/]+//;
+ $fn =~ s{^https?\://[^/]+}{};
} else {
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' unspecified filename for retrieval', $r->filename);
@@ -306,9 +320,8 @@ sub handler {
my $uname;
my $udom;
- ($uname,$udom)=
- &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
- unless (($uname) && ($udom)) {
+ ($uname,$udom) = &Apache::loncacc::constructaccess($fn);
+ unless (($uname ne '') && ($udom ne '')) {
$r->log_reason($uname.' at '.$udom.
' trying to publish file '.$env{'form.filename'}.
' ('.$fn.') - not authorized',
@@ -316,23 +329,43 @@ sub handler {
return HTTP_NOT_ACCEPTABLE;
}
- $fn=~s{/~($LONCAPA::username_re)}{};
-
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- $r->print(&Apache::loncommon::start_page('Retrieve Published Resources'));
+ # Breadcrumbs
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Construction Space',
+ 'href' => &Apache::loncommon::authorspace($fn),
+ });
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Retrieve previous version',
+ 'href' => '',
+ });
+
+ my $londocroot = $r->dir_config('lonDocRoot');
+ my $trailfile = $fn;
+ $trailfile =~ s{^/(priv/)}{$londocroot/$1};
+
+ $r->print(&Apache::loncommon::start_page('Retrieve Published Resources')
+ .&Apache::lonhtmlcommon::breadcrumbs()
+ .&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader($trailfile))
+ );
-
- $r->print(''
+ $fn=~s{/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{};
+
+ $r->print(' '
.&mt('Retrieve previous versions of [_1]'
,''.$fn.' ')
- .'');
+ .'
');
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- $r->print(''.&mt('Co-Author').': '.$uname.
- &mt(' at ').$udom.
- ' ');
+ $r->print(''
+ .&mt('Co-Author [_1]'
+ ,&Apache::loncommon::plainname($uname,$udom)
+ .' ('.$uname.':'.$udom.')')
+ .'
');
}