version 1.44, 2003/11/19 14:57:32
|
version 1.53, 2004/04/03 00:23:47
|
Line 72 use Apache::loncacc;
|
Line 72 use Apache::loncacc;
|
use Apache::Log (); |
use Apache::Log (); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
use Apache::lonlocal; |
|
|
my $DEBUG=2; |
my $DEBUG=0; |
my $r; # Needs to be global for some stuff RF. |
my $r; # Needs to be global for some stuff RF. |
|
|
=pod |
=pod |
Line 110 sub Debug {
|
Line 111 sub Debug {
|
# Put out the indicated message butonly if DEBUG is true. |
# Put out the indicated message butonly if DEBUG is true. |
|
|
if ($DEBUG) { |
if ($DEBUG) { |
$r->log_reason($message); |
$r->log_reason($message); |
} |
} |
} |
} |
|
|
=pod |
=pod |
|
|
=item checksuffix($old, $new) |
|
|
|
Determine if a resource filename suffix (the stuff after the .) would change |
|
as a result of this operation. |
|
|
|
Parameters: |
|
|
|
=over 4 |
|
|
|
=item $old = string [in] Previous filename. |
|
|
|
=item $new = string [in] Resultant filename. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
=pod |
|
|
|
=item URLToPath($url) |
=item URLToPath($url) |
|
|
Convert a URL to a file system path. |
Convert a URL to a file system path. |
Line 191 sub display {
|
Line 173 sub display {
|
return '<tt>'.$fn.'</tt>'; |
return '<tt>'.$fn.'</tt>'; |
} |
} |
|
|
|
|
|
# see if the file is |
|
# a) published (return 0 if not) |
|
# b) if, so obsolete (return 0 if not) |
|
|
|
sub obsolete_unpub { |
|
my ($user,$domain,$construct)=@_; |
|
my $published=$construct; |
|
$published=~ |
|
s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//; |
|
if (-e $published) { |
|
if (&Apache::lonnet::metadata($published,'obsolete')) { |
|
return 1; |
|
} |
|
return 0; |
|
} else { |
|
return 1; |
|
} |
|
} |
|
|
|
|
|
|
=pod |
=pod |
|
|
=item exists($user, $domain, $file) |
=item exists($user, $domain, $file) |
Line 230 sub exists {
|
Line 234 sub exists {
|
s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//; |
s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//; |
my $result=''; |
my $result=''; |
if ( -d $construct ) { |
if ( -d $construct ) { |
return 'Error: destination for operation is an existing directory.'; |
return &mt('Error: destination for operation is an existing directory.'); |
} |
} |
if ( -e $published) { |
if ( -e $published) { |
$result.='<p><font color="red">Warning: target file exists, and has been published!</font></p>'; |
$result.='<p><font color="red">'.&mt('Warning: target file exists, and has been published!').'</font></p>'; |
} elsif ( -e $construct) { |
} elsif ( -e $construct) { |
$result.='<p><font color="red">Warning: target file exists!</font></p>'; |
$result.='<p><font color="red">'.&mt('Warning: target file exists!').'</font></p>'; |
} |
} |
return $result; |
return $result; |
|
|
Line 279 sub checksuffix {
|
Line 283 sub checksuffix {
|
if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; } |
if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; } |
if ($oldsuffix ne $newsuffix) { |
if ($oldsuffix ne $newsuffix) { |
$result.= |
$result.= |
'<p><font color="red">Warning: change of MIME type!</font></p>'; |
'<p><font color="red">'.&mt('Warning: change of MIME type!').'</font></p>'; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 288 sub cleanDest {
|
Line 292 sub cleanDest {
|
my ($request,$dest)=@_; |
my ($request,$dest)=@_; |
#remove bad characters |
#remove bad characters |
if ($dest=~/[\#\?&]/) { |
if ($dest=~/[\#\?&]/) { |
$request->print("<p><font color=\"red\">Invalid characters in requested name have been removed.</font></p>"); |
$request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>"); |
$dest=~s/[\#\?&]//g; |
$dest=~s/[\#\?&]//g; |
} |
} |
return $dest; |
return $dest; |
Line 331 Parameters:
|
Line 335 Parameters:
|
|
|
sub CloseForm1 { |
sub CloseForm1 { |
my ($request, $fn) = @_; |
my ($request, $fn) = @_; |
$request->print('<p><input type="submit" value="Continue" /></p></form>'); |
$request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>'); |
$request->print('<form action="'.&url($fn). |
$request->print('<form action="'.&url($fn). |
'" method="POST"><p><input type="submit" value="Cancel" /></p></form>'); |
'" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>'); |
} |
} |
|
|
|
|
Line 363 Parameters:
|
Line 367 Parameters:
|
|
|
sub CloseForm2 { |
sub CloseForm2 { |
my ($request, $user, $fn) = @_; |
my ($request, $user, $fn) = @_; |
$request->print('<h3><a href="'.&url($fn).'/">Done</a></h3>'); |
$request->print('<h3><a href="'.&url($fn).'/">'.&mt('Done').'</a></h3>'); |
} |
} |
|
|
=pod |
=pod |
Line 402 new filename relative to the current dir
|
Line 406 new filename relative to the current dir
|
=cut |
=cut |
|
|
sub Rename1 { |
sub Rename1 { |
my ($request, $user, $domain, $fn, $newfilename) = @_; |
my ($request, $user, $domain, $fn, $newfilename, $style) = @_; |
|
|
if(-e $fn) { |
if(-e $fn) { |
if($newfilename) { |
if($newfilename) { |
# is dest a dir |
# is dest a dir |
if (-d $newfilename) { |
if ($style eq 'move') { |
if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; } |
if (-d $newfilename) { |
|
if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; } |
|
} |
} |
} |
if ($newfilename =~ m|/[^\.]+$|) { |
if ($newfilename =~ m|/[^\.]+$|) { |
#no extension add on original extension |
#no extension add on original extension |
Line 420 sub Rename1 {
|
Line 426 sub Rename1 {
|
#renaming a dir, delete the trailing / |
#renaming a dir, delete the trailing / |
#remove second to last element for current dir |
#remove second to last element for current dir |
if (-d $fn) { |
if (-d $fn) { |
|
$newfilename=~/\.(\w+)$/; |
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
|
$request->print('<br /><font color="red">'. |
|
&mt('Cannot change MIME type of a directory'). |
|
'</font>'. |
|
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
|
return; |
|
} |
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/; |
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/; |
} |
} |
$newfilename=~s://+:/:g; # remove duplicate / |
$newfilename=~s://+:/:g; # remove duplicate / |
Line 429 sub Rename1 {
|
Line 443 sub Rename1 {
|
my $return=&exists($user, $domain, $newfilename); |
my $return=&exists($user, $domain, $newfilename); |
$request->print($return); |
$request->print($return); |
if ($return =~/^Error:/) { |
if ($return =~/^Error:/) { |
$request->print('<br /><a href="'.&url($fn).'">Cancel</a>'); |
$request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
|
return; |
|
} |
|
unless (&obsolete_unpub($user,$domain,$fn)) { |
|
$request->print('<h3>'.&mt('Cannot rename or move non-obsolete published file').'</h3>'. |
|
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
return; |
return; |
} |
} |
|
my $action; |
|
if ($style eq 'rename') { |
|
$action=&mt('Rename'); |
|
} else { |
|
$action=&mt('Move'); |
|
} |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$newfilename. |
$newfilename. |
'" /><p>Rename '.&display($fn). |
'" /><p>'.$action.' '.&display($fn). |
'</tt><br />to '.&display($newfilename).'?</p>'); |
'</tt><br />to '.&display($newfilename).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} else { |
} else { |
$request->print('<p>No new filename specified.</p></form>'); |
$request->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
return; |
return; |
} |
} |
} else { |
} else { |
$request->print('<p> No such file: '.&display($fn).'</p></form>'); |
$request->print('<p> '.&mt('No such file').': '.&display($fn).'</p></form>'); |
return; |
return; |
} |
} |
|
|
Line 477 sub Delete1 {
|
Line 502 sub Delete1 {
|
if( -e $fn) { |
if( -e $fn) { |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$fn.'"/>'); |
$fn.'"/>'); |
$request->print('<p>Delete '.&display($fn).'?</p>'); |
unless (&obsolete_unpub($user,$domain,$fn)) { |
|
$request->print('<h3>'.&mt('Cannot delete non-obsolete published file').'</h3>'. |
|
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
|
return; |
|
} |
|
$request->print('<p>'.&mt('Delete').' '.&display($fn).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} else { |
} else { |
$request->print('<p>No such file: '.&display($fn).'</p></form>'); |
$request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>'); |
} |
} |
} |
} |
|
|
Line 531 sub Copy1 {
|
Line 561 sub Copy1 {
|
my $return=&exists($user, $domain, $newfilename); |
my $return=&exists($user, $domain, $newfilename); |
$request->print($return); |
$request->print($return); |
if ($return =~/^Error:/) { |
if ($return =~/^Error:/) { |
$request->print('<br /><a href="'.&url($fn).'">Cancel</a>'); |
$request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
return; |
return; |
} |
} |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$newfilename. |
$newfilename. |
'" /><p>Copy '.&display($fn).'<br />to '. |
'" /><p>'.&mt('Copy').' '.&display($fn).'<br />to '. |
&display($newfilename).'?</p>'); |
&display($newfilename).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} else { |
} else { |
$request->print('<p>No such file: '.&display($fn).'</p></form>'); |
$request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>'); |
} |
} |
} |
} |
|
|
Line 585 causes the newdir operation to transitio
|
Line 615 causes the newdir operation to transitio
|
|
|
sub NewDir1 |
sub NewDir1 |
{ |
{ |
my ($request, $username, $domain, $fn, $newfilename) = @_; |
my ($request, $username, $domain, $fn, $newfilename, $mode) = @_; |
|
|
my $result=&exists($username,$domain,$newfilename); |
my $result=&exists($username,$domain,$newfilename); |
if ($result) { |
if ($result) { |
$request->print('<font color="red">'.$result.'</font></form>'); |
$request->print('<font color="red">'.$result.'</font></form>'); |
} else { |
} else { |
|
if ($mode eq 'testbank') { |
|
$request->print('<input type="hidden" name="callingmode" value="testbank">'); |
|
} elsif ($mode eq 'imsimport') { |
|
$request->print('<input type="hidden" name="callingmode" value="imsimport">'); |
|
} |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$newfilename.'" /><p>Make new directory '. |
$newfilename.'" /><p>'.&mt('Make new directory').' '. |
&display($newfilename).'?</p>'); |
&display($newfilename).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} |
} |
Line 603 sub Decompress1 {
|
Line 638 sub Decompress1 {
|
my ($request, $user, $domain, $fn) = @_; |
my ($request, $user, $domain, $fn) = @_; |
if( -e $fn) { |
if( -e $fn) { |
$request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>'); |
$request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>'); |
$request->print('<p>Decompress '.&display($fn).'?</p>'); |
$request->print('<p>'.&mt('Decompress').' '.&display($fn).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} else { |
} else { |
$request->print('<p>No such file: '.&display($fn).'</p></form>'); |
$request->print('<p>'.&mt('No such file').': '.&display($fn).'</p></form>'); |
} |
} |
} |
} |
=pod |
=pod |
Line 659 sub NewFile1 {
|
Line 694 sub NewFile1 {
|
##Informs User (name).(number).(extension) not allowed |
##Informs User (name).(number).(extension) not allowed |
if($newfilename =~ /\.(\d+)\.(\w+)$/){ |
if($newfilename =~ /\.(\d+)\.(\w+)$/){ |
$r->print('<font color="red">'.$newfilename. |
$r->print('<font color="red">'.$newfilename. |
' - Bad Filename<br />(name).(number).(extension)'. |
' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').')'. |
' Not Allowed</font>'); |
' '.&mt('Not Allowed').'</font>'); |
return; |
return; |
} |
} |
if ($newfilename !~ /\Q.$extension\E$/) { |
if ($newfilename !~ /\Q.$extension\E$/) { |
Line 675 sub NewFile1 {
|
Line 710 sub NewFile1 {
|
if($result) { |
if($result) { |
$request->print('<font color="red">'.$result.'</font></form>'); |
$request->print('<font color="red">'.$result.'</font></form>'); |
} else { |
} else { |
$request->print('<p>Make new file '.&display($newfilename).'?</p>'); |
$request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>'); |
$request->print('</form>'); |
$request->print('</form>'); |
$request->print('<form action="'.&url($newfilename). |
$request->print('<form action="'.&url($newfilename). |
'" method="POST"><p><input type="submit" value="Continue" /></p></form>'); |
'" method="POST"><p><input type="submit" value="'.&mt('Continue').'" /></p></form>'); |
$request->print('<form action="'.&url($fn). |
$request->print('<form action="'.&url($fn). |
'" method="POST"><p><input type="submit" value="Cancel" /></p></form>'); |
'" method="POST"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>'); |
} |
} |
} |
} |
|
|
Line 717 sub phaseone {
|
Line 752 sub phaseone {
|
|
|
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'}); |
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'}); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
&Debug($r, "Newfile: $newfilename"); |
|
$r->print('<form action="/adm/cfile" method="post">'. |
$r->print('<form action="/adm/cfile" method="post">'. |
'<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'. |
'<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
|
|
if ($ENV{'form.action'} eq 'rename') { |
if ($ENV{'form.action'} eq 'rename') { |
&Rename1($r, $uname, $udom, $fn, $newfilename); |
&Rename1($r, $uname, $udom, $fn, $newfilename, 'rename'); |
|
} elsif ($ENV{'form.action'} eq 'move') { |
|
&Rename1($r, $uname, $udom, $fn, $newfilename, 'move'); |
} elsif ($ENV{'form.action'} eq 'delete') { |
} elsif ($ENV{'form.action'} eq 'delete') { |
&Delete1($r, $uname, $udom, $fn); |
&Delete1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'decompress') { |
} elsif ($ENV{'form.action'} eq 'decompress') { |
&Apache::lonnet::appenv('cgi.path' => $newfilename); |
|
&Decompress1($r, $uname, $udom, $fn); |
&Decompress1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
if($newfilename) { |
if($newfilename) { |
&Copy1($r, $uname, $udom, $fn, $newfilename); |
&Copy1($r, $uname, $udom, $fn, $newfilename); |
} else { |
} else { |
$r->print('<p>No new filename specified.</p></form>'); |
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
} |
} |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
&NewDir1($r, $uname, $udom, $fn, $newfilename); |
my $mode = ''; |
|
if (exists($ENV{'form.callingmode'}) ) { |
|
$mode = $ENV{'form.callingmode'}; |
|
} |
|
&NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); |
} elsif ($ENV{'form.action'} eq 'newfile' || |
} elsif ($ENV{'form.action'} eq 'newfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
Line 749 sub phaseone {
|
Line 788 sub phaseone {
|
if ($newfilename) { |
if ($newfilename) { |
&NewFile1($r, $uname, $udom, $fn, $newfilename); |
&NewFile1($r, $uname, $udom, $fn, $newfilename); |
} else { |
} else { |
$r->print('<p>No new filename specified.</p></form>'); |
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
} |
} |
} |
} |
} |
} |
Line 801 sub Rename2 {
|
Line 840 sub Rename2 {
|
my $oRN=$oldfile; |
my $oRN=$oldfile; |
my $nRN=$newfile; |
my $nRN=$newfile; |
unless (rename($oldfile,$newfile)) { |
unless (rename($oldfile,$newfile)) { |
$request->print('<font color="red">Error: '.$!.'</font>'); |
$request->print('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
return 0; |
return 0; |
} |
} |
## If old name.(extension) exits, move under new name. |
## If old name.(extension) exits, move under new name. |
Line 836 sub Rename2 {
|
Line 875 sub Rename2 {
|
unlink $tmp2; |
unlink $tmp2; |
} |
} |
} else { |
} else { |
$request->print("<p> No such file: ".&display($oldfile).'</p></form>'); |
$request->print("<p> ".&mt('No such file').": ".&display($oldfile).'</p></form>'); |
return 0; |
return 0; |
} |
} |
return 1; |
return 1; |
Line 872 Returns:
|
Line 911 Returns:
|
|
|
sub Delete2 { |
sub Delete2 { |
my ($request, $user, $filename) = @_; |
my ($request, $user, $filename) = @_; |
|
if(opendir DIR, $filename) { |
if(-e $filename) { |
my @files=readdir(DIR); |
unless(unlink($filename)) { |
shift @files; shift @files; # takes off . and .. |
$request->print('<font color="red">Error: '.$!.'</font>'); |
if(@files) { |
|
$request->print('<font color="red"> '.&mt('Error: Directory Non Empty').'</font>'); |
|
return 0; |
|
} else { |
|
if(-e $filename) { |
|
unless(rmdir($filename)) { |
|
$request->print('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
|
return 0; |
|
} |
|
} else { |
|
$request->print('<p> '.&mt('No such file').'. </p></form>'); |
|
return 0; |
|
} |
|
} |
|
} else { |
|
if(-e $filename) { |
|
unless(unlink($filename)) { |
|
$request->print('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
|
return 0; |
|
} |
|
} else { |
|
$request->print('<p> '.&mt('No such file').'. </p></form>'); |
return 0; |
return 0; |
} |
|
} else { |
|
$request->print('<p> No such file. </p></form'); |
|
return 0; |
|
} |
} |
|
} |
return 1; |
return 1; |
} |
} |
|
|
Line 918 sub Copy2 {
|
Line 975 sub Copy2 {
|
&Debug($request ,"Will try to copy $oldfile to $newfile"); |
&Debug($request ,"Will try to copy $oldfile to $newfile"); |
if(-e $oldfile) { |
if(-e $oldfile) { |
unless (copy($oldfile, $newfile)) { |
unless (copy($oldfile, $newfile)) { |
$request->print('<font color="red"> copy Error: '.$!.'</font>'); |
$request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>'); |
return 0; |
return 0; |
} else { |
} else { |
unless (chmod(0660, $newfile)) { |
unless (chmod(0660, $newfile)) { |
$request->print('<font color="red"> chmod error: '.$!.'</font>'); |
$request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>'); |
return 0; |
return 0; |
} |
} |
return 1; |
return 1; |
} |
} |
} else { |
} else { |
$request->print('<p> No such file </p>'); |
$request->print('<p> '.&mt('No such file').' </p>'); |
return 0; |
return 0; |
} |
} |
return 1; |
return 1; |
Line 959 sub NewDir2 {
|
Line 1016 sub NewDir2 {
|
my ($request, $user, $newdirectory) = @_; |
my ($request, $user, $newdirectory) = @_; |
|
|
unless(mkdir($newdirectory, 02770)) { |
unless(mkdir($newdirectory, 02770)) { |
$request->print('<font color="red">Error: '.$!.'</font>'); |
$request->print('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
return 0; |
return 0; |
} |
} |
unless(chmod(02770, ($newdirectory))) { |
unless(chmod(02770, ($newdirectory))) { |
$request->print('<font color="red"> Error: '.$!.'</font>'); |
$request->print('<font color="red"> '.&mt('Error').': '.$!.'</font>'); |
return 0; |
return 0; |
} |
} |
return 1; |
return 1; |
Line 1020 sub phasetwo {
|
Line 1077 sub phasetwo {
|
my $dir; # Directory path |
my $dir; # Directory path |
my $main; # Filename. |
my $main; # Filename. |
my $suffix; # Extension. |
my $suffix; # Extension. |
|
if ($fn=~m:(.*)/([^/]+):) { |
if ($fn=~m:(.*)/([^/]+)\.(\w+)$:) { |
|
$dir=$1; # Directory path |
$dir=$1; # Directory path |
$main=$2; # Filename. |
$main=$2; # Filename. |
$suffix=$3; # Extension. |
} |
} |
if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions |
|
$main=$`; #This is what is before the match (.) so it's just the main filename, yea it's nasty |
|
$suffix=$1; #This is the actually filename extension if it exists |
|
} |
my $dest; # On success this is where we'll go. |
my $dest; # On success this is where we'll go. |
|
|
&Debug($r, |
&Debug($r, |
Line 1079 sub phasetwo {
|
Line 1137 sub phasetwo {
|
$dest = $ENV{'form.newfilename'}; |
$dest = $ENV{'form.newfilename'}; |
|
|
} else { |
} else { |
$r->print('<p>No New filename specified</p></form>'); |
$r->print('<p>'.&mt('No New filename specified').'</p></form>'); |
return; |
return; |
} |
} |
|
|
Line 1090 sub phasetwo {
|
Line 1148 sub phasetwo {
|
} |
} |
$dest = $newdir."/" |
$dest = $newdir."/" |
} |
} |
$r->print('<h3><a href="'.&url($dest).'">Done</a></h3>'); |
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>'); |
|
} else { |
|
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>'); |
|
} |
} |
} |
|
|
sub handler { |
sub handler { |
Line 1114 sub handler {
|
Line 1176 sub handler {
|
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
} |
} |
|
#Just hijack the script only the first time around to inject the correct information for further processing |
elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
Line 1154 sub handler {
|
Line 1217 sub handler {
|
} |
} |
|
|
|
|
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
$r->print('<html><head><title>LON-CAPA Construction Space</title></head>'); |
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'}; |
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation')); |
$r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">'); |
|
$r->print(qq| |
|
function writeDone() { |
|
var winName = window.opener |
|
window.focus(); |
|
winName.document.dataForm.newdir.value = "$newdirname" |
|
setTimeout("self.close()",10000) |
|
} |
|
</script> |
|
</head>|); |
|
my $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('<h3>Location: '.&display($fn).'</h3>'); |
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>'); |
|
|
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) { |
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) { |
$r->print('<h3><font color="red">Co-Author: '.$uname.' at '.$udom. |
$r->print('<h3><font color="red">'.&mt('Co-Author').': '.$uname.' at '.$udom. |
'</font></h3>'); |
'</font></h3>'); |
} |
} |
|
|
Line 1173 sub handler {
|
Line 1251 sub handler {
|
&Debug($r, "loncfile::handler Form action is $ENV{'form.action'} "); |
&Debug($r, "loncfile::handler Form action is $ENV{'form.action'} "); |
if ($ENV{'form.action'} eq 'delete') { |
if ($ENV{'form.action'} eq 'delete') { |
|
|
$r->print('<h3>Delete</h3>'); |
$r->print('<h3>'.&mt('Delete').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'rename') { |
} elsif ($ENV{'form.action'} eq 'rename') { |
$r->print('<h3>Rename</h3>'); |
$r->print('<h3>'.&mt('Rename').'</h3>'); |
|
} elsif ($ENV{'form.action'} eq 'move') { |
|
$r->print('<h3>'.&mt('Move').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
$r->print('<h3>New Directory</h3>'); |
$r->print('<h3>'.&mt('New Directory').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'decompress') { |
} elsif ($ENV{'form.action'} eq 'decompress') { |
$r->print('<h3>Decompress</h3>'); |
$r->print('<h3>'.&mt('Decompress').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
$r->print('<h3>Copy</h3>'); |
$r->print('<h3>'.&mt('Copy').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'newfile' || |
} elsif ($ENV{'form.action'} eq 'newfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
Line 1190 sub handler {
|
Line 1270 sub handler {
|
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
$ENV{'form.action'} eq 'Select Action' ) { |
$ENV{'form.action'} eq 'Select Action' ) { |
$r->print('<h3>New Resource</h3>'); |
$r->print('<h3>'.&mt('New Resource').'</h3>'); |
} else { |
} else { |
$r->print('<p>Unknown Action '.$ENV{'form.action'}.' </p></body></html>'); |
$r->print('<p>'.&mt('Unknown Action').' '.$ENV{'form.action'}.' </p></body></html>'); |
return OK; |
return OK; |
} |
} |
if ($ENV{'form.phase'} eq 'two') { |
if ($ENV{'form.phase'} eq 'two') { |