version 1.74, 2005/11/09 09:06:59
|
version 1.81, 2007/03/30 20:37:31
|
Line 72 use Apache::loncacc;
|
Line 72 use Apache::loncacc;
|
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use LONCAPA qw(:DEFAULT :match); |
|
|
|
|
my $DEBUG=0; |
my $DEBUG=0; |
my $r; # Needs to be global for some stuff RF. |
my $r; # Needs to be global for some stuff RF. |
Line 148 sub URLToPath {
|
Line 150 sub URLToPath {
|
$Url=~ s/\/+/\//g; |
$Url=~ s/\/+/\//g; |
$Url=~ s/^http\:\/\/[^\/]+//; |
$Url=~ s/^http\:\/\/[^\/]+//; |
$Url=~ s/^\///; |
$Url=~ s/^\///; |
$Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//; |
$Url=~ s/(\~|priv\/)($match_username)\//\/home\/$2\/public_html\//; |
&Debug($r, "Returning $Url \n"); |
&Debug($r, "Returning $Url \n"); |
return $Url; |
return $Url; |
} |
} |
|
|
sub url { |
sub url { |
my $fn=shift; |
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,'<>"&'); |
$fn=&HTML::Entities::encode($fn,'<>"&'); |
return $fn; |
return $fn; |
} |
} |
|
|
sub display { |
sub display { |
my $fn=shift; |
my $fn=shift; |
$fn=~s-^/home/(\w+)/public_html-/priv/$1-; |
$fn=~s-^/home/($match_username)/public_html-/priv/$1-; |
return '<tt>'.$fn.'</tt>'; |
return '<tt>'.$fn.'</tt>'; |
} |
} |
|
|
Line 747 sub NewFile1 {
|
Line 749 sub NewFile1 {
|
return; |
return; |
} |
} |
if ($newfilename !~ /\Q.$extension\E$/) { |
if ($newfilename !~ /\Q.$extension\E$/) { |
if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) { |
if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) { |
#already has an extension strip it and add in expected one |
#already has an extension strip it and add in expected one |
$newfilename =~ s|.([^\.]+)$||; |
$newfilename =~ s|(/[^./])\.(?:[^.]+)$|$1|; |
} |
} |
$newfilename.=".$extension"; |
$newfilename.=".$extension"; |
} |
} |
} |
} |
my $result=&exists($user,$domain,$newfilename); |
my $result=&exists($user,$domain,$newfilename); |
if($result) { |
if($result) { |
$request->print('<font color="red">'.$result.'</font></form>'); |
$request->print('<span class="LC_error">'.$result.'</span></form>'); |
} else { |
} else { |
$request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>'); |
$request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>'); |
$request->print('</form>'); |
$request->print('</form>'); |
Line 1135 sub phasetwo {
|
Line 1137 sub phasetwo {
|
|
|
&Debug($r, "loncfile - Entering phase 2 for $fn"); |
&Debug($r, "loncfile - Entering phase 2 for $fn"); |
|
|
# Break down the file into it's component pieces. |
# Break down the file into its component pieces. |
|
|
my $dir; # Directory path |
my $dir; # Directory path |
my $main; # Filename. |
my $main; # Filename. |
Line 1148 sub phasetwo {
|
Line 1150 sub phasetwo {
|
$suffix=$1; #This is the actually filename extension if it exists |
$suffix=$1; #This is the actually filename extension if it exists |
$main=~s/\.\w+$//; #strip the extension |
$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,"loncfile::phase2 dir = $dir main = $main suffix = $suffix"); |
&Debug($r," newfilename = ".$env{'form.newfilename'}); |
&Debug($r," newfilename = ".$env{'form.newfilename'}); |
|
|
Line 1176 sub phasetwo {
|
Line 1180 sub phasetwo {
|
if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) { |
if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) { |
return; |
return; |
} |
} |
$dest = $env{'form.newfilename'}; |
$dest = $dir."/"; |
|
$dest_newname = $env{'form.newfilename'}; |
|
$env{'form.newfilename'} =~ /.+(\/.+$)/; |
|
$disp_newname = $1; |
|
$disp_newname =~ s/\///; |
} |
} |
} elsif ($env{'form.action'} eq 'delete') { |
} elsif ($env{'form.action'} eq 'delete') { |
if(!&Delete2($r, $uname, $env{'form.newfilename'})) { |
if(!&Delete2($r, $uname, $env{'form.newfilename'})) { |
Line 1207 sub phasetwo {
|
Line 1215 sub phasetwo {
|
if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { |
if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { |
$r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>'); |
$r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>'); |
} else { |
} else { |
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>'); |
if ($env{'form.action'} eq 'rename') { |
|
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Return to Directory').'</a></h3>'); |
|
$r->print('<h3><a href="'.&url($dest_newname).'">'.$disp_newname.'</a></h3>'); |
|
} else { |
|
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>'); |
|
} |
} |
} |
} |
} |
|
|
Line 1229 sub handler {
|
Line 1242 sub handler {
|
|
|
if ($env{'form.filename'}) { |
if ($env{'form.filename'}) { |
&Debug($r, "test: $env{'form.filename'}"); |
&Debug($r, "test: $env{'form.filename'}"); |
$fn=&Apache::lonnet::unescape($env{'form.filename'}); |
$fn=&unescape($env{'form.filename'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
} elsif($ENV{'QUERY_STRING'} && $env{'form.phase'} ne 'two') { |
} elsif($ENV{'QUERY_STRING'} && $env{'form.phase'} ne 'two') { |
#Just hijack the script only the first time around to inject the |
#Just hijack the script only the first time around to inject the |
#correct information for further processing |
#correct information for further processing |
$fn=&Apache::lonnet::unescape($env{'form.decompress'}); |
$fn=&unescape($env{'form.decompress'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
$env{'form.action'}="decompress"; |
$env{'form.action'}="decompress"; |
} elsif ($env{'form.qualifiedfilename'}) { |
} elsif ($env{'form.qualifiedfilename'}) { |
Line 1273 sub handler {
|
Line 1286 sub handler {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
|
my (%loaditem,$js); |
|
|
if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { |
if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) { |
my $newdirname = $env{'form.newfilename'}; |
my $newdirname = $env{'form.newfilename'}; |
$r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">'); |
$js = qq| |
$r->print(qq| |
<script type="text/javascript"> |
function writeDone() { |
function writeDone() { |
var winName = window.opener |
var winName = window.opener |
window.focus(); |
window.focus(); |
Line 1284 function writeDone() {
|
Line 1299 function writeDone() {
|
setTimeout("self.close()",10000) |
setTimeout("self.close()",10000) |
} |
} |
</script> |
</script> |
</head>|); |
|; |
my $loaditem = 'onLoad="writeDone()"'; |
$loaditem{'onload'} = "writeDone()"; |
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation','',$loaditem)); |
|
} else { |
|
$r->print('<html><head><title>LON-CAPA Construction Space</title></head>'); |
|
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation')); |
|
} |
} |
|
|
|
$r->print(&Apache::loncommon::start_page('Construction Space File Operation', |
|
$js, |
|
{'add_entries' => \%loaditem,})); |
|
|
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>'); |
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>'); |
|
|
Line 1325 function writeDone() {
|
Line 1339 function writeDone() {
|
$env{'form.action'} eq 'Select Action' ) { |
$env{'form.action'} eq 'Select Action' ) { |
$r->print('<h3>'.&mt('New Resource').'</h3>'); |
$r->print('<h3>'.&mt('New Resource').'</h3>'); |
} else { |
} else { |
$r->print('<p>'.&mt('Unknown Action').' '.$env{'form.action'}.' </p></body></html>'); |
$r->print('<p>'.&mt('Unknown Action').' '.$env{'form.action'}.' </p>'. |
|
&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
if ($env{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
Line 1336 function writeDone() {
|
Line 1351 function writeDone() {
|
&phaseone($r,$fn,$uname,$udom); |
&phaseone($r,$fn,$uname,$udom); |
} |
} |
|
|
$r->print('</body></html>'); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
|
|