Bugzilla – Attachment 38929 Details for
Bug 6874
Attach files to bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6874: Move uploadPath syspref to koha-conf.xml
Bug-6874-Move-uploadPath-syspref-to-koha-confxml.patch (text/plain), 10.58 KB, created by
Mark Tompsett
on 2015-05-06 21:22:05 UTC
(
hide
)
Description:
Bug 6874: Move uploadPath syspref to koha-conf.xml
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-05-06 21:22:05 UTC
Size:
10.58 KB
patch
obsolete
>From 4f9c6c4d284030ae0c489987f54848382b95f6e0 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 12 Jun 2013 13:12:51 +0000 >Subject: [PATCH] Bug 6874: Move uploadPath syspref to koha-conf.xml > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > C4/UploadedFiles.pm | 6 ++-- > cataloguing/value_builder/upload.pl | 38 ++++++++++++---------- > etc/koha-conf.xml | 1 + > installer/data/mysql/sysprefs.sql | 1 - > installer/data/mysql/updatedatabase.pl | 9 ++--- > .../en/modules/admin/preferences/cataloguing.pref | 4 --- > .../en/modules/cataloguing/value_builder/upload.tt | 24 +++++++++----- > t/db_dependent/UploadedFiles.t | 8 ++--- > 8 files changed, 45 insertions(+), 46 deletions(-) > >diff --git a/C4/UploadedFiles.pm b/C4/UploadedFiles.pm >index 1574e99..1d72015 100644 >--- a/C4/UploadedFiles.pm >+++ b/C4/UploadedFiles.pm >@@ -61,7 +61,7 @@ use C4::Context; > sub _get_file_path { > my ($id, $dirname, $filename) = @_; > >- my $uploadPath = C4::Context->preference('uploadPath'); >+ my $uploadPath = C4::Context->config('uploadPath'); > my $filepath = "$uploadPath/$dirname/${id}_$filename"; > $filepath =~ s|/+|/|g; > >@@ -81,7 +81,7 @@ Hash keys are: > > =item * filename: name of the file > >-=item * dir: directory where file is stored (relative to syspref 'uploadPath') >+=item * dir: directory where file is stored (relative to config variable 'uploadPath') > > =back > >@@ -123,7 +123,7 @@ Parameters: > > =item * $filename: name of the file > >-=item * $dir: directory where to store the file (path relative to syspref 'uploadPath' >+=item * $dir: directory where to store the file (path relative to config variable 'uploadPath' > > =item * $io_handle: valid IO::Handle object, can be retrieved with > $cgi->upload('uploaded_file')->handle; >diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl >index 7eb15e5..f415464 100755 >--- a/cataloguing/value_builder/upload.pl >+++ b/cataloguing/value_builder/upload.pl >@@ -108,22 +108,26 @@ sub plugin { > } > } > } else { >- my $filefield = CGI::filefield( >- -name => 'uploaded_file', >- -size => 50, >- ); >- >- my $upload_path = C4::Context->preference('uploadPath'); >- my $dirs_tree = [ { >- name => '/', >- value => '/', >- dirs => finddirs($upload_path) >- } ]; >- >- $template->param( >- dirs_tree => $dirs_tree, >- filefield => $filefield >- ); >+ my $upload_path = C4::Context->config('uploadPath'); >+ if ($upload_path) { >+ my $filefield = CGI::filefield( >+ -name => 'uploaded_file', >+ -size => 50, >+ ); >+ >+ my $dirs_tree = [ { >+ name => '/', >+ value => '/', >+ dirs => finddirs($upload_path) >+ } ]; >+ >+ $template->param( >+ dirs_tree => $dirs_tree, >+ filefield => $filefield >+ ); >+ } else { >+ $template->param( error_upload_path_not_configured => 1 ); >+ } > } > > $template->param( >@@ -137,7 +141,7 @@ sub plugin { > # Build a hierarchy of directories > sub finddirs { > my $base = shift; >- my $upload_path = C4::Context->preference('uploadPath'); >+ my $upload_path = C4::Context->config('uploadPath'); > my $found = 0; > my @dirs; > my @files = glob("$base/*"); >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index 289d51d..77d0e6d 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -88,6 +88,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > <authorityservershadow>1</authorityservershadow> > <pluginsdir>__PLUGINS_DIR__</pluginsdir> > <enable_plugins>0</enable_plugins> >+ <uploadPath></uploadPath> > <intranetdir>__INTRANET_CGI_DIR__</intranetdir> > <opacdir>__OPAC_CGI_DIR__/opac</opacdir> > <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs> >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index ea096f3..9fc5c83 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -447,7 +447,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('UniqueItemFields','barcode','','Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'), > ('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), > ('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'), >-('uploadPath','',NULL,'Sets the upload path for the upload.pl plugin. For security reasons, the upload path MUST NOT be a public, webserver accessible directory.','Free') > ('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'), > ('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'), > ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 992926f..68d81c0 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -10416,11 +10416,6 @@ if ( CheckVersion($DBversion) ) { > $DBversion = "XXX"; > if ( CheckVersion($DBversion) ) { > $dbh->do(" >- INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) >- VALUES('uploadPath','','Sets the upload path for the upload.pl plugin','',''); >- "); >- >- $dbh->do(" > CREATE TABLE uploaded_files ( > id CHAR(40) NOT NULL PRIMARY KEY, > filename TEXT NOT NULL, >@@ -10429,8 +10424,8 @@ if ( CheckVersion($DBversion) ) { > "); > > print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n"; >- print "This plugin comes with a new syspref (uploadPath) and a new table (uploaded_files)\n"; >- print "To use it, set 'uploadPath' and 'OPACBaseURL' system preferences and link this plugin to a subfield (856\$u for instance)\n"; >+ print "This plugin comes with a new config variable (uploadPath) and a new table (uploaded_files)\n"; >+ print "To use it, set 'uploadPath' config variable and 'OPACBaseURL' system preference and link this plugin to a subfield (856\$u for instance)\n"; > SetVersion($DBversion); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index e8ddf3c..bc35aad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -125,10 +125,6 @@ Cataloging: > - 'MARC21: "952$a 952$b 952$c"' > - Note that the FA framework is excluded from the permission. > - If the pref is empty, no fields are restricted. >- - >- - Absolute path where to store files uploaded in MARC record (plugin upload.pl) >- - pref: uploadPath >- class: multi > Display: > - > - 'Separate multiple displayed authors, series or subjects with ' >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >index da40360..10f64f1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >@@ -54,15 +54,21 @@ > [% END %] > [% END %] > >- <h2>Please select the file to upload : </h2> >- <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >- [% filefield %] >- <h3>Choose where to upload file</h3> >- [% INCLUDE list_dirs dirs = dirs_tree %] >- <input type="hidden" name="plugin_name" value="upload.pl" /> >- <input type="hidden" name="index" value="[% index %]" /> >- <input type="submit"> >- </form> >+ [% IF (error_upload_path_not_configured) %] >+ <h2>Configuration error</h2> >+ <p>Configuration variable 'uploadPath' is not configured.</p> >+ <p>Please configure it in your koha-conf.xml</p> >+ [% ELSE %] >+ <h2>Please select the file to upload : </h2> >+ <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >+ [% filefield %] >+ <h3>Choose where to upload file</h3> >+ [% INCLUDE list_dirs dirs = dirs_tree %] >+ <input type="hidden" name="plugin_name" value="upload.pl" /> >+ <input type="hidden" name="index" value="[% index %]" /> >+ <input type="submit"> >+ </form> >+ [% END %] > [% END %] > > [% END %] >diff --git a/t/db_dependent/UploadedFiles.t b/t/db_dependent/UploadedFiles.t >index 36605d2..d829dee 100644 >--- a/t/db_dependent/UploadedFiles.t >+++ b/t/db_dependent/UploadedFiles.t >@@ -5,6 +5,8 @@ use File::Temp qw/ tempdir /; > use Test::CGI::Multipart; > use Test::More tests => 11; > >+use t::lib::Mocks; >+ > use C4::Context; > use C4::UploadedFiles; > >@@ -17,10 +19,8 @@ $tcm->upload_file( > ); > my $cgi = $tcm->create_cgi; > >-# Save the value of uploadPath and set it to a temporary directory >-my $uploadPath = C4::Context->preference('uploadPath'); > my $tempdir = tempdir(CLEANUP => 1); >-C4::Context->set_preference('uploadPath', $tempdir); >+t::lib::Mocks::mock_config('uploadPath', $tempdir); > > my $testfilename = $cgi->param('testfile'); > my $testfile_fh = $cgi->upload('testfile'); >@@ -38,7 +38,5 @@ ok(-e $file->{filepath}, "File $file->{filepath} exists"); > ok(C4::UploadedFiles::DelUploadedFile($id), "DelUploadedFile($id) returned true"); > ok(! -e $file->{filepath}, "File $file->{filepath} does not exist anymore"); > >-C4::Context->set_preference('uploadPath', $uploadPath); >- > is(C4::UploadedFiles::UploadFile($testfilename, '../', $testfile_fh->handle), undef, 'UploadFile with $dir containing ".." return undef'); > is(C4::UploadedFiles::GetUploadedFile(), undef, 'GetUploadedFile without parameters returns undef'); >-- >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 6874
:
5439
|
5440
|
5764
|
7114
|
7980
|
8234
|
8468
|
10664
|
10673
|
10863
|
10982
|
11098
|
11634
|
12355
|
12356
|
12357
|
12358
|
14130
|
14131
|
14132
|
14133
|
16343
|
16354
|
16355
|
16356
|
16357
|
16370
|
16693
|
16694
|
16695
|
16696
|
16697
|
16698
|
16699
|
16712
|
16713
|
16714
|
16715
|
16716
|
16717
|
16718
|
16719
|
17368
|
17369
|
18767
|
18768
|
18769
|
18770
|
18771
|
18772
|
18773
|
18774
|
18775
|
18776
|
18777
|
18891
|
18892
|
18893
|
18894
|
20059
|
20060
|
20779
|
21432
|
21433
|
21434
|
21435
|
21436
|
21489
|
21543
|
21546
|
21635
|
21798
|
21799
|
21800
|
21801
|
21802
|
21803
|
23588
|
23589
|
23590
|
23591
|
23607
|
23608
|
23609
|
23610
|
23611
|
23612
|
23613
|
26418
|
26419
|
26420
|
26421
|
26422
|
26423
|
26424
|
26878
|
26879
|
26880
|
26881
|
26882
|
26883
|
26884
|
27114
|
27125
|
27154
|
27155
|
27225
|
30362
|
30363
|
30364
|
30365
|
30366
|
30367
|
30368
|
30369
|
30370
|
30371
|
32384
|
32385
|
32386
|
32387
|
32388
|
32389
|
32390
|
32391
|
32392
|
32393
|
36198
|
36199
|
36200
|
36201
|
36202
|
36203
|
36204
|
36205
|
36206
|
36207
|
36208
|
36209
|
36210
|
36211
|
36213
|
36214
|
36215
|
36216
|
36217
|
36218
|
36219
|
36220
|
36221
|
36222
|
36223
|
36224
|
36225
|
36226
|
36227
|
36228
|
36229
|
36230
|
36231
|
36232
|
37681
|
37682
|
37683
|
37684
|
37685
|
37686
|
37687
|
37688
|
37689
|
37690
|
37691
|
37692
|
37693
|
37694
|
37696
|
37697
|
37698
|
37699
|
37700
|
37701
|
37702
|
37703
|
37704
|
37705
|
37706
|
38911
|
38912
|
38913
|
38914
|
38915
|
38916
|
38917
|
38918
|
38919
|
38920
|
38921
|
38922
|
38923
|
38924
|
38925
|
38926
|
38927
|
38928
|
38929
|
38930
|
38931
|
38932
|
38933
|
38934
|
38935
|
38936
|
39113
|
39114
|
39115
|
39116
|
39117
|
39118
|
39119
|
39120
|
39121
|
39122
|
39123
|
39626
|
39627
|
39628
|
39629
|
39630
|
39631
|
39632
|
39633
|
39634
|
39635
|
39636
|
39637
|
39638
|
41275
|
41276
|
41277
|
41278
|
41279
|
41280
|
41281
|
41282
|
41283
|
41284
|
41285
|
41286
|
41287
|
41288
|
41448
|
41449
|
41450
|
41783