--- loncom/publisher/loncfile.pm 2006/11/22 22:10:58 1.78 +++ loncom/publisher/loncfile.pm 2007/03/30 20:37:31 1.81 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.78 2006/11/22 22:10:58 banghart Exp $ +# $Id: loncfile.pm,v 1.81 2007/03/30 20:37:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,9 +72,8 @@ use Apache::loncacc; use Apache::lonnet; use Apache::loncommon(); use Apache::lonlocal; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; - +use LONCAPA qw(:DEFAULT :match); + my $DEBUG=0; my $r; # Needs to be global for some stuff RF. @@ -151,21 +150,21 @@ sub URLToPath { $Url=~ s/\/+/\//g; $Url=~ s/^http\:\/\/[^\/]+//; $Url=~ s/^\///; - $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//; + $Url=~ s/(\~|priv\/)($match_username)\//\/home\/$2\/public_html\//; &Debug($r, "Returning $Url \n"); return $Url; } sub url { my $fn=shift; - $fn=~s/^\/home\/(\w+)\/public\_html/\/priv\/$1/; + $fn=~s/^\/home\/($match_username)\/public\_html/\/priv\/$1/; $fn=&HTML::Entities::encode($fn,'<>"&'); return $fn; } sub display { my $fn=shift; - $fn=~s-^/home/(\w+)/public_html-/priv/$1-; + $fn=~s-^/home/($match_username)/public_html-/priv/$1-; return ''.$fn.''; } @@ -750,16 +749,16 @@ sub NewFile1 { return; } if ($newfilename !~ /\Q.$extension\E$/) { - if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) { + if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) { #already has an extension strip it and add in expected one - $newfilename =~ s|.([^\.]+)$||; + $newfilename =~ s|(/[^./])\.(?:[^.]+)$|$1|; } $newfilename.=".$extension"; } } my $result=&exists($user,$domain,$newfilename); if($result) { - $request->print(''.$result.''); + $request->print(''.$result.''); } else { $request->print('

'.&mt('Make new file').' '.&display($newfilename).'?

'); $request->print(''); @@ -1151,8 +1150,10 @@ sub phasetwo { $suffix=$1; #This is the actually filename extension if it exists $main=~s/\.\w+$//; #strip the extension } - my $dest; # On success this is where we'll go. - + my $dest; # + my $dest_dir; # On success this is where we'll go. + my $disp_newname; # + my $dest_newname; # &Debug($r,"loncfile::phase2 dir = $dir main = $main suffix = $suffix"); &Debug($r," newfilename = ".$env{'form.newfilename'}); @@ -1180,6 +1181,10 @@ sub phasetwo { return; } $dest = $dir."/"; + $dest_newname = $env{'form.newfilename'}; + $env{'form.newfilename'} =~ /.+(\/.+$)/; + $disp_newname = $1; + $disp_newname =~ s/\///; } } elsif ($env{'form.action'} eq 'delete') { if(!&Delete2($r, $uname, $env{'form.newfilename'})) { @@ -1210,7 +1215,12 @@ sub phasetwo { if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { $r->print('

'.&mt('Done').'

'); } else { - $r->print('

'.&mt('Done').'

'); + if ($env{'form.action'} eq 'rename') { + $r->print('

'.&mt('Return to Directory').'

'); + $r->print('

'.$disp_newname.'

'); + } else { + $r->print('

'.&mt('Done').'

'); + } } }