Bug 9827: remove 'insecure' system preference
[koha.git] / C4 / UploadedFile.pm
index dbf192e..b7bcd37 100644 (file)
@@ -14,11 +14,12 @@ package C4::UploadedFile;
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
 
 use strict;
+#use warnings; FIXME - Bug 2505
 use C4::Context;
 use C4::Auth qw/get_session/;
 use IO::File;
 use C4::Context;
 use C4::Auth qw/get_session/;
 use IO::File;
@@ -27,7 +28,7 @@ use vars qw($VERSION);
 
 BEGIN {
        # set the version for version checking
 
 BEGIN {
        # set the version for version checking
-       $VERSION = 3.00;
+    $VERSION = 3.07.00.049;
 }
 
 =head1 NAME
 }
 
 =head1 NAME
@@ -37,26 +38,23 @@ for later processing.
 
 =head1 SYNOPSIS
 
 
 =head1 SYNOPSIS
 
-=over 4
-
-# create and store data
-my $uploaded_file = C4::UploadedFile->new($sessionID);
-my $fileID = $uploaded_file->id();
-$uploaded_file->name('c:\temp\file.mrc');
-$uploaded_file->max_size(1024);
-while ($have_more_data) {
+ # create and store data
+ my $uploaded_file = C4::UploadedFile->new($sessionID);
+ my $fileID = $uploaded_file->id();
+ $uploaded_file->name('c:\temp\file.mrc');
+ $uploaded_file->max_size(1024);
+ while ($have_more_data) {
     $uploaded_file->stash($data, $bytes_read);
     $uploaded_file->stash($data, $bytes_read);
-}
-$uploaded_file->done();
+ }
+ $uploaded_file->done();
 
 
-# check status of current file upload
-my $progress = C4::UploadedFile->upload_progress($sessionID);
+ # check status of current file upload
+ my $progress = C4::UploadedFile->upload_progress($sessionID);
 
 
-# get file handle for reading uploaded file
-my $uploaded_file = C4::UploadedFile->fetch($fileID);
-my $fh = $uploaded_file->fh();
+ # get file handle for reading uploaded file
+ my $uploaded_file = C4::UploadedFile->fetch($fileID);
+ my $fh = $uploaded_file->fh();
 
 
-=back
 
 Stores files uploaded by the user from their web browser.  The
 uploaded files are temporary and at present are not guaranteed
 
 Stores files uploaded by the user from their web browser.  The
 uploaded files are temporary and at present are not guaranteed
@@ -75,11 +73,7 @@ TODO: implement secure persistant storage of uploaded files.
 
 =head2 new
 
 
 =head2 new
 
-=over 4
-
-my $uploaded_file = C4::UploadedFile->new($sessionID);
-
-=back
+  my $uploaded_file = C4::UploadedFile->new($sessionID);
 
 Creates a new object to represent the uploaded file.  Requires
 the current session ID.
 
 Creates a new object to represent the uploaded file.  Requires
 the current session ID.
@@ -137,11 +131,7 @@ sub _serialize {
 
 =head2 id
 
 
 =head2 id
 
-=over 4
-
-my $fileID = $uploaded_file->id();
-
-=back
+  my $fileID = $uploaded_file->id();
 
 =cut
 
 
 =cut
 
@@ -152,12 +142,8 @@ sub id {
 
 =head2 name
 
 
 =head2 name
 
-=over 4
-
-my $name = $uploaded_file->name();
-$uploaded_file->name($name);
-
-=back
+  my $name = $uploaded_file->name();
+  $uploaded_file->name($name);
 
 Accessor method for the name by which the file is to be known.
 
 
 Accessor method for the name by which the file is to be known.
 
@@ -173,14 +159,28 @@ sub name {
     }
 }
 
     }
 }
 
-=head2 max_size
+=head2 filename
 
 
-=over 4
+  my $filename = $uploaded_file->filename();
 
 
-my $max_size = $uploaded_file->max_size();
-$uploaded_file->max_size($max_size);
+Accessor method for the name by which the file is to be known.
 
 
-=back
+=cut
+
+sub filename {
+    my $self = shift;
+    if (@_) {
+        $self->{'tmp_file_name'} = shift;
+        $self->_serialize();
+    } else {
+        return $self->{'tmp_file_name'};
+    }
+}
+
+=head2 max_size
+
+  my $max_size = $uploaded_file->max_size();
+  $uploaded_file->max_size($max_size);
 
 Accessor method for the maximum size of the uploaded file.
 
 
 Accessor method for the maximum size of the uploaded file.
 
@@ -193,11 +193,7 @@ sub max_size {
 
 =head2 stash
 
 
 =head2 stash
 
-=over 4
-
-$uploaded_file->stash($dataref, $bytes_read);
-
-=back
+  $uploaded_file->stash($dataref, $bytes_read);
 
 Write C<$dataref> to the temporary file.  C<$bytes_read> represents
 the number of bytes (out of C<$max_size>) transmitted so far.
 
 Write C<$dataref> to the temporary file.  C<$bytes_read> represents
 the number of bytes (out of C<$max_size>) transmitted so far.
@@ -221,11 +217,7 @@ sub stash {
 
 =head2 done
 
 
 =head2 done
 
-=over 4
-
-$uploaded_file->done();
-
-=back
+  $uploaded_file->done();
 
 Indicates that all of the bytes have been uploaded.
 
 
 Indicates that all of the bytes have been uploaded.
 
@@ -240,11 +232,7 @@ sub done {
 
 =head2 upload_progress
 
 
 =head2 upload_progress
 
-=over 4
-
-my $upload_progress = C4::UploadFile->upload_progress($sessionID);
-
-=back
+  my $upload_progress = C4::UploadFile->upload_progress($sessionID);
 
 Returns (as an integer from 0 to 100) the percentage
 progress of the current file upload.
 
 Returns (as an integer from 0 to 100) the percentage
 progress of the current file upload.
@@ -275,11 +263,7 @@ sub upload_progress {
 
 =head2 fetch
 
 
 =head2 fetch
 
-=over 4
-
-    my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID);
-
-=back
+  my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID);
 
 Retrieves an uploaded file object from the current session.
 
 
 Retrieves an uploaded file object from the current session.
 
@@ -302,11 +286,7 @@ sub fetch {
 
 =head2 fh
 
 
 =head2 fh
 
-=over
-
-my $fh = $uploaded_file->fh();
-
-=back
+  my $fh = $uploaded_file->fh();
 
 Returns an IO::File handle to read the uploaded file.
 
 
 Returns an IO::File handle to read the uploaded file.
 
@@ -322,7 +302,7 @@ __END__
 
 =head1 AUTHOR
 
 
 =head1 AUTHOR
 
-Koha Development Team <info@koha.org>
+Koha Development Team <http://koha-community.org/>
 
 Galen Charlton <galen.charlton@liblime.com>
 
 
 Galen Charlton <galen.charlton@liblime.com>