Bugzilla – Attachment 59349 Details for
Bug 17501
Koha Objects for uploaded files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17501: Rename Upload to Uploader
Bug-17501-Rename-Upload-to-Uploader.patch (text/plain), 7.01 KB, created by
Jonathan Druart
on 2017-01-20 11:40:54 UTC
(
hide
)
Description:
Bug 17501: Rename Upload to Uploader
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-20 11:40:54 UTC
Size:
7.01 KB
patch
obsolete
>From 55bb79ac5a56e2c47a504d84f83c3f2bccea8305 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 24 Nov 2016 10:02:19 +0100 >Subject: [PATCH] Bug 17501: Rename Upload to Uploader > >Why? Koha::Uploader now only contains the actual CGI upload. The new name >better reflects its handler status. >Pragmatically, the difference between Uploaded and Uploader makes it >easier to specifically search for them in the codebase. > >Test plan: >[1] Run t/db_dependent/Upload.t. >[2] Add an upload via the interface. >[3] Check the code: > git grep "Koha::Upload;" > git grep "Koha::Upload\->" > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/{Upload.pm => Uploader.pm} | 8 ++++---- > t/db_dependent/Upload.t | 22 +++++++++++----------- > tools/upload-file.pl | 8 ++++---- > 3 files changed, 19 insertions(+), 19 deletions(-) > rename Koha/{Upload.pm => Uploader.pm} (97%) > >diff --git a/Koha/Upload.pm b/Koha/Uploader.pm >similarity index 97% >rename from Koha/Upload.pm >rename to Koha/Uploader.pm >index 9879fa1..844c166 100644 >--- a/Koha/Upload.pm >+++ b/Koha/Uploader.pm >@@ -1,4 +1,4 @@ >-package Koha::Upload; >+package Koha::Uploader; > > # Copyright 2007 LibLime, Galen Charlton > # Copyright 2011-2012 BibLibre >@@ -21,17 +21,17 @@ package Koha::Upload; > > =head1 NAME > >-Koha::Upload - Facilitate file uploads (temporary and permanent) >+Koha::Uploader - Facilitate file uploads (temporary and permanent) > > =head1 SYNOPSIS > >- use Koha::Upload; >+ use Koha::Uploader; > use Koha::UploadedFile; > use Koha::UploadedFiles; > > # add an upload (see tools/upload-file.pl) > # the public flag allows retrieval via OPAC >- my $upload = Koha::Upload->new( public => 1, category => 'A' ); >+ my $upload = Koha::Uploader->new( public => 1, category => 'A' ); > my $cgi = $upload->cgi; > # Do something with $upload->count, $upload->result or $upload->err > >diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t >index b6fc223..49ec239 100644 >--- a/t/db_dependent/Upload.t >+++ b/t/db_dependent/Upload.t >@@ -10,9 +10,9 @@ use t::lib::TestBuilder; > > use C4::Context; > use Koha::Database; >-use Koha::Upload; > use Koha::UploadedFile; > use Koha::UploadedFiles; >+use Koha::Uploader; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -95,7 +95,7 @@ sub test01 { > is( Koha::UploadedFile->temporary_directory, $tempdir, > 'Check temporary directory' ); > >- my $upl = Koha::Upload->new({ >+ my $upl = Koha::Uploader->new({ > category => $uploads->[$current_upload]->[0]->{cat}, > }); > my $cgi= $upl->cgi; >@@ -118,7 +118,7 @@ sub test01 { > } > > sub test02 { >- my $upl = Koha::Upload->new({ >+ my $upl = Koha::Uploader->new({ > category => $uploads->[$current_upload]->[0]->{cat}, > public => 1, > }); >@@ -138,7 +138,7 @@ sub test02 { > } > > sub test03 { >- my $upl = Koha::Upload->new({ tmp => 1 }); #temporary >+ my $upl = Koha::Uploader->new({ tmp => 1 }); #temporary > my $cgi= $upl->cgi; > is( $upl->count, 1, 'Upload 3 includes one temporary file' ); > my $rec = Koha::UploadedFiles->find( $upl->result ); >@@ -146,7 +146,7 @@ sub test03 { > } > > sub test04 { # Fail on a file already there >- my $upl = Koha::Upload->new({ >+ my $upl = Koha::Uploader->new({ > category => $uploads->[$current_upload]->[0]->{cat}, > }); > my $cgi= $upl->cgi; >@@ -157,7 +157,7 @@ sub test04 { # Fail on a file already there > } > > sub test05 { # add temporary file with same name and contents, delete it >- my $upl = Koha::Upload->new({ tmp => 1 }); >+ my $upl = Koha::Uploader->new({ tmp => 1 }); > my $cgi= $upl->cgi; > is( $upl->count, 1, 'Upload 5 adds duplicate temporary file' ); > my $id = $upl->result; >@@ -171,7 +171,7 @@ sub test05 { # add temporary file with same name and contents, delete it > > # testing delete via UploadedFile (singular) > # Note that find returns a Koha::Object >- $upl = Koha::Upload->new({ tmp => 1 }); >+ $upl = Koha::Uploader->new({ tmp => 1 }); > $upl->cgi; > my $kohaobj = Koha::UploadedFiles->find( $upl->result ); > my $name = $kohaobj->filename; >@@ -208,19 +208,19 @@ sub test08 { # allows_add_by > value => { flags => 0 }, #no permissions > }); > my $patronid = $patron->{borrowernumber}; >- is( Koha::Upload->allows_add_by( $patron->{userid} ), >+ is( Koha::Uploader->allows_add_by( $patron->{userid} ), > undef, 'Patron is not allowed to do anything' ); > > # add some permissions: edit_catalogue > my $fl = 2**9; # edit_catalogue > $schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); >- is( Koha::Upload->allows_add_by( $patron->{userid} ), >+ is( Koha::Uploader->allows_add_by( $patron->{userid} ), > undef, 'Patron is still not allowed to add uploaded files' ); > > # replace flags by all tools > $fl = 2**13; # tools > $schema->resultset('Borrower')->find( $patronid )->update({ flags => $fl }); >- is( Koha::Upload->allows_add_by( $patron->{userid} ), >+ is( Koha::Uploader->allows_add_by( $patron->{userid} ), > 1, 'Patron should be allowed now to add uploaded files' ); > > # remove all tools and add upload_general_files only >@@ -234,7 +234,7 @@ sub test08 { # allows_add_by > code => 'upload_general_files', > }, > }); >- is( Koha::Upload->allows_add_by( $patron->{userid} ), >+ is( Koha::Uploader->allows_add_by( $patron->{userid} ), > 1, 'Patron is still allowed to add uploaded files' ); > } > >diff --git a/tools/upload-file.pl b/tools/upload-file.pl >index a64ce28..86ef2c5 100755 >--- a/tools/upload-file.pl >+++ b/tools/upload-file.pl >@@ -27,7 +27,7 @@ use URI::Escape; > > use C4::Context; > use C4::Auth qw/check_cookie_auth haspermission/; >-use Koha::Upload; >+use Koha::Uploader; > > # upload-file.pl must authenticate the user > # before processing the POST request, >@@ -41,14 +41,14 @@ my %cookies = CGI::Cookie->fetch; > my $sid = $cookies{'CGISESSID'}->value; > my ( $auth_status, $sessionID ) = check_cookie_auth( $sid ); > my $uid = C4::Auth::get_session($sid)->param('id'); >-my $allowed = Koha::Upload->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 ); >@@ -70,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 >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17501
:
57751
|
57752
|
57753
|
57754
|
57755
|
57756
|
57757
|
57758
|
57759
|
58613
|
58614
|
58615
|
58616
|
58617
|
58618
|
58619
|
58620
|
58621
|
58809
|
59342
|
59343
|
59344
|
59345
|
59346
|
59347
|
59348
| 59349 |
59350
|
59351