Bug 32030: ERM - Add eHoldings home page
[koha-ffzg.git] / tools / upload-file.pl
index b410934..125e7cb 100755 (executable)
@@ -23,12 +23,11 @@ use CGI qw ( -utf8 );
 use CGI::Cookie;
 use Encode;
 use JSON;
-use URI::Escape;
+use URI::Escape qw( uri_unescape );
 
 use C4::Context;
-use C4::Auth qw/check_cookie_auth haspermission/;
-use Koha::Upload;
-use Koha::Schema::Result::UploadedFile;
+use C4::Auth qw( check_cookie_auth get_session );
+use Koha::Uploader;
 
 # upload-file.pl must authenticate the user
 # before processing the POST request,
@@ -40,16 +39,16 @@ use Koha::Schema::Result::UploadedFile;
 
 my %cookies = CGI::Cookie->fetch;
 my $sid = $cookies{'CGISESSID'}->value;
-my ( $auth_status, $sessionID ) = check_cookie_auth( $sid );
+my ( $auth_status ) = check_cookie_auth( $sid );
 my $uid = C4::Auth::get_session($sid)->param('id');
-my $allowed = Koha::Schema::Result::UploadedFile->allows_add_by( $uid );
+my $allowed = Koha::Uploader->allows_add_by( $uid );
 
 if( $auth_status ne 'ok' || !$allowed ) {
     send_reply( 'denied' );
     exit 0;
 }
 
-my $upload = Koha::Upload->new( upload_pars($ENV{QUERY_STRING}) );
+my $upload = Koha::Uploader->new( upload_pars($ENV{QUERY_STRING}) );
 if( !$upload || !$upload->cgi || !$upload->count ) {
     # not one upload succeeded
     send_reply( 'failed', undef, $upload? $upload->err: undef );
@@ -71,7 +70,7 @@ sub send_reply {    # response will be sent back as JSON
 }
 
 sub upload_pars { # this sub parses QUERY_STRING in order to build the
-                  # parameter hash for Koha::Upload
+                  # parameter hash for Koha::Uploader
     my ( $qstr ) = @_;
     $qstr = Encode::decode_utf8( uri_unescape( $qstr ) );
     # category could include a utf8 character