Bugzilla – Attachment 84525 Details for
Bug 20208
Custom file upload paths
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20208: Development - Peddie School - Custom file upload paths
Bug-20208-Development---Peddie-School---Custom-fil.patch (text/plain), 6.45 KB, created by
Devinim
on 2019-01-30 14:34:45 UTC
(
hide
)
Description:
Bug 20208: Development - Peddie School - Custom file upload paths
Filename:
MIME Type:
Creator:
Devinim
Created:
2019-01-30 14:34:45 UTC
Size:
6.45 KB
patch
obsolete
>From 18ac0af8013188cc1af92f2f146e071fe817e050 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Nazl=C4=B1=20=C3=87etin?= <nazli@devinim.com.tr> >Date: Wed, 30 Jan 2019 14:34:12 +0000 >Subject: [PATCH] Bug 20208: Development - Peddie School - Custom file upload > paths > >--- > Koha/UploadedFiles.pm | 15 +++++++++- > installer/data/mysql/atomicupdate/bug_20208.perl | 3 ++ > .../intranet-tmpl/prog/en/modules/tools/upload.tt | 35 ++++++++++++++++++++-- > tools/upload-file.pl | 4 +-- > tools/upload.pl | 1 + > 5 files changed, 52 insertions(+), 6 deletions(-) > >diff --git a/Koha/UploadedFiles.pm b/Koha/UploadedFiles.pm >index b6804f299b..3e88247c9c 100644 >--- a/Koha/UploadedFiles.pm >+++ b/Koha/UploadedFiles.pm >@@ -159,7 +159,8 @@ sub search_term { > } > return $self->search( > [ { filename => { like => '%'.$term.'%' }, %public }, >- { hashvalue => { like => '%'.$params->{term}.'%' }, %public } ], >+ { hashvalue => { like => '%'.$params->{term}.'%' }, %public }, >+ { dir => { like => '%'.$params->{term}.'%' }, %public } ], > { order_by => { -asc => 'id' }}, > ); > } >@@ -178,6 +179,18 @@ sub getCategories { > [ map {{ code => $_->{authorised_value}, name => $_->{lib} }} @$cats ]; > } > >+=head3 getPaths >+ >+getPaths returns a list of upload path codes and names >+ >+=cut >+ >+sub getPaths { >+ my ( $class ) = @_; >+ my $cats = C4::Koha::GetAuthorisedValues('UPLOAD_PATH'); >+ [ map {{ code => $_->{authorised_value}, name => $_->{lib} }} @$cats ]; >+} >+ > =head3 _type > > Returns name of corresponding DBIC resultset >diff --git a/installer/data/mysql/atomicupdate/bug_20208.perl b/installer/data/mysql/atomicupdate/bug_20208.perl >index 00e750ef41..5d82ae61c6 100644 >--- a/installer/data/mysql/atomicupdate/bug_20208.perl >+++ b/installer/data/mysql/atomicupdate/bug_20208.perl >@@ -9,6 +9,9 @@ if( CheckVersion( $DBversion ) ) { > }); > $dbh->do("ALTER TABLE `uploaded_files` MODIFY COLUMN `dir` mediumtext DEFAULT NULL"); > } >+ $dbh->do(q{ >+ INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('UPLOAD_PATH') >+ }); > SetVersion( $DBversion ); > print "Upgrade to $DBversion done (Bug 20208 - Development - Peddie School - Custom file upload paths)\n"; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >index 443e25b4b6..ef7d2f092c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt >@@ -48,6 +48,26 @@ > <input type="file" id="fileToUpload" name="fileToUpload" multiple/> > </div> > </li> >+ <li> >+ <label for="fileChecksum">Add file checksum to the uploaded filename: </label> >+ <label class="radio"> >+ Yes<input type="radio" name="checksum" id="checksum" value="1" checked /> >+ No<input type="radio" name="checksum" id="checksum" value="0" /> >+ </label> >+ </li> >+ [% IF uploadpaths %] >+ <li> >+ <label for="uploadpath">Upload Path: </label> >+ <select id="uploadpath" name="uploadpath"> >+ [% IF !plugin %] >+ <option value=""></option> >+ [% END %] >+ [% FOREACH dir IN uploadpaths %] >+ <option value="[% dir.code | html %]">[% dir.name | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ [% END %] > [% IF uploadcategories %] > <li> > <label for="uploadcategory">Category: </label> >@@ -156,7 +176,9 @@ > <tr> > <th>Filename</th> > <th>Size</th> >+ <th>File checksum</th> > <th>Hashvalue</th> >+ <th>Upload path</th> > <th>Category</th> > [% IF !plugin %]<th>Public</th>[% END %] > [% IF !plugin %]<th>Temporary</th>[% END %] >@@ -168,7 +190,9 @@ > <tr> > <td>[% record.filename | html %]</td> > <td>[% record.filesize | html %]</td> >+ <td>[% IF record.checksum %]Yes[% ELSE %]No[% END %]</td> > <td>[% record.hashvalue | html %]</td> >+ <td>[% record.dir | html %]</td> > <td>[% record.uploadcategorycode | html %]</td> > [% IF !plugin %] > <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td> >@@ -271,16 +295,21 @@ > $("#searchfile").hide(); > $("#lastbreadcrumb").text( _("Add a new upload") ); > >- var cat, xtra=''; >+ var dir, cat, xtra=''; > if( $("#uploadcategory").val() ) > cat = encodeURIComponent( $("#uploadcategory").val() ); > if( cat ) xtra= 'category=' + cat + '&'; >+ > [% IF plugin %] >- xtra = xtra + 'public=1&temp=0'; >+ xtra = xtra + 'public=1&temp=0&'; > [% ELSE %] > if( !cat ) xtra = 'temp=1&'; >- if( $('#public').prop('checked') ) xtra = xtra + 'public=1'; >+ if( $('#public').prop('checked') ) xtra = xtra + 'public=1&'; > [% END %] >+ if( $("#uploadpath").val() ) >+ dir = encodeURIComponent( $("#uploadpath").val() ); >+ if( dir ) xtra= xtra + 'dir=' + dir + '&'; >+ xtra = xtra + 'checksum=' + $('#checksum:checked').val(); > xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload ); > } > function CancelUpload() { >diff --git a/tools/upload-file.pl b/tools/upload-file.pl >index 86ef2c5dc2..3448be02be 100755 >--- a/tools/upload-file.pl >+++ b/tools/upload-file.pl >@@ -75,8 +75,8 @@ sub upload_pars { # this sub parses QUERY_STRING in order to build the > $qstr = Encode::decode_utf8( uri_unescape( $qstr ) ); > # category could include a utf8 character > my $rv = {}; >- foreach my $p ( qw[public category temp] ) { >- if( $qstr =~ /(^|&)$p=(\w+)(&|$)/ ) { >+ foreach my $p ( qw[public category temp checksum dir] ) { >+ if( $qstr =~ /(^|&)$p=([\w\/\_]*)(&|$)/ ) { > $rv->{$p} = $2; > } > } >diff --git a/tools/upload.pl b/tools/upload.pl >index afb7c516f9..f35e6d9cbd 100755 >--- a/tools/upload.pl >+++ b/tools/upload.pl >@@ -51,6 +51,7 @@ $template->param( > owner => $loggedinuser, > plugin => $plugin, > uploadcategories => Koha::UploadedFiles->getCategories, >+ uploadpaths => Koha::UploadedFiles->getPaths, > ); > > if ( $op eq 'new' ) { >-- >2.11.0
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 20208
:
84524
|
84525
|
89954