[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm
raeburn
raeburn at source.lon-capa.org
Fri Jul 14 19:20:15 EDT 2023
raeburn Fri Jul 14 23:20:15 2023 EDT
Modified files:
/loncom/publisher loncfile.pm
Log:
- Remove trailing whitespace. No code changes.
-------------- next part --------------
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.126 loncom/publisher/loncfile.pm:1.127
--- loncom/publisher/loncfile.pm:1.126 Fri Jul 14 14:32:57 2023
+++ loncom/publisher/loncfile.pm Fri Jul 14 23:20:15 2023
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.126 2023/07/14 14:32:57 raeburn Exp $
+# $Id: loncfile.pm,v 1.127 2023/07/14 23:20:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,13 +40,13 @@
Apache::loncfile - Authoring space file management.
=head1 SYNOPSIS
-
- Content handler for buttons on the top frame of the construction space
+
+ Content handler for buttons on the top frame of the construction space
directory.
=head1 INTRODUCTION
- loncfile is invoked when buttons in the top frame of the construction
+ loncfile is invoked when buttons in the top frame of the construction
space directory listing are clicked. All operations proceed in two phases.
The first phase describes to the user exactly what will be done. If the user
confirms the operation, the second phase commits the operation and indicates
@@ -88,13 +88,13 @@
Parameters:
=over 4
-
+
=item $request - The current request operation.
=item $message - The message to put in the log file.
=back
-
+
Returns:
nothing.
@@ -125,7 +125,7 @@
=item URLToPath($url)
Convert a URL to a file system path.
-
+
In order to manipulate the construction space objects, it is necessary
to access url identified objects a filespace objects. This function
translates a construction space URL to a file system path.
@@ -134,14 +134,14 @@
=over 4
=item Url - string [in] The url to convert.
-
+
=back
-
+
Returns:
=over 4
-=item The corresponding file system path.
+=item The corresponding file system path.
=back
@@ -210,14 +210,14 @@
# see if directory is empty
# ignores any .meta, .save, .bak, and .log files created for a previously
# published file, which has since been marked obsolete and deleted.
-# ignores a .DS_Store file put there when viewing directory via webDAV on MacOS.
+# ignores a .DS_Store file put there when viewing directory via webDAV on MacOS.
sub empty_directory {
my ($dirname,$phase) = @_;
if (opendir DIR, $dirname) {
my @files = grep(!/^\.\.?$/, readdir(DIR)); # ignore . and ..
- if (@files) {
+ if (@files) {
my @orphans = grep(/\.(meta|save|log|bak|DS_Store)$/, at files);
- if (scalar(@files) - scalar(@orphans) > 0) {
+ if (scalar(@files) - scalar(@orphans) > 0) {
return 0;
} else {
if (($phase eq 'Delete2') && (@orphans > 0)) {
@@ -269,7 +269,7 @@
=item string - Either where the resource exists as an html string that can
be embedded in a dialog or an empty string if the resource
does not exist.
-
+
=back
=cut
@@ -313,7 +313,7 @@
=pod
=item checksuffix($old, $new)
-
+
Determine if a resource filename suffix (the stuff after the .) would change
as a result of this operation.
@@ -463,7 +463,7 @@
=item $user - string [in] - Name of the user that is initiating the
request.
-=item $directory - string [in] - Directory in which the operation is
+=item $directory - string [in] - Directory in which the operation is
being done relative to the top level construction space
directory.
@@ -479,14 +479,14 @@
=pod
=item Rename1($request, $filename, $user, $domain, $dir)
-
+
Perform phase 1 processing of the file rename operation.
Parameters:
=over 4
-=item $request - Apache Request Object [in] The request object for the
+=item $request - Apache Request Object [in] The request object for the
current request.
=item $filename - The filename relative to construction space.
@@ -509,7 +509,7 @@
=back
-=cut
+=cut
sub Rename1 {
my ($request, $user, $domain, $fn, $newfilename, $style) = @_;
@@ -587,7 +587,7 @@
);
return;
}
-
+
}
=pod
@@ -601,7 +601,7 @@
=over 4
-=item $request - Apache Request Object [in] request object for the current
+=item $request - Apache Request Object [in] request object for the current
request.
=item $user - string [in] Name of the user initiating the request.
@@ -632,7 +632,7 @@
);
return;
}
- } else {
+ } else {
unless (&obsolete_unpub($user,$domain,$fn)) {
$request->print('<p><span class="LC_error">'
.&mt('Cannot delete non-obsolete published file.')
@@ -669,7 +669,7 @@
=over 4
-=item $request - Apache Request Object [in] request object for the current
+=item $request - Apache Request Object [in] request object for the current
request.
=item $user - string [in] Name of the user initiating the request.
@@ -695,7 +695,7 @@
if ($newfilename =~ m|/[^\.]+$|) {
#no extension add on original extension
if ($fn =~ m|/[^\.]*\.([^\.]+)$|) { $newfilename.='.'.$1; }
- }
+ }
$newfilename=~s://+:/:g; # remove duplicate /
while ($newfilename=~m:/\.\./:) {
$newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
@@ -740,7 +740,7 @@
=pod
=item NewDir1
-
+
Does all phase 1 processing of directory creation:
Ensures that the user provides a new directory name,
and that the directory does not already exist.
@@ -758,7 +758,7 @@
=item $fn - source file.
-=item $newdir - Name of the directory to be created; path relative to the
+=item $newdir - Name of the directory to be created; path relative to the
top level of construction space.
=back
@@ -822,7 +822,7 @@
=pod
=item NewFile1
-
+
Does all phase 1 processing of file creation:
Ensures that the user provides a new filename, adds proper extension
if needed and that the file does not already exist, if it is a html,
@@ -938,7 +938,7 @@
' '.&mt('Not Allowed').'</span>');
return;
}
- return 'ok';
+ return 'ok';
}
=pod
@@ -949,7 +949,7 @@
are returned if the request cannot be performed (e.g. attempts to manipulate
files that are nonexistent). If the operation can be performed, what is
about to be done will be presented to the user for confirmation. If the
-user confirms the request, then phase two is executed, the action
+user confirms the request, then phase two is executed, the action
performed and reported to the user.
Parameters:
@@ -958,12 +958,12 @@
=item $r - request object [in] - The Apache request being executed.
-=item $fn = string [in] - The filename being manipulated by the
+=item $fn = string [in] - The filename being manipulated by the
request.
=item $uname - string [in] Name of user logged in and doing this action.
-=item $udom - string [in] Domain name under which the user logged in.
+=item $udom - string [in] Domain name under which the user logged in.
=back
@@ -971,10 +971,10 @@
sub phaseone {
my ($r,$fn,$uname,$udom)=@_;
-
+
my $doingdir=0;
if ($env{'form.action'} eq 'newdir') { $doingdir=1; }
- my ($newfilename,$error,$warnings) =
+ my ($newfilename,$error,$warnings) =
&cleanDest($env{'form.newfilename'},$doingdir,$fn,$uname,$udom);
unless ($error) {
($newfilename,$error)=&relativeDest($fn,$newfilename,$uname,$udom);
@@ -984,7 +984,7 @@
if ($fn=~m{^(.*/)[^/]+$}) {
$dirlist=$1;
} else {
- $dirlist=$fn;
+ $dirlist=$fn;
}
if ($warnings) {
$r->print($warnings);
@@ -1029,11 +1029,11 @@
&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);
} elsif ($env{'form.action'} eq 'decompress') {
&Decompress1($r, $uname, $udom, $fn);
- } elsif ($env{'form.action'} eq 'copy') {
+ } elsif ($env{'form.action'} eq 'copy') {
if ($newfilename) {
&Copy1($r, $uname, $udom, $fn, $newfilename);
} else {
@@ -1103,7 +1103,7 @@
return 0;
}
## If old name.(extension) exits, move under new name.
- ## If it doesn't exist and a new.(extension) exists
+ ## If it doesn't exist and a new.(extension) exists
## delete it (only concern when renaming over files)
my $tmp1=$oRN.'.meta';
my $tmp2=$nRN.'.meta';
@@ -1149,7 +1149,7 @@
=item Delete2($request, $user, $filename)
- Performs phase two of a delete. The user has confirmed that they want
+ Performs phase two of a delete. The user has confirmed that they want
to delete the selected file. The file is deleted and the results of the
delete attempt are indicated.
@@ -1176,11 +1176,11 @@
sub Delete2 {
my ($request, $user, $filename) = @_;
- if (-d $filename) {
- unless (&empty_directory($filename,'Delete2')) {
- $request->print('<span class="LC_error">'.&mt('Error: Directory Non Empty').'</span>');
+ if (-d $filename) {
+ unless (&empty_directory($filename,'Delete2')) {
+ $request->print('<span class="LC_error">'.&mt('Error: Directory Non Empty').'</span>');
return 0;
- } else {
+ } else {
if(-e $filename) {
unless(rmdir($filename)) {
$request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
@@ -1209,7 +1209,7 @@
=item Copy2($request, $username, $dir, $oldfile, $newfile)
- Performs phase 2 of a copy. The file is copied and the status
+ Performs phase 2 of a copy. The file is copied and the status
of that copy is reported back to the user.
=over 4
@@ -1247,7 +1247,7 @@
} elsif (!chmod(0660, $newfile)) {
$request->print('<span class="LC_error">'.&mt('chmod error').': '.$!.'</span>');
return 0;
- } elsif (-e $oldfile.'.meta' &&
+ } elsif (-e $oldfile.'.meta' &&
!copy($oldfile.'.meta', $newfile.'.meta') &&
!chmod(0660, $newfile.'.meta')) {
$request->print('<span class="LC_error">'.&mt('copy metadata error').
@@ -1287,7 +1287,7 @@
sub NewDir2 {
my ($request, $user, $newdirectory) = @_;
-
+
unless(mkdir($newdirectory, 02770)) {
$request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
@@ -1320,7 +1320,7 @@
is performed and the result is shown.
The strategy is to break out the processing into specific action processors
- named action2 where action is the requested action and the 2 denotes
+ named action2 where action is the requested action and the 2 denotes
phase 2 processing.
Parameters:
@@ -1344,11 +1344,11 @@
sub phasetwo {
my ($r,$fn,$uname,$udom)=@_;
-
+
&Debug($r, "loncfile - Entering phase 2 for $fn");
-
+
# Break down the file into its component pieces.
-
+
my $dir; # Directory path
my $main; # Filename.
my $suffix; # Extension.
@@ -1368,13 +1368,13 @@
&Debug($r," newfilename = ".$env{'form.newfilename'});
my $conspace=$fn;
-
+
&Debug($r,"loncfile::phase2 Full construction space name: $conspace");
-
+
&Debug($r,"loncfie::phase2 action is $env{'form.action'}");
-
+
# Select the appropriate processing sub.
- if ($env{'form.action'} eq 'decompress') {
+ if ($env{'form.action'} eq 'decompress') {
$main .= '.'.$suffix;
if(!&decompress2($r, $uname, $dir, $main)) {
return ;
@@ -1385,7 +1385,7 @@
if($env{'form.newfilename'}) {
if (!defined($dir)) {
$fn=~m:^(.*)/:;
- $dir=$1;
+ $dir=$1;
}
if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
return;
@@ -1396,7 +1396,7 @@
$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'})) {
return ;
}
@@ -1404,7 +1404,7 @@
# previously held it.
#
$dest = $dir."/."; # Parent dir.
- } elsif ($env{'form.action'} eq 'copy') {
+ } elsif ($env{'form.action'} eq 'copy') {
if($env{'form.newfilename'}) {
if(!&Copy2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
return ;
@@ -1462,7 +1462,7 @@
&Debug($r, "test: $env{'form.filename'}");
$fn=&unescape($env{'form.filename'});
$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
#correct information for further processing
$fn=&unescape($env{'form.decompress'});
@@ -1473,27 +1473,27 @@
} else {
&Debug($r, "loncfile::handler - no form.filename");
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
- ' unspecified filename for cfile', $r->filename);
+ ' unspecified filename for cfile', $r->filename);
return HTTP_NOT_FOUND;
}
unless ($fn) {
&Debug($r, "loncfile::handler - doctored url is empty");
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
- ' trying to cfile non-existing file', $r->filename);
+ ' trying to cfile non-existing file', $r->filename);
return HTTP_NOT_FOUND;
- }
+ }
# ----------------------------------------------------------- Start page output
my ($uname,$udom) = &Apache::lonnet::constructaccess($fn);
- &Debug($r,
+ &Debug($r,
"loncfile::handler constructaccess uname = $uname domain = $udom");
if (($uname eq '') || ($udom eq '')) {
$r->log_reason($uname.' at '.$udom.
' trying to manipulate file '.$env{'form.filename'}.
- ' ('.$fn.') - not authorized',
- $r->filename);
+ ' ('.$fn.') - not authorized',
+ $r->filename);
return HTTP_NOT_ACCEPTABLE;
}
@@ -1553,11 +1553,11 @@
.&Apache::loncommon::head_subbox(
&Apache::loncommon::CSTR_pageheader($trailfile))
);
-
+
$r->print('<p>'.&mt('Location').': '.&display($fn).'</p>');
-
+
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- unless ($crsauthor) {
+ unless ($crsauthor) {
$r->print('<p class="LC_info">'
.&mt('Co-Author [_1]',$uname.':'.$udom)
.'</p>'
@@ -1624,7 +1624,7 @@
}
$r->print(&Apache::loncommon::end_page());
- return OK;
+ return OK;
}
1;
More information about the LON-CAPA-cvs
mailing list