View | Details | Raw Unified | Return to bug 6874
Collapse All | Expand All

(-)a/C4/Biblio.pm (-6 / +23 lines)
Lines 38-43 use C4::ClassSource; Link Here
38
use C4::Charset;
38
use C4::Charset;
39
use C4::Linker;
39
use C4::Linker;
40
use C4::OAI::Sets;
40
use C4::OAI::Sets;
41
use C4::UploadedFiles;
41
42
42
use Koha::Cache;
43
use Koha::Cache;
43
44
Lines 1967-1973 sub GetMarcAuthors { Link Here
1967
1968
1968
=head2 GetMarcUrls
1969
=head2 GetMarcUrls
1969
1970
1970
  $marcurls = GetMarcUrls($record,$marcflavour);
1971
  $marcurls = GetMarcUrls($record,$marcflavour,$frameworkcode);
1971
1972
1972
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
1973
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
1973
Assumes web resources (not uncommon in MARC21 to omit resource type ind) 
1974
Assumes web resources (not uncommon in MARC21 to omit resource type ind) 
Lines 1975-1993 Assumes web resources (not uncommon in MARC21 to omit resource type ind) Link Here
1975
=cut
1976
=cut
1976
1977
1977
sub GetMarcUrls {
1978
sub GetMarcUrls {
1978
    my ( $record, $marcflavour ) = @_;
1979
    my ( $record, $marcflavour, $frameworkcode ) = @_;
1979
    if (!$record) {
1980
    if (!$record) {
1980
        carp 'GetMarcUrls called on undefined record';
1981
        carp 'GetMarcUrls called on undefined record';
1981
        return;
1982
        return;
1982
    }
1983
    }
1983
1984
1985
    my $tagslib = &GetMarcStructure(1, $frameworkcode);
1986
    my $urltag = '856';
1987
    my $urlsubtag = 'u';
1988
1984
    my @marcurls;
1989
    my @marcurls;
1985
    for my $field ( $record->field('856') ) {
1990
    for my $field ( $record->field($urltag) ) {
1986
        my @notes;
1991
        my @notes;
1987
        for my $note ( $field->subfield('z') ) {
1992
        for my $note ( $field->subfield('z') ) {
1988
            push @notes, { note => $note };
1993
            push @notes, { note => $note };
1989
        }
1994
        }
1990
        my @urls = $field->subfield('u');
1995
        my @urls = $field->subfield($urlsubtag);
1991
        foreach my $url (@urls) {
1996
        foreach my $url (@urls) {
1992
            my $marcurl;
1997
            my $marcurl;
1993
            if ( $marcflavour eq 'MARC21' ) {
1998
            if ( $marcflavour eq 'MARC21' ) {
Lines 2015-2022 sub GetMarcUrls { Link Here
2015
                $marcurl->{'part'} = $s3 if ($link);
2020
                $marcurl->{'part'} = $s3 if ($link);
2016
                $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ );
2021
                $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ );
2017
            } else {
2022
            } else {
2018
                $marcurl->{'linktext'} = $field->subfield('2') || C4::Context->preference('URLLinkText') || $url;
2023
                if ($tagslib->{ $urltag }->{ $urlsubtag }->{value_builder} eq "upload.pl"
2019
                $marcurl->{'MARCURL'} = $url;
2024
                  and $url =~ /id=([0-9a-f]+)/) {
2025
                    my $file = C4::UploadedFiles::GetUploadedFile($1);
2026
                    my $text = $file ? $file->{filename} : $url;
2027
                    $marcurl->{'linktext'} = $field->subfield('2')
2028
                                          || C4::Context->preference('URLLinkText')
2029
                                          || $file->{filename};
2030
                    $marcurl->{'MARCURL'} = $url;
2031
                } else {
2032
                    $marcurl->{'linktext'} = $field->subfield('2')
2033
                                          || C4::Context->preference('URLLinkText')
2034
                                          || $url;
2035
                    $marcurl->{'MARCURL'} = $url;
2036
                }
2020
            }
2037
            }
2021
            push @marcurls, $marcurl;
2038
            push @marcurls, $marcurl;
2022
        }
2039
        }
(-)a/C4/UploadedFiles.pm (+226 lines)
Line 0 Link Here
1
package C4::UploadedFiles;
2
3
# Copyright 2011-2012 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
C4::UploadedFiles - Functions to deal with files uploaded with cataloging plugin upload.pl
23
24
=head1 SYNOPSIS
25
26
    use C4::UploadedFiles;
27
28
    my $filename = $cgi->param('uploaded_file');
29
    my $file = $cgi->upload('uploaded_file');
30
    my $dir = $input->param('dir');
31
32
    # upload file
33
    my $id = C4::UploadedFiles::UploadFile($filename, $dir, $file->handle);
34
35
    # retrieve file infos
36
    my $uploaded_file = C4::UploadedFiles::GetUploadedFile($id);
37
38
    # delete file
39
    C4::UploadedFiles::DelUploadedFile($id);
40
41
=head1 DESCRIPTION
42
43
This module provides basic functions for adding, retrieving and deleting files related to
44
cataloging plugin upload.pl.
45
46
It uses uploaded_files table.
47
48
It is not related to C4::UploadedFile
49
50
=head1 FUNCTIONS
51
52
=cut
53
54
use Modern::Perl;
55
use Digest::SHA;
56
use Fcntl;
57
use Encode;
58
59
use C4::Context;
60
61
sub _get_file_path {
62
    my ($id, $dirname, $filename) = @_;
63
64
    my $uploadPath = C4::Context->preference('uploadPath');
65
    my $filepath = "$uploadPath/$dirname/${id}_$filename";
66
    $filepath =~ s|/+|/|g;
67
68
    return $filepath;
69
}
70
71
=head2 GetUploadedFile
72
73
    my $file = C4::UploadedFiles::GetUploadedFile($id);
74
75
Returns a hashref containing infos on uploaded files.
76
Hash keys are:
77
78
=over 2
79
80
=item * id: id of the file (same as given in argument)
81
82
=item * filename: name of the file
83
84
=item * dir: directory where file is stored (relative to syspref 'uploadPath')
85
86
=back
87
88
It returns undef if file is not found
89
90
=cut
91
92
sub GetUploadedFile {
93
    my ($id) = @_;
94
95
    return unless $id;
96
97
    my $dbh = C4::Context->dbh;
98
    my $query = qq{
99
        SELECT id, filename, dir
100
        FROM uploaded_files
101
        WHERE id = ?
102
    };
103
    my $sth = $dbh->prepare($query);
104
    $sth->execute($id);
105
    my $file = $sth->fetchrow_hashref;
106
    if ($file) {
107
        $file->{filepath} = _get_file_path($file->{id}, $file->{dir},
108
            $file->{filename});
109
    }
110
111
    return $file;
112
}
113
114
=head2 UploadFile
115
116
    my $id = C4::UploadedFiles::UploadFile($filename, $dir, $io_handle);
117
118
Upload a new file and returns its id (its SHA-1 sum, actually).
119
120
Parameters:
121
122
=over 2
123
124
=item * $filename: name of the file
125
126
=item * $dir: directory where to store the file (path relative to syspref 'uploadPath'
127
128
=item * $io_handle: valid IO::Handle object, can be retrieved with
129
$cgi->upload('uploaded_file')->handle;
130
131
=back
132
133
=cut
134
135
sub UploadFile {
136
    my ($filename, $dir, $handle) = @_;
137
138
    $filename = decode_utf8($filename);
139
    if($filename =~ m#(^|/)\.\.(/|$)# or $dir =~ m#(^|/)\.\.(/|$)#) {
140
        warn "Filename or dirname contains '..'. Aborting upload";
141
        return;
142
    }
143
144
    my $buffer;
145
    my $data = '';
146
    while($handle->read($buffer, 1024)) {
147
        $data .= $buffer;
148
    }
149
    $handle->close;
150
151
    my $sha = new Digest::SHA;
152
    $sha->add($data);
153
    my $id = $sha->hexdigest;
154
155
    # Test if this id already exist
156
    my $file = GetUploadedFile($id);
157
    if ($file) {
158
        return $file->{id};
159
    }
160
161
    my $file_path = _get_file_path($id, $dir, $filename);
162
163
    my $out_fh;
164
    # Create the file only if it doesn't exist
165
    unless( sysopen($out_fh, $file_path, O_WRONLY|O_CREAT|O_EXCL) ) {
166
        warn "Failed to open file '$file_path': $!";
167
        return;
168
    }
169
170
    print $out_fh $data;
171
    close $out_fh;
172
173
    my $dbh = C4::Context->dbh;
174
    my $query = qq{
175
        INSERT INTO uploaded_files (id, filename, dir)
176
        VALUES (?,?, ?);
177
    };
178
    my $sth = $dbh->prepare($query);
179
    if($sth->execute($id, $filename, $dir)) {
180
        return $id;
181
    }
182
183
    return undef;
184
}
185
186
=head2 DelUploadedFile
187
188
    C4::UploadedFiles::DelUploadedFile($id);
189
190
Remove a previously uploaded file, given its id.
191
192
Returns a false value if an error occurs.
193
194
=cut
195
196
sub DelUploadedFile {
197
    my ($id) = @_;
198
199
    my $file = GetUploadedFile($id);
200
    if($file) {
201
        my $file_path = $file->{filepath};
202
        my $file_deleted = 0;
203
        unless( -f $file_path ) {
204
            warn "Id $file->{id} is in database but not in filesystem, removing id from database";
205
            $file_deleted = 1;
206
        } else {
207
            if(unlink $file_path) {
208
                $file_deleted = 1;
209
            }
210
        }
211
212
        unless($file_deleted) {
213
            warn "File $file_path cannot be deleted: $!";
214
        }
215
216
        my $dbh = C4::Context->dbh;
217
        my $query = qq{
218
            DELETE FROM uploaded_files
219
            WHERE id = ?
220
        };
221
        my $sth = $dbh->prepare($query);
222
        return $sth->execute($id);
223
    }
224
}
225
226
1;
(-)a/basket/basket.pl (-1 / +1 lines)
Lines 67-73 foreach my $biblionumber ( @bibs ) { Link Here
67
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
67
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
68
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
68
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
69
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
69
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
70
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
70
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour, GetFrameworkCode($biblionumber));
71
    my @items            = GetItemsInfo( $biblionumber );
71
    my @items            = GetItemsInfo( $biblionumber );
72
72
73
    my $hasauthors = 0;
73
    my $hasauthors = 0;
(-)a/catalogue/MARCdetail.pl (-1 lines)
Lines 216-222 for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) { Link Here
216
                    $subfield_data{marc_value} =
216
                    $subfield_data{marc_value} =
217
                      GetAuthorisedValueDesc( $fields[$x_i]->tag(),
217
                      GetAuthorisedValueDesc( $fields[$x_i]->tag(),
218
                        $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
218
                        $subf[$i][0], $subf[$i][1], '', $tagslib) || $subf[$i][1];
219
220
                }
219
                }
221
                $subfield_data{marc_subfield} = $subf[$i][0];
220
                $subfield_data{marc_subfield} = $subf[$i][0];
222
                $subfield_data{marc_tag}      = $fields[$x_i]->tag();
221
                $subfield_data{marc_tag}      = $fields[$x_i]->tag();
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 113-119 my $marcisbnsarray = GetMarcISBN( $record, $marcflavour ); Link Here
113
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
113
my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
114
my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
114
my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
115
my $marcseriesarray  = GetMarcSeries($record,$marcflavour);
115
my $marcseriesarray  = GetMarcSeries($record,$marcflavour);
116
my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
116
my $marcurlsarray    = GetMarcUrls    ($record, $marcflavour, $fw);
117
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
117
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
118
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
118
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
119
119
(-)a/cataloguing/value_builder/upload.pl (+178 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011-2012 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI qw/-utf8/;
22
use File::Basename;
23
24
use C4::Auth;
25
use C4::Context;
26
use C4::Output;
27
use C4::UploadedFiles;
28
29
my $upload_path = C4::Context->preference('uploadPath');
30
31
sub plugin_parameters {
32
    my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
33
    return "";
34
}
35
36
sub plugin_javascript {
37
    my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
38
    my $function_name = $field_number;
39
    my $res           = "
40
    <script type=\"text/javascript\">
41
        function Focus$function_name(subfield_managed) {
42
            return 1;
43
        }
44
45
        function Blur$function_name(subfield_managed) {
46
            return 1;
47
        }
48
49
        function Clic$function_name(index) {
50
            var id = document.getElementById(index).value;
51
            if(id.match(/id=([0-9a-f]+)/)){
52
                id = RegExp.\$1;
53
            }
54
            window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&id=\"+id, 'upload', 'width=600,height=400,toolbar=false,scrollbars=no');
55
56
        }
57
    </script>
58
";
59
60
    return ( $function_name, $res );
61
}
62
63
sub plugin {
64
    my ($input) = @_;
65
    my $index = $input->param('index');
66
    my $id = $input->param('id');
67
    my $delete = $input->param('delete');
68
    my $uploaded_file = $input->param('uploaded_file');
69
70
    my $template_name = ($id || $delete)
71
                    ? "upload_delete_file.tt"
72
                    : "upload.tt";
73
74
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
75
        {   template_name   => "cataloguing/value_builder/$template_name",
76
            query           => $input,
77
            type            => "intranet",
78
            authnotrequired => 0,
79
            flagsrequired   => { editcatalogue => '*' },
80
            debug           => 1,
81
        }
82
    );
83
84
    # Dealing with the uploaded file
85
    if ($uploaded_file) {
86
        my $fh = $input->upload('uploaded_file');
87
        my $dir = $input->param('dir');
88
89
        $id = C4::UploadedFiles::UploadFile($uploaded_file, $dir, $fh->handle);
90
        if($id) {
91
            my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
92
            $OPACBaseURL =~ s#/$##;
93
            my $return = "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id";
94
            $template->param(
95
                success => 1,
96
                return => $return,
97
                uploaded_file => $uploaded_file,
98
            );
99
        } else {
100
            $template->param(error => 1);
101
        }
102
    } elsif ($delete || $id) {
103
        # If there's already a file uploaded for this field,
104
        # We handle its deletion
105
        if ($delete) {
106
            if(C4::UploadedFiles::DelUploadedFile($id)) {;
107
                $template->param(success => 1);
108
            } else {
109
                $template->param(error => 1);
110
            }
111
        }
112
    } else {
113
        my $filefield = CGI::filefield(
114
            -name => 'uploaded_file',
115
            -size => 50,
116
        );
117
118
        my $dirs_tree = [ {
119
            name => '/',
120
            value => '/',
121
            dirs => finddirs($upload_path)
122
        } ];
123
124
        $template->param(
125
            dirs_tree => $dirs_tree,
126
            filefield => $filefield
127
        );
128
    }
129
130
    $template->param(
131
        index => $index,
132
        id => $id
133
    );
134
135
    output_html_with_http_headers $input, $cookie, $template->output;
136
}
137
138
# Build a hierarchy of directories
139
sub finddirs {
140
    my $base = shift || $upload_path;
141
    my $found = 0;
142
    my @dirs;
143
    my @files = <$base/*>;
144
    foreach (@files) {
145
        if (-d $_ and -w $_) {
146
            my $lastdirname = basename($_);
147
            my $dirname =  $_;
148
            $dirname =~ s/^$upload_path//g;
149
            push @dirs, {
150
                value => $dirname,
151
                name => $lastdirname,
152
                dirs => finddirs($_)
153
            };
154
            $found = 1;
155
        };
156
    }
157
    return \@dirs;
158
}
159
160
1;
161
162
163
__END__
164
165
=head1 upload.pl
166
167
This plugin allow to upload files on the server and reference it in a marc
168
field.
169
170
Two system preference are used:
171
172
=over 4
173
174
=item * uploadPath: the real absolute path where files will be stored
175
176
=item * OPACBaseURL: for building URLs to be stored in MARC
177
178
=back
(-)a/installer/data/mysql/kohastructure.sql (+11 lines)
Lines 3362-3367 CREATE TABLE IF NOT EXISTS `borrower_modifications` ( Link Here
3362
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3362
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3363
3363
3364
--
3364
--
3365
-- Table structure for table uploaded_files
3366
--
3367
3368
DROP TABLE IF EXISTS uploaded_files
3369
CREATE TABLE uploaded_files (
3370
    id CHAR(40) NOT NULL PRIMARY KEY,
3371
    filename TEXT NOT NULL,
3372
    dir TEXT NOT NULL
3373
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3374
3375
--
3365
-- Table structure for table linktracker
3376
-- Table structure for table linktracker
3366
-- This stores clicks to external links
3377
-- This stores clicks to external links
3367
--
3378
--
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 443-448 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
443
('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'),
443
('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'),
444
('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'),
444
('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'),
445
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
445
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
446
('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')
446
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
447
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
447
('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'),
448
('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'),
448
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
449
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+21 lines)
Lines 9978-9983 if ( CheckVersion($DBversion) ) { Link Here
9978
    SetVersion($DBversion);
9978
    SetVersion($DBversion);
9979
}
9979
}
9980
9980
9981
$DBversion = "XXX";
9982
if ( CheckVersion($DBversion) ) {
9983
    $dbh->do("
9984
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
9985
        VALUES('uploadPath','','Sets the upload path for the upload.pl plugin','','');
9986
    ");
9987
9988
    $dbh->do("
9989
        CREATE TABLE uploaded_files (
9990
            id CHAR(40) NOT NULL PRIMARY KEY,
9991
            filename TEXT NOT NULL,
9992
            dir TEXT NOT NULL
9993
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9994
    ");
9995
9996
    print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
9997
    print "This plugin comes with a new syspref (uploadPath) and a new table (uploaded_files)\n";
9998
    print "To use it, set 'uploadPath' and 'OPACBaseURL' system preferences and link this plugin to a subfield (856\$u for instance)\n";
9999
    SetVersion($DBversion);
10000
}
9981
10001
9982
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10002
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
9983
# SEE bug 13068
10003
# SEE bug 13068
Lines 9992-9997 while ( my $file = readdir $dirh ) { Link Here
9992
    my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
10012
    my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
9993
}
10013
}
9994
10014
10015
9995
=head1 FUNCTIONS
10016
=head1 FUNCTIONS
9996
10017
9997
=head2 TableExists($table)
10018
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 125-130 Cataloging: Link Here
125
            - 'MARC21: "952$a 952$b 952$c"'
125
            - 'MARC21: "952$a 952$b 952$c"'
126
            - Note that the FA framework is excluded from the permission.
126
            - Note that the FA framework is excluded from the permission.
127
            - If the pref is empty, no fields are restricted.
127
            - If the pref is empty, no fields are restricted.
128
        -
129
            - Absolute path where to store files uploaded in MARC record (plugin upload.pl)
130
            - pref: uploadPath
131
              class: multi
128
    Display:
132
    Display:
129
        -
133
        -
130
            - 'Separate multiple displayed authors, series or subjects with '
134
            - 'Separate multiple displayed authors, series or subjects with '
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt (+71 lines)
Line 0 Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
    <title>Upload plugin</title>
6
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
    <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
8
    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
9
10
</head>
11
<body>
12
[% IF ( success ) %]
13
14
    <script type="text/javascript">
15
        function report() {
16
            var doc   = opener.document;
17
            var field = doc.getElementById("[% index %]");
18
            field.value =  "[% return %]";
19
        }
20
        $(document).ready(function() {
21
            report();
22
        });
23
    </script>
24
25
26
    The file [% uploaded_file | html %] has been successfully uploaded.
27
    <p><input type="button" value="close" onclick="window.close();" /></p>
28
29
[% ELSE %]
30
31
    [% IF ( error ) %]
32
        <p>Error: Failed to upload file. See logs for details.</p>
33
        <input type="button" value="close" onclick="window.close();" />
34
    [% ELSE %]
35
        [%# This block display recursively a directory tree in variable 'dirs' %]
36
        [% BLOCK list_dirs %]
37
            [% IF dirs.size %]
38
                <ul>
39
                    [% FOREACH dir IN dirs %]
40
                        <li style="list-style-type:none">
41
                            <input type="radio" name="dir" id="[% dir.value %]" value="[% dir.value %]">
42
                                <label for="[% dir.value %]">
43
                                    [% IF (dir.name == '/') %]
44
                                        <em>(root)</em>
45
                                    [% ELSE %]
46
                                        [% dir.name %]
47
                                    [% END %]
48
                                </label>
49
                            </input>
50
                            [% INCLUDE list_dirs dirs=dir.dirs %]
51
                        </li>
52
                    [% END %]
53
                </ul>
54
            [% END %]
55
        [% END %]
56
57
        <h2>Please select the file to upload : </h2>
58
        <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl">
59
            [% filefield %]
60
            <h3>Choose where to upload file</h3>
61
            [% INCLUDE list_dirs dirs = dirs_tree %]
62
            <input type="hidden" name="plugin_name" value="upload.pl" />
63
            <input type="hidden" name="index" value="[% index %]" />
64
            <input type="submit">
65
        </form>
66
    [% END %]
67
68
[% END %]
69
70
</body>
71
</html>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload_delete_file.tt (+60 lines)
Line 0 Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
    <title>Upload plugin</title>
6
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
    <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
8
    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
9
    <script type="text/javascript">
10
        //<![CDATA[
11
        function goToUploadPage() {
12
            var url = "/cgi-bin/koha/cataloguing/plugin_launcher.pl?"
13
                + "plugin_name=upload.pl&index=[% index %]";
14
            window.location.href = url;
15
        }
16
        //]]>
17
    </script>
18
19
</head>
20
<body>
21
[% IF ( success ) %]
22
23
    <script type="text/javascript">
24
        function report() {
25
            var doc   = opener.document;
26
            var field = doc.getElementById("[% index %]");
27
            field.value =  "";
28
        }
29
        $(document).ready(function() {
30
            report();
31
        });
32
    </script>
33
34
    <p>The file has been successfully deleted.</p>
35
36
    <input type="button" value="Upload a new file" onclick="goToUploadPage();" />
37
    <input type="button" value="Close" onclick="window.close();" />
38
39
[% ELSE %]
40
41
    [% IF ( error ) %]
42
        Error: Unable to delete the file.
43
        <p><input type="button" value="close" onclick="window.close();" /></p>
44
    [% ELSE %]
45
        <h2>File deletion</h2>
46
        <p>A file has already been uploaded for this field. Do you want to delete it?</p>
47
        <form method="post" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl">
48
        <input type="hidden" name="plugin_name" value="upload.pl" />
49
        <input type="hidden" name="delete" value="delete" />
50
        <input type="hidden" name="id" value="[% id %]" />
51
        <input type="hidden" name="index" value="[% index %]" />
52
        <input type="button" value="Cancel" onclick="javascript:window.close();" />
53
        <input type="submit" value="Delete" />
54
        </form>
55
    [% END %]
56
57
[% END %]
58
59
</body>
60
</html>
(-)a/opac/opac-basket.pl (-1 / +1 lines)
Lines 70-76 foreach my $biblionumber ( @bibs ) { Link Here
70
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
70
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
71
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
71
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
72
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
72
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
73
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
73
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour, GetFrameworkCode($biblionumber));
74
    my @items            = &GetItemsInfo( $biblionumber );
74
    my @items            = &GetItemsInfo( $biblionumber );
75
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
75
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
76
76
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 710-716 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); Link Here
710
my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
710
my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
711
my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
711
my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
712
my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
712
my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
713
my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
713
my $marcurlsarray    = GetMarcUrls    ($record, $marcflavour, $dat->{'frameworkcode'});
714
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
714
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
715
my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
715
my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
716
716
(-)a/opac/opac-retrieve-file.pl (-1 / +47 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2011-2012 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI;
22
23
use C4::Context;
24
use C4::UploadedFiles;
25
26
my $input = new CGI;
27
28
my $id = $input->param('id');
29
my $file = C4::UploadedFiles::GetUploadedFile($id);
30
exit 1 if not $file;
31
32
my $file_path = $file->{filepath};
33
34
if( -f $file_path ) {
35
    open FH, '<', $file_path or die "Can't open file: $!";
36
    print $input->header(
37
        -type => "application/octet-stream",
38
        -attachment => $file->{filename}
39
    );
40
    while(<FH>) {
41
        print $_;
42
    }
43
} else {
44
    exit 1;
45
}
46
47
exit 0;

Return to bug 6874