Bugzilla – Attachment 20779 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]
Reconstructed attempt for the upload plugin feature.
0001-bug_6874.patch (text/plain), 45.09 KB, created by
Mark Tompsett
on 2013-09-04 15:33:15 UTC
(
hide
)
Description:
Reconstructed attempt for the upload plugin feature.
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2013-09-04 15:33:15 UTC
Size:
45.09 KB
patch
obsolete
>From a2f3fb15569bb0df2344af8f12b50ca10a69d5e2 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 21 Aug 2013 18:55:31 -0400 >Subject: [PATCH] bug_6874 > >--- > C4/Biblio.pm | 43 +++- > C4/Installer/PerlDependencies.pm | 5 + > C4/UploadedFiles.pm | 230 ++++++++++++++++++++ > basket/basket.pl | 2 +- > catalogue/detail.pl | 2 +- > cataloguing/value_builder/upload.pl | 187 ++++++++++++++++ > etc/koha-conf.xml | 1 + > installer/data/mysql/kohastructure.sql | 11 + > installer/data/mysql/updatedatabase.pl | 16 ++ > .../prog/en/modules/catalogue/MARCdetail.tt | 80 ++++++- > .../en/modules/cataloguing/value_builder/upload.tt | 77 +++++++ > .../value_builder/upload_delete_file.tt | 60 +++++ > misc/strip_value_from_tag.pl | 60 +++++ > opac/opac-basket.pl | 2 +- > opac/opac-detail.pl | 2 +- > opac/opac-retrieve-file.pl | 50 +++++ > t/db_dependent/UploadedFiles.t | 42 ++++ > 17 files changed, 845 insertions(+), 25 deletions(-) > create mode 100644 C4/UploadedFiles.pm > create mode 100755 cataloguing/value_builder/upload.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt > create mode 100755 misc/strip_value_from_tag.pl > create mode 100755 opac/opac-retrieve-file.pl > create mode 100755 t/db_dependent/UploadedFiles.t > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index e94b0eb..48119f6a2 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -37,6 +37,7 @@ use C4::ClassSource; > use C4::Charset; > use C4::Linker; > use C4::OAI::Sets; >+use C4::UploadedFiles; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -1445,13 +1446,14 @@ sub GetCOinSBiblio { > =head2 GetMarcPrice > > return the prices in accordance with the Marc format. >+ > =cut > > sub GetMarcPrice { > my ( $record, $marcflavour ) = @_; > my @listtags; > my $subfield; >- >+ > if ( $marcflavour eq "MARC21" ) { > @listtags = ('345', '020'); > $subfield="c"; >@@ -1461,7 +1463,7 @@ sub GetMarcPrice { > } else { > return; > } >- >+ > for my $field ( $record->field(@listtags) ) { > for my $subfield_value ($field->subfield($subfield)){ > #check value >@@ -1907,7 +1909,7 @@ sub GetMarcAuthors { > > =head2 GetMarcUrls > >- $marcurls = GetMarcUrls($record,$marcflavour); >+ $marcurls = GetMarcUrls($record,$marcflavour,$frameworkcode); > > Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop. > Assumes web resources (not uncommon in MARC21 to omit resource type ind) >@@ -1915,15 +1917,19 @@ Assumes web resources (not uncommon in MARC21 to omit resource type ind) > =cut > > sub GetMarcUrls { >- my ( $record, $marcflavour ) = @_; >+ my ( $record, $marcflavour, $frameworkcode ) = @_; >+ >+ my $tagslib = &GetMarcStructure(1, $frameworkcode); >+ my $urltag = '856'; >+ my $urlsubtag = 'u'; > > my @marcurls; >- for my $field ( $record->field('856') ) { >+ for my $field ( $record->field($urltag) ) { > my @notes; > for my $note ( $field->subfield('z') ) { > push @notes, { note => $note }; > } >- my @urls = $field->subfield('u'); >+ my @urls = $field->subfield($urlsubtag); > foreach my $url (@urls) { > my $marcurl; > if ( $marcflavour eq 'MARC21' ) { >@@ -1951,8 +1957,20 @@ sub GetMarcUrls { > $marcurl->{'part'} = $s3 if ($link); > $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ ); > } else { >- $marcurl->{'linktext'} = $field->subfield('2') || C4::Context->preference('URLLinkText') || $url; >- $marcurl->{'MARCURL'} = $url; >+ if ($tagslib->{ $urltag }->{ $urlsubtag }->{value_builder} eq "upload.pl" >+ and $url =~ /id=([0-9a-f]+)/) { >+ my $file = C4::UploadedFiles::GetUploadedFile($1); >+ my $text = $file ? $file->{filename} : $url; >+ $marcurl->{'linktext'} = $field->subfield('2') >+ || C4::Context->preference('URLLinkText') >+ || $file->{filename}; >+ $marcurl->{'MARCURL'} = $url; >+ } else { >+ $marcurl->{'linktext'} = $field->subfield('2') >+ || C4::Context->preference('URLLinkText') >+ || $url; >+ $marcurl->{'MARCURL'} = $url; >+ } > } > push @marcurls, $marcurl; > } >@@ -3377,7 +3395,8 @@ sub get_biblio_authorised_values { > =head2 CountBiblioInOrders > > =over 4 >-$count = &CountBiblioInOrders( $biblionumber); >+ >+=item $count = &CountBiblioInOrders( $biblionumber); > > =back > >@@ -3400,7 +3419,8 @@ sub CountBiblioInOrders { > =head2 GetSubscriptionsId > > =over 4 >-$subscriptions = &GetSubscriptionsId($biblionumber); >+ >+=item $subscriptions = &GetSubscriptionsId($biblionumber); > > =back > >@@ -3423,7 +3443,8 @@ sub GetSubscriptionsId { > =head2 GetHolds > > =over 4 >-$holds = &GetHolds($biblionumber); >+ >+=item $holds = &GetHolds($biblionumber); > > =back > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index ca220aa..782c364 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -689,6 +689,11 @@ our $PERL_DEPS = { > 'required' => '1', > 'min_ver' => '0.22', > }, >+ 'Test::CGI::Multipart' => { >+ 'usage' => 'Tests', >+ 'required' => '0', >+ 'min_ver' => '0.0.3', >+ }, > }; > > 1; >diff --git a/C4/UploadedFiles.pm b/C4/UploadedFiles.pm >new file mode 100644 >index 0000000..6e7dd7e >--- /dev/null >+++ b/C4/UploadedFiles.pm >@@ -0,0 +1,230 @@ >+package C4::UploadedFiles; >+ >+# Copyright 2011-2012 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as >+# published by the Free Software Foundation; either version 3 >+# of the License, or (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, >+# but WITHOUT ANY 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. >+# 51 Franklin Street, Fifth Floor >+# Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+C4::UploadedFiles - Functions to deal with files uploaded with >+ cataloging plugin upload.pl >+ >+=head1 SYNOPSIS >+ >+ use C4::UploadedFiles; >+ >+ my $filename = $cgi->param('uploaded_file'); >+ my $file = $cgi->upload('uploaded_file'); >+ my $dir = $input->param('dir'); >+ >+ # upload file >+ my $id = C4::UploadedFiles::UploadFile($filename, $dir, $file->handle); >+ >+ # retrieve file infos >+ my $uploaded_file = C4::UploadedFiles::GetUploadedFile($id); >+ >+ # delete file >+ C4::UploadedFiles::DelUploadedFile($id); >+ >+=head1 DESCRIPTION >+ >+This module provides basic functions for adding, retrieving >+and deleting files related to cataloging plugin upload.pl. >+ >+It uses uploaded_files table. >+ >+It is not related to C4::UploadedFile >+ >+=head1 FUNCTIONS >+ >+=cut >+ >+use Modern::Perl; >+use Digest::SHA; >+use Fcntl; >+use Encode; >+ >+use C4::Context; >+ >+sub _get_file_path { >+ my ($id, $dirname, $filename) = @_; >+ >+ my $upload_path = C4::Context->config('upload_path'); >+ my $filepath = "$upload_path/$dirname/${id}_$filename"; >+ $filepath =~ s|/+|/|g; >+ >+ return $filepath; >+} >+ >+=head2 GetUploadedFile >+ >+ my $file = C4::UploadedFiles::GetUploadedFile($id); >+ >+Returns a hashref containing infos on uploaded files. >+Hash keys are: >+ >+=over 2 >+ >+=item * id: id of the file (same as given in argument) >+ >+=item * filename: name of the file >+ >+=item * dir: directory where file is stored (relative to config variable 'upload_path') >+ >+=back >+ >+It returns undef if file is not found >+ >+=cut >+ >+sub GetUploadedFile { >+ my ($id) = @_; >+ >+ return unless $id; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT id, filename, dir >+ FROM uploaded_files >+ WHERE id = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($id); >+ my $file = $sth->fetchrow_hashref; >+ if ($file) { >+ $file->{filepath} = _get_file_path($file->{id}, $file->{dir}, >+ $file->{filename}); >+ } >+ >+ return $file; >+} >+ >+=head2 UploadFile >+ >+ my $id = C4::UploadedFiles::UploadFile($filename, $dir, $io_handle); >+ >+Upload a new file and returns its id (its SHA-1 sum, actually). >+ >+Parameters: >+ >+=over 2 >+ >+=item * $filename: name of the file >+ >+=item * $dir: directory where to store the file (path relative to config variable 'upload_path') >+ >+=item * $io_handle: valid IO::Handle object, can be retrieved with >+$cgi->upload('uploaded_file')->handle; >+ >+=back >+ >+=cut >+ >+sub UploadFile { >+ my ($filename, $dir, $handle) = @_; >+ >+ $filename = decode_utf8($filename); >+ if($filename =~ m#(^|/)\.\.(/|$)# or $dir =~ m#(^|/)\.\.(/|$)#) { >+ warn "Filename or dirname contains '..'. Aborting upload"; >+ return; >+ } >+ >+ my $buffer; >+ my $data = ''; >+ while($handle->read($buffer, 1024)) { >+ $data .= $buffer; >+ } >+ $handle->close; >+ >+ my $sha = new Digest::SHA; >+ $sha->add($data); >+ my $id = $sha->hexdigest; >+ >+ # Test if this id already exist >+ my $file = GetUploadedFile($id); >+ if ($file) { >+ return $file->{id}; >+ } >+ >+ my $file_path = _get_file_path($id, $dir, $filename); >+ >+ my $out_fh; >+ # Create the file only if it doesn't exist >+ unless( sysopen($out_fh, $file_path, O_WRONLY|O_CREAT|O_EXCL) ) { >+ warn "Failed to open file '$file_path': $!"; >+ return; >+ } >+ >+ print $out_fh $data; >+ close $out_fh; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ INSERT INTO uploaded_files (id, filename, dir) >+ VALUES (?,?, ?); >+ }; >+ my $sth = $dbh->prepare($query); >+ if($sth->execute($id, $filename, $dir)) { >+ return $id; >+ } >+ >+ return; >+} >+ >+=head2 DelUploadedFile >+ >+ C4::UploadedFiles::DelUploadedFile($id); >+ >+Remove a previously uploaded file, given its id. >+ >+Returns a false value if an error occurs. >+ >+=cut >+ >+sub DelUploadedFile { >+ my ($id) = @_; >+ >+ my $file = GetUploadedFile($id); >+ if($file) { >+ my $file_path = $file->{filepath}; >+ my $file_deleted = 0; >+ unless( -f $file_path ) { >+ warn "Id $file->{id} is in database but not in filesystem, removing id from database"; >+ $file_deleted = 1; >+ } else { >+ if(unlink $file_path) { >+ $file_deleted = 1; >+ } >+ } >+ >+ unless($file_deleted) { >+ warn "File $file_path cannot be deleted: $!"; >+ } >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ DELETE FROM uploaded_files >+ WHERE id = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ return $sth->execute($id); >+ } >+} >+ >+1; >diff --git a/basket/basket.pl b/basket/basket.pl >index d33216c..e07c694 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -66,7 +66,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >- my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+ my $marcurlsarray = GetMarcUrls ($record,$marcflavour, GetFrameworkCode($biblionumber)); > my @items = GetItemsInfo( $biblionumber ); > > my $hasauthors = 0; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 72258fd..0a1a876 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -113,7 +113,7 @@ my $marcisbnsarray = GetMarcISBN( $record, $marcflavour ); > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries($record,$marcflavour); >-my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+my $marcurlsarray = GetMarcUrls ($record,$marcflavour, $fw); > my $marchostsarray = GetMarcHosts($record,$marcflavour); > my $subtitle = GetRecordValue('subtitle', $record, $fw); > >diff --git a/cataloguing/value_builder/upload.pl b/cataloguing/value_builder/upload.pl >new file mode 100755 >index 0000000..e0b786d >--- /dev/null >+++ b/cataloguing/value_builder/upload.pl >@@ -0,0 +1,187 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011-2012 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published >+# by the Free Software Foundation; either version 3 of the >+# License, or (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY 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. >+# 51 Franklin Street, Fifth Floor >+# Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use CGI qw/-utf8/; >+use File::Basename; >+ >+use C4::Auth; >+use C4::Context; >+use C4::Output; >+use C4::UploadedFiles; >+ >+sub plugin_parameters { >+ my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_; >+ return ""; >+} >+ >+sub plugin_javascript { >+ my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; >+ my $function_name = $field_number; >+ my $res = " >+ <script type=\"text/javascript\"> >+ function Focus$function_name(subfield_managed) { >+ return 1; >+ } >+ >+ function Blur$function_name(subfield_managed) { >+ return 1; >+ } >+ >+ function Clic$function_name(index) { >+ var id = document.getElementById(index).value; >+ if(id.match(/id=([0-9a-f]+)/)){ >+ id = RegExp.\$1; >+ } >+ window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&id=\"+id, 'upload', 'width=600,height=400,toolbar=false,scrollbars=no'); >+ >+ } >+ </script> >+"; >+ >+ return ( $function_name, $res ); >+} >+ >+sub plugin { >+ my ($input) = @_; >+ my $index = $input->param('index'); >+ my $id = $input->param('id'); >+ my $delete = $input->param('delete'); >+ my $uploaded_file = $input->param('uploaded_file'); >+ >+ my $template_name = ($id || $delete) >+ ? "upload_delete_file.tt" >+ : "upload.tt"; >+ >+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "cataloguing/value_builder/$template_name", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { editcatalogue => '*' }, >+ debug => 1, >+ } >+ ); >+ >+ # Dealing with the uploaded file >+ if ($uploaded_file) { >+ my $fh = $input->upload('uploaded_file'); >+ my $dir = $input->param('dir'); >+ >+ $id = C4::UploadedFiles::UploadFile($uploaded_file, $dir, $fh->handle); >+ if($id) { >+ my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); >+ $OPACBaseURL =~ s#/$##; >+ my $return = "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id"; >+ $template->param( >+ success => 1, >+ return => $return, >+ uploaded_file => $uploaded_file, >+ ); >+ } else { >+ $template->param(error => 1); >+ } >+ } elsif ($delete || $id) { >+ # If there's already a file uploaded for this field, >+ # We handle its deletion >+ if ($delete) { >+ if(C4::UploadedFiles::DelUploadedFile($id)) {; >+ $template->param(success => 1); >+ } else { >+ $template->param(error => 1); >+ } >+ } >+ } else { >+ my $upload_path = C4::Context->config('upload_path'); >+ 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( >+ index => $index, >+ id => $id >+ ); >+ >+ output_html_with_http_headers $input, $cookie, $template->output; >+} >+ >+# Build a hierarchy of directories >+sub finddirs { >+ my $base = shift; >+ my $upload_path = C4::Context->config('upload_path'); >+ my $found = 0; >+ my @dirs; >+ my @files = glob("$base/*"); >+ foreach (@files) { >+ if (-d $_ and -w $_) { >+ my $lastdirname = basename($_); >+ my $dirname = $_; >+ $dirname =~ s/^$upload_path//g; >+ push @dirs, { >+ value => $dirname, >+ name => $lastdirname, >+ dirs => finddirs($_) >+ }; >+ $found = 1; >+ }; >+ } >+ return \@dirs; >+} >+ >+1; >+ >+ >+__END__ >+ >+=head1 upload.pl >+ >+This plugin allow to upload files on the server and reference it in a marc >+field. >+ >+Two system settings are used: >+ >+=over 4 >+ >+=item * upload_path: the real absolute path where files will be stored >+ >+=item * OPACBaseURL: for building URLs to be stored in MARC >+ >+=back >+ >+upload_path is in koha-conf.xml, and OPACBaseURL is a system preference. >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index d42f041..c2e74a6 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -278,6 +278,7 @@ __PAZPAR2_TOGGLE_XML_POST__ > <authorityservershadow>1</authorityservershadow> > <pluginsdir>__PLUGINS_DIR__</pluginsdir> > <enable_plugins>0</enable_plugins> >+ <upload_path></upload_path> > <intranetdir>__INTRANET_CGI_DIR__</intranetdir> > <opacdir>__OPAC_CGI_DIR__/opac</opacdir> > <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs> >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 7628983..9e40ae5 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3184,6 +3184,17 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > -- >+-- Table structure for table uploaded_files >+-- >+ >+DROP TABLE IF EXISTS uploaded_files; >+CREATE TABLE uploaded_files ( >+ id CHAR(40) NOT NULL PRIMARY KEY, >+ filename TEXT NOT NULL, >+ dir TEXT NOT NULL >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- > -- Table structure for table linktracker > -- This stores clicks to external links > -- >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 74aeb3e..9f480aa 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7067,6 +7067,22 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(" >+ CREATE TABLE uploaded_files ( >+ id CHAR(40) NOT NULL PRIMARY KEY, >+ filename TEXT NOT NULL, >+ dir TEXT NOT NULL >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ "); >+ >+ print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n"; >+ print "This plugin comes with a new config variable (upload_path) and a new table (uploaded_files)\n"; >+ print "To use it, set the 'upload_path' variable and 'OPACBaseURL' system preference and link this plugin to a subfield (856\$u for example)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >index fd78eeb..37cb812 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >@@ -120,7 +120,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %][% subfiel.marc_subfield %][% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -150,7 +156,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -180,7 +192,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -210,7 +228,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -240,7 +264,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -270,7 +300,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -300,7 +336,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -330,7 +372,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -360,7 +408,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value |html %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >@@ -390,7 +444,13 @@ function Changefwk(FwkList) { > <span class="subfield-label"> > [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %] > <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span> >- [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %] >+ [% IF ( subfiel.is_url ) %] >+ <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a> >+ [% ELSIF ( subfiel.is_file ) %] >+ [% subfiel.marc_value %] >+ [% ELSE %] >+ [% subfiel.marc_value |html %] >+ [% END %] > [% IF ( subfiel.link ) %] > <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&idx=[% subfiel.link %],phr&type=intranet&q=[% subfiel.marc_value |url %]"> > <img border="0" src="[% interface %]/[% theme %]/img/filefind.png" height="15" title="Search on [% subfiel.marc_value |html %]" alt="Search on [% subfiel.marc_value |html %]" /> >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 >new file mode 100644 >index 0000000..585aa3b >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt >@@ -0,0 +1,77 @@ >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+<head> >+ <title>Upload plugin</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript" src="[% interface %]/lib/jquery/jquery.js"></script> >+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" /> >+ >+</head> >+<body> >+[% IF ( success ) %] >+ >+ <script type="text/javascript"> >+ function report() { >+ var doc = opener.document; >+ var field = doc.getElementById("[% index %]"); >+ field.value = "[% return %]"; >+ } >+ $(document).ready(function() { >+ report(); >+ }); >+ </script> >+ >+ >+ The file [% uploaded_file | html %] has been successfully uploaded. >+ <p><input type="button" value="close" onclick="window.close();" /></p> >+ >+[% ELSE %] >+ >+ [% IF ( error ) %] >+ <p>Error: Failed to upload file. See logs for details.</p> >+ <input type="button" value="close" onclick="window.close();" /> >+ [% ELSE %] >+ [%# This block display recursively a directory tree in variable 'dirs' %] >+ [% BLOCK list_dirs %] >+ [% IF dirs.size %] >+ <ul> >+ [% FOREACH dir IN dirs %] >+ <li style="list-style-type:none"> >+ <input type="radio" name="dir" id="[% dir.value %]" value="[% dir.value %]"> >+ <label for="[% dir.value %]"> >+ [% IF (dir.name == '/') %] >+ <em>(root)</em> >+ [% ELSE %] >+ [% dir.name %] >+ [% END %] >+ </label> >+ </input> >+ [% INCLUDE list_dirs dirs=dir.dirs %] >+ </li> >+ [% END %] >+ </ul> >+ [% END %] >+ [% END %] >+ >+ [% IF (error_upload_path_not_configured) %] >+ <h2>Configuration error</h2> >+ <p>Configuration variable 'upload_path' 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 %] >+ >+</body> >+</html> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt >new file mode 100644 >index 0000000..7817bbe >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt >@@ -0,0 +1,60 @@ >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+<head> >+ <title>Upload plugin</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script> >+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" /> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function goToUploadPage() { >+ var url = "/cgi-bin/koha/cataloguing/plugin_launcher.pl?" >+ + "plugin_name=upload.pl&index=[% index %]"; >+ window.location.href = url; >+ } >+ //]]> >+ </script> >+ >+</head> >+<body> >+[% IF ( success ) %] >+ >+ <script type="text/javascript"> >+ function report() { >+ var doc = opener.document; >+ var field = doc.getElementById("[% index %]"); >+ field.value = ""; >+ } >+ $(document).ready(function() { >+ report(); >+ }); >+ </script> >+ >+ <p>The file has been successfully deleted.</p> >+ >+ <input type="button" value="Upload a new file" onclick="goToUploadPage();" /> >+ <input type="button" value="Close" onclick="window.close();" /> >+ >+[% ELSE %] >+ >+ [% IF ( error ) %] >+ Error: Unable to delete the file. >+ <p><input type="button" value="close" onclick="window.close();" /></p> >+ [% ELSE %] >+ <h2>File deletion</h2> >+ <p>A file has already been uploaded for this field. Do you want to delete it?</p> >+ <form method="post" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >+ <input type="hidden" name="plugin_name" value="upload.pl" /> >+ <input type="hidden" name="delete" value="delete" /> >+ <input type="hidden" name="id" value="[% id %]" /> >+ <input type="hidden" name="index" value="[% index %]" /> >+ <input type="button" value="Cancel" onclick="javascript:window.close();" /> >+ <input type="submit" value="Delete" /> >+ </form> >+ [% END %] >+ >+[% END %] >+ >+</body> >+</html> >diff --git a/misc/strip_value_from_tag.pl b/misc/strip_value_from_tag.pl >new file mode 100755 >index 0000000..958a7fc >--- /dev/null >+++ b/misc/strip_value_from_tag.pl >@@ -0,0 +1,60 @@ >+#!/usr/bin/perl >+ >+# This script takes every biblio record in the database, >+# looks for a value beginning with $find in $fieldtag$$subfieldtag >+# and strips $find from this value. >+# This was originally made for the file upload plugin, but might >+# be used for other purposes. >+ >+use Modern::Perl; >+ >+use Getopt::Long; >+use C4::Context; >+use C4::Biblio; >+ >+my $debug = 0; >+ >+# Which field are we processing? >+my $fieldtag = "857"; >+my $subfieldtag = "u"; >+ >+# Whichi beginning pattern are we looking to delete? >+my $find = "http://myurl.tld/"; >+my $length = length($find); >+my $pattern = qr|^$find|; >+ >+print "Field $fieldtag\$$subfieldtag\n"; >+ >+# Getting db connection >+my $dbh = C4::Context->dbh; >+ >+# Getting max bibnumber >+my $query = "SELECT MAX(biblionumber) from biblio"; >+my $sth = $dbh->prepare($query); >+$sth->execute(); >+my $bibliocount = $sth->fetchrow; >+ >+warn "unable to get biblio count" and exit -1 unless $bibliocount; >+ >+print "Biblio count : $bibliocount\n"; >+ >+# Foreach each biblio >+foreach (1..$bibliocount) { >+ my $found = 0; >+ my $record = GetMarcBiblio($_); >+ $debug and warn "unable to get marc for record $_" unless $record; >+ next unless $record; >+ foreach my $field ($record->field($fieldtag)) { >+ my $newfield = $field->clone(); >+ my $subfield = $newfield->subfield($subfieldtag); >+ if ($subfield and $subfield =~ $pattern) { >+ my $newsubfield = substr $subfield, $length; >+ $newsubfield =~ s/\s+$//; >+ $newfield->update($subfieldtag, $newsubfield); >+ $field->replace_with($newfield); >+ $found = 1; >+ } >+ } >+ print "processing $_\n" if ($found == 1); >+ ModBiblioMarc($record, $_, GetFrameworkCode($_)) if ($found == 1); >+} >diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl >index 7b3a90a..99ca074 100755 >--- a/opac/opac-basket.pl >+++ b/opac/opac-basket.pl >@@ -69,7 +69,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >- my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+ my $marcurlsarray = GetMarcUrls ($record,$marcflavour, GetFrameworkCode($biblionumber)); > my @items = &GetItemsInfo( $biblionumber ); > my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index d1f5d91..4fbb1a2 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -634,7 +634,7 @@ my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); > my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour); > my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); >-my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >+my $marcurlsarray = GetMarcUrls ($record,$marcflavour, $dat->{'frameworkcode'}); > my $marchostsarray = GetMarcHosts($record,$marcflavour); > my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); > >diff --git a/opac/opac-retrieve-file.pl b/opac/opac-retrieve-file.pl >new file mode 100755 >index 0000000..a0f7d93 >--- /dev/null >+++ b/opac/opac-retrieve-file.pl >@@ -0,0 +1,50 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011-2012 BibLibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published >+# by the Free Software Foundation; either version 2 of the >+# License, or (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY 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. >+# 51 Franklin Street, Fifth Floor >+# Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+use CGI; >+ >+use C4::Context; >+use C4::UploadedFiles; >+ >+my $input = new CGI; >+ >+my $id = $input->param('id'); >+my $file = C4::UploadedFiles::GetUploadedFile($id); >+exit 1 if not $file; >+ >+my $file_path = $file->{filepath}; >+ >+if( -f $file_path ) { >+ open my $fh, '<', $file_path or die "Can't open file: $!"; >+ print $input->header( >+ -type => "application/octet-stream", >+ -attachment => $file->{filename} >+ ); >+ while(<$fh>) { >+ print $_; >+ } >+} else { >+ exit 1; >+} >+ >+exit 0; >diff --git a/t/db_dependent/UploadedFiles.t b/t/db_dependent/UploadedFiles.t >new file mode 100755 >index 0000000..ff14317 >--- /dev/null >+++ b/t/db_dependent/UploadedFiles.t >@@ -0,0 +1,42 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use File::Temp qw/ tempdir /; >+use Test::CGI::Multipart; >+use Test::More tests => 11; >+ >+use t::lib::Mocks; >+ >+use C4::Context; >+use C4::UploadedFiles; >+ >+# This simulates a multipart POST request with a file upload. >+my $tcm = new Test::CGI::Multipart; >+$tcm->upload_file( >+ name => 'testfile', >+ file => 'testfilename.txt', >+ value => "This is the content of testfilename.txt", >+); >+my $cgi = $tcm->create_cgi; >+ >+my $tempdir = tempdir(CLEANUP => 1); >+t::lib::Mocks::mock_config('upload_path', $tempdir); >+ >+my $testfilename = $cgi->param('testfile'); >+my $testfile_fh = $cgi->upload('testfile'); >+my $id = C4::UploadedFiles::UploadFile($testfilename, '', $testfile_fh->handle); >+ok($id, "File uploaded, id is $id"); >+ >+my $file = C4::UploadedFiles::GetUploadedFile($id); >+isa_ok($file, 'HASH', "GetUploadedFiles($id)"); >+foreach my $key (qw(id filename filepath dir)) { >+ ok(exists $file->{$key}, "GetUploadedFile($id)->{$key} exists"); >+} >+ >+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"); >+ >+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'); >-- >1.7.10.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