--- loncom/publisher/lonretrieve.pm 2005/12/12 21:59:12 1.28 +++ loncom/publisher/lonretrieve.pm 2006/12/06 22:22:39 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to retrieve an old version of a file # -# $Id: lonretrieve.pm,v 1.28 2005/12/12 21:59:12 albertel Exp $ +# $Id: lonretrieve.pm,v 1.34 2006/12/06 22:22:39 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::loncacc; use Apache::loncommon(); use Apache::lonlocal; use Apache::lonnet; +use LONCAPA(); # ------------------------------------ Interface for selecting previous version sub phaseone { @@ -51,67 +52,91 @@ sub phaseone { my $resdir=$resfn; $resdir=~s/\/[^\/]+$/\//; - $fn=~/\/([^\/]+)\.(\w+)$/; - my $main=$1; - my $suffix=$2; - + my ($main,$suffix,$is_meta) = &get_file_info($fn); + if (-e $resfn) { - $r->print('
'); -} else { - $r->print(''.&mt('Copying file').': '); - if (copy($csource,$ctarget)) { + if (copy($csource,$ctarget)) { $r->print('ok
'); print $logfile "Copied sucessfully.\n\n"; } else { @@ -152,12 +184,23 @@ sub phasetwo { $r->print(''.&mt('Back to').' '.$fn.''); } else { - $r->print( - ''.&mt('Please pick a version to retrieve').'
'); + $r->print(''.&mt('Please pick a version to retrieve').'
'); &phaseone($r,$fn,$uname,$udom); } } +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 sub handler { @@ -200,22 +243,20 @@ sub handler { return HTTP_NOT_ACCEPTABLE; } - $fn=~s/\/\~(\w+)//; + $fn=~s{/~($LONCAPA::username_re)}{}; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print('