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

(-)a/C4/Biblio.pm (-11 / +32 lines)
Lines 37-42 use C4::ClassSource; Link Here
37
use C4::Charset;
37
use C4::Charset;
38
use C4::Linker;
38
use C4::Linker;
39
use C4::OAI::Sets;
39
use C4::OAI::Sets;
40
use C4::UploadedFiles;
40
41
41
use vars qw($VERSION @ISA @EXPORT);
42
use vars qw($VERSION @ISA @EXPORT);
42
43
Lines 1445-1457 sub GetCOinSBiblio { Link Here
1445
=head2 GetMarcPrice
1446
=head2 GetMarcPrice
1446
1447
1447
return the prices in accordance with the Marc format.
1448
return the prices in accordance with the Marc format.
1449
1448
=cut
1450
=cut
1449
1451
1450
sub GetMarcPrice {
1452
sub GetMarcPrice {
1451
    my ( $record, $marcflavour ) = @_;
1453
    my ( $record, $marcflavour ) = @_;
1452
    my @listtags;
1454
    my @listtags;
1453
    my $subfield;
1455
    my $subfield;
1454
    
1456
1455
    if ( $marcflavour eq "MARC21" ) {
1457
    if ( $marcflavour eq "MARC21" ) {
1456
        @listtags = ('345', '020');
1458
        @listtags = ('345', '020');
1457
        $subfield="c";
1459
        $subfield="c";
Lines 1461-1467 sub GetMarcPrice { Link Here
1461
    } else {
1463
    } else {
1462
        return;
1464
        return;
1463
    }
1465
    }
1464
    
1466
1465
    for my $field ( $record->field(@listtags) ) {
1467
    for my $field ( $record->field(@listtags) ) {
1466
        for my $subfield_value  ($field->subfield($subfield)){
1468
        for my $subfield_value  ($field->subfield($subfield)){
1467
            #check value
1469
            #check value
Lines 1907-1913 sub GetMarcAuthors { Link Here
1907
1909
1908
=head2 GetMarcUrls
1910
=head2 GetMarcUrls
1909
1911
1910
  $marcurls = GetMarcUrls($record,$marcflavour);
1912
  $marcurls = GetMarcUrls($record,$marcflavour,$frameworkcode);
1911
1913
1912
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
1914
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop.
1913
Assumes web resources (not uncommon in MARC21 to omit resource type ind) 
1915
Assumes web resources (not uncommon in MARC21 to omit resource type ind) 
Lines 1915-1929 Assumes web resources (not uncommon in MARC21 to omit resource type ind) Link Here
1915
=cut
1917
=cut
1916
1918
1917
sub GetMarcUrls {
1919
sub GetMarcUrls {
1918
    my ( $record, $marcflavour ) = @_;
1920
    my ( $record, $marcflavour, $frameworkcode ) = @_;
1921
1922
    my $tagslib = &GetMarcStructure(1, $frameworkcode);
1923
    my $urltag = '856';
1924
    my $urlsubtag = 'u';
1919
1925
1920
    my @marcurls;
1926
    my @marcurls;
1921
    for my $field ( $record->field('856') ) {
1927
    for my $field ( $record->field($urltag) ) {
1922
        my @notes;
1928
        my @notes;
1923
        for my $note ( $field->subfield('z') ) {
1929
        for my $note ( $field->subfield('z') ) {
1924
            push @notes, { note => $note };
1930
            push @notes, { note => $note };
1925
        }
1931
        }
1926
        my @urls = $field->subfield('u');
1932
        my @urls = $field->subfield($urlsubtag);
1927
        foreach my $url (@urls) {
1933
        foreach my $url (@urls) {
1928
            my $marcurl;
1934
            my $marcurl;
1929
            if ( $marcflavour eq 'MARC21' ) {
1935
            if ( $marcflavour eq 'MARC21' ) {
Lines 1951-1958 sub GetMarcUrls { Link Here
1951
                $marcurl->{'part'} = $s3 if ($link);
1957
                $marcurl->{'part'} = $s3 if ($link);
1952
                $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ );
1958
                $marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ );
1953
            } else {
1959
            } else {
1954
                $marcurl->{'linktext'} = $field->subfield('2') || C4::Context->preference('URLLinkText') || $url;
1960
                if ($tagslib->{ $urltag }->{ $urlsubtag }->{value_builder} eq "upload.pl"
1955
                $marcurl->{'MARCURL'} = $url;
1961
                  and $url =~ /id=([0-9a-f]+)/) {
1962
                    my $file = C4::UploadedFiles::GetUploadedFile($1);
1963
                    my $text = $file ? $file->{filename} : $url;
1964
                    $marcurl->{'linktext'} = $field->subfield('2')
1965
                                          || C4::Context->preference('URLLinkText')
1966
                                          || $file->{filename};
1967
                    $marcurl->{'MARCURL'} = $url;
1968
                } else {
1969
                    $marcurl->{'linktext'} = $field->subfield('2')
1970
                                          || C4::Context->preference('URLLinkText')
1971
                                          || $url;
1972
                    $marcurl->{'MARCURL'} = $url;
1973
                }
1956
            }
1974
            }
1957
            push @marcurls, $marcurl;
1975
            push @marcurls, $marcurl;
1958
        }
1976
        }
Lines 3377-3383 sub get_biblio_authorised_values { Link Here
3377
=head2 CountBiblioInOrders
3395
=head2 CountBiblioInOrders
3378
3396
3379
=over 4
3397
=over 4
3380
$count = &CountBiblioInOrders( $biblionumber);
3398
3399
=item $count = &CountBiblioInOrders( $biblionumber);
3381
3400
3382
=back
3401
=back
3383
3402
Lines 3400-3406 sub CountBiblioInOrders { Link Here
3400
=head2 GetSubscriptionsId
3419
=head2 GetSubscriptionsId
3401
3420
3402
=over 4
3421
=over 4
3403
$subscriptions = &GetSubscriptionsId($biblionumber);
3422
3423
=item $subscriptions = &GetSubscriptionsId($biblionumber);
3404
3424
3405
=back
3425
=back
3406
3426
Lines 3423-3429 sub GetSubscriptionsId { Link Here
3423
=head2 GetHolds
3443
=head2 GetHolds
3424
3444
3425
=over 4
3445
=over 4
3426
$holds = &GetHolds($biblionumber);
3446
3447
=item $holds = &GetHolds($biblionumber);
3427
3448
3428
=back
3449
=back
3429
3450
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 689-694 our $PERL_DEPS = { Link Here
689
        'required' => '1',
689
        'required' => '1',
690
        'min_ver'  => '0.22',
690
        'min_ver'  => '0.22',
691
    },
691
    },
692
    'Test::CGI::Multipart' => {
693
        'usage'    => 'Tests',
694
        'required' => '0',
695
        'min_ver'  => '0.0.3',
696
    },
692
};
697
};
693
698
694
1;
699
1;
(-)a/C4/UploadedFiles.pm (+230 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
8
# it under the terms of the GNU General Public License as
9
# published by the Free Software Foundation; either version 3
10
# of the License, or (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty
14
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
# See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public
18
# License along with Koha; if not, write to the
19
#     Free Software Foundation, Inc.
20
#     51 Franklin Street, Fifth Floor
21
#     Boston, MA 02110-1301 USA.
22
23
=head1 NAME
24
25
C4::UploadedFiles - Functions to deal with files uploaded with
26
                    cataloging plugin upload.pl
27
28
=head1 SYNOPSIS
29
30
    use C4::UploadedFiles;
31
32
    my $filename = $cgi->param('uploaded_file');
33
    my $file = $cgi->upload('uploaded_file');
34
    my $dir = $input->param('dir');
35
36
    # upload file
37
    my $id = C4::UploadedFiles::UploadFile($filename, $dir, $file->handle);
38
39
    # retrieve file infos
40
    my $uploaded_file = C4::UploadedFiles::GetUploadedFile($id);
41
42
    # delete file
43
    C4::UploadedFiles::DelUploadedFile($id);
44
45
=head1 DESCRIPTION
46
47
This module provides basic functions for adding, retrieving
48
and deleting files related to cataloging plugin upload.pl.
49
50
It uses uploaded_files table.
51
52
It is not related to C4::UploadedFile
53
54
=head1 FUNCTIONS
55
56
=cut
57
58
use Modern::Perl;
59
use Digest::SHA;
60
use Fcntl;
61
use Encode;
62
63
use C4::Context;
64
65
sub _get_file_path {
66
    my ($id, $dirname, $filename) = @_;
67
68
    my $upload_path = C4::Context->config('upload_path');
69
    my $filepath = "$upload_path/$dirname/${id}_$filename";
70
    $filepath =~ s|/+|/|g;
71
72
    return $filepath;
73
}
74
75
=head2 GetUploadedFile
76
77
    my $file = C4::UploadedFiles::GetUploadedFile($id);
78
79
Returns a hashref containing infos on uploaded files.
80
Hash keys are:
81
82
=over 2
83
84
=item * id: id of the file (same as given in argument)
85
86
=item * filename: name of the file
87
88
=item * dir: directory where file is stored (relative to config variable 'upload_path')
89
90
=back
91
92
It returns undef if file is not found
93
94
=cut
95
96
sub GetUploadedFile {
97
    my ($id) = @_;
98
99
    return unless $id;
100
101
    my $dbh = C4::Context->dbh;
102
    my $query = qq{
103
        SELECT id, filename, dir
104
        FROM uploaded_files
105
        WHERE id = ?
106
    };
107
    my $sth = $dbh->prepare($query);
108
    $sth->execute($id);
109
    my $file = $sth->fetchrow_hashref;
110
    if ($file) {
111
        $file->{filepath} = _get_file_path($file->{id}, $file->{dir},
112
            $file->{filename});
113
    }
114
115
    return $file;
116
}
117
118
=head2 UploadFile
119
120
    my $id = C4::UploadedFiles::UploadFile($filename, $dir, $io_handle);
121
122
Upload a new file and returns its id (its SHA-1 sum, actually).
123
124
Parameters:
125
126
=over 2
127
128
=item * $filename: name of the file
129
130
=item * $dir: directory where to store the file (path relative to config variable 'upload_path')
131
132
=item * $io_handle: valid IO::Handle object, can be retrieved with
133
$cgi->upload('uploaded_file')->handle;
134
135
=back
136
137
=cut
138
139
sub UploadFile {
140
    my ($filename, $dir, $handle) = @_;
141
142
    $filename = decode_utf8($filename);
143
    if($filename =~ m#(^|/)\.\.(/|$)# or $dir =~ m#(^|/)\.\.(/|$)#) {
144
        warn "Filename or dirname contains '..'. Aborting upload";
145
        return;
146
    }
147
148
    my $buffer;
149
    my $data = '';
150
    while($handle->read($buffer, 1024)) {
151
        $data .= $buffer;
152
    }
153
    $handle->close;
154
155
    my $sha = new Digest::SHA;
156
    $sha->add($data);
157
    my $id = $sha->hexdigest;
158
159
    # Test if this id already exist
160
    my $file = GetUploadedFile($id);
161
    if ($file) {
162
        return $file->{id};
163
    }
164
165
    my $file_path = _get_file_path($id, $dir, $filename);
166
167
    my $out_fh;
168
    # Create the file only if it doesn't exist
169
    unless( sysopen($out_fh, $file_path, O_WRONLY|O_CREAT|O_EXCL) ) {
170
        warn "Failed to open file '$file_path': $!";
171
        return;
172
    }
173
174
    print $out_fh $data;
175
    close $out_fh;
176
177
    my $dbh = C4::Context->dbh;
178
    my $query = qq{
179
        INSERT INTO uploaded_files (id, filename, dir)
180
        VALUES (?,?, ?);
181
    };
182
    my $sth = $dbh->prepare($query);
183
    if($sth->execute($id, $filename, $dir)) {
184
        return $id;
185
    }
186
187
    return;
188
}
189
190
=head2 DelUploadedFile
191
192
    C4::UploadedFiles::DelUploadedFile($id);
193
194
Remove a previously uploaded file, given its id.
195
196
Returns a false value if an error occurs.
197
198
=cut
199
200
sub DelUploadedFile {
201
    my ($id) = @_;
202
203
    my $file = GetUploadedFile($id);
204
    if($file) {
205
        my $file_path = $file->{filepath};
206
        my $file_deleted = 0;
207
        unless( -f $file_path ) {
208
            warn "Id $file->{id} is in database but not in filesystem, removing id from database";
209
            $file_deleted = 1;
210
        } else {
211
            if(unlink $file_path) {
212
                $file_deleted = 1;
213
            }
214
        }
215
216
        unless($file_deleted) {
217
            warn "File $file_path cannot be deleted: $!";
218
        }
219
220
        my $dbh = C4::Context->dbh;
221
        my $query = qq{
222
            DELETE FROM uploaded_files
223
            WHERE id = ?
224
        };
225
        my $sth = $dbh->prepare($query);
226
        return $sth->execute($id);
227
    }
228
}
229
230
1;
(-)a/basket/basket.pl (-1 / +1 lines)
Lines 66-72 foreach my $biblionumber ( @bibs ) { Link Here
66
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
66
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
67
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
67
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
68
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
68
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
69
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
69
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour, GetFrameworkCode($biblionumber));
70
    my @items            = GetItemsInfo( $biblionumber );
70
    my @items            = GetItemsInfo( $biblionumber );
71
71
72
    my $hasauthors = 0;
72
    my $hasauthors = 0;
(-)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 (+187 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
8
# under the terms of the GNU General Public License as published
9
# by the Free Software Foundation; either version 3 of the
10
# License, or (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
# See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public
18
# License along with Koha; if not, write to the
19
#     Free Software Foundation, Inc.
20
#     51 Franklin Street, Fifth Floor
21
#     Boston, MA 02110-1301 USA.
22
23
use Modern::Perl;
24
use CGI qw/-utf8/;
25
use File::Basename;
26
27
use C4::Auth;
28
use C4::Context;
29
use C4::Output;
30
use C4::UploadedFiles;
31
32
sub plugin_parameters {
33
    my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
34
    return "";
35
}
36
37
sub plugin_javascript {
38
    my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
39
    my $function_name = $field_number;
40
    my $res           = "
41
    <script type=\"text/javascript\">
42
        function Focus$function_name(subfield_managed) {
43
            return 1;
44
        }
45
46
        function Blur$function_name(subfield_managed) {
47
            return 1;
48
        }
49
50
        function Clic$function_name(index) {
51
            var id = document.getElementById(index).value;
52
            if(id.match(/id=([0-9a-f]+)/)){
53
                id = RegExp.\$1;
54
            }
55
            window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&id=\"+id, 'upload', 'width=600,height=400,toolbar=false,scrollbars=no');
56
57
        }
58
    </script>
59
";
60
61
    return ( $function_name, $res );
62
}
63
64
sub plugin {
65
    my ($input) = @_;
66
    my $index = $input->param('index');
67
    my $id = $input->param('id');
68
    my $delete = $input->param('delete');
69
    my $uploaded_file = $input->param('uploaded_file');
70
71
    my $template_name = ($id || $delete)
72
                    ? "upload_delete_file.tt"
73
                    : "upload.tt";
74
75
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
76
        {   template_name   => "cataloguing/value_builder/$template_name",
77
            query           => $input,
78
            type            => "intranet",
79
            authnotrequired => 0,
80
            flagsrequired   => { editcatalogue => '*' },
81
            debug           => 1,
82
        }
83
    );
84
85
    # Dealing with the uploaded file
86
    if ($uploaded_file) {
87
        my $fh = $input->upload('uploaded_file');
88
        my $dir = $input->param('dir');
89
90
        $id = C4::UploadedFiles::UploadFile($uploaded_file, $dir, $fh->handle);
91
        if($id) {
92
            my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
93
            $OPACBaseURL =~ s#/$##;
94
            my $return = "$OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=$id";
95
            $template->param(
96
                success => 1,
97
                return => $return,
98
                uploaded_file => $uploaded_file,
99
            );
100
        } else {
101
            $template->param(error => 1);
102
        }
103
    } elsif ($delete || $id) {
104
        # If there's already a file uploaded for this field,
105
        # We handle its deletion
106
        if ($delete) {
107
            if(C4::UploadedFiles::DelUploadedFile($id)) {;
108
                $template->param(success => 1);
109
            } else {
110
                $template->param(error => 1);
111
            }
112
        }
113
    } else {
114
        my $upload_path = C4::Context->config('upload_path');
115
        if ($upload_path) {
116
            my $filefield = CGI::filefield(
117
                -name => 'uploaded_file',
118
                -size => 50,
119
            );
120
121
            my $dirs_tree = [ {
122
                name => '/',
123
                value => '/',
124
                dirs => finddirs($upload_path)
125
            } ];
126
127
            $template->param(
128
                dirs_tree => $dirs_tree,
129
                filefield => $filefield
130
            );
131
        } else {
132
            $template->param( error_upload_path_not_configured => 1 );
133
        }
134
    }
135
136
    $template->param(
137
        index => $index,
138
        id => $id
139
    );
140
141
    output_html_with_http_headers $input, $cookie, $template->output;
142
}
143
144
# Build a hierarchy of directories
145
sub finddirs {
146
    my $base = shift;
147
    my $upload_path = C4::Context->config('upload_path');
148
    my $found = 0;
149
    my @dirs;
150
    my @files = glob("$base/*");
151
    foreach (@files) {
152
        if (-d $_ and -w $_) {
153
            my $lastdirname = basename($_);
154
            my $dirname =  $_;
155
            $dirname =~ s/^$upload_path//g;
156
            push @dirs, {
157
                value => $dirname,
158
                name => $lastdirname,
159
                dirs => finddirs($_)
160
            };
161
            $found = 1;
162
        };
163
    }
164
    return \@dirs;
165
}
166
167
1;
168
169
170
__END__
171
172
=head1 upload.pl
173
174
This plugin allow to upload files on the server and reference it in a marc
175
field.
176
177
Two system settings are used:
178
179
=over 4
180
181
=item * upload_path: the real absolute path where files will be stored
182
183
=item * OPACBaseURL: for building URLs to be stored in MARC
184
185
=back
186
187
upload_path is in koha-conf.xml, and OPACBaseURL is a system preference.
(-)a/etc/koha-conf.xml (+1 lines)
Lines 278-283 __PAZPAR2_TOGGLE_XML_POST__ Link Here
278
 <authorityservershadow>1</authorityservershadow>
278
 <authorityservershadow>1</authorityservershadow>
279
 <pluginsdir>__PLUGINS_DIR__</pluginsdir>
279
 <pluginsdir>__PLUGINS_DIR__</pluginsdir>
280
 <enable_plugins>0</enable_plugins>
280
 <enable_plugins>0</enable_plugins>
281
 <upload_path></upload_path>
281
 <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
282
 <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
282
 <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
283
 <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
283
 <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>
284
 <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>
(-)a/installer/data/mysql/kohastructure.sql (+11 lines)
Lines 3184-3189 CREATE TABLE IF NOT EXISTS `borrower_modifications` ( Link Here
3184
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3184
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3185
3185
3186
--
3186
--
3187
-- Table structure for table uploaded_files
3188
--
3189
3190
DROP TABLE IF EXISTS uploaded_files;
3191
CREATE TABLE uploaded_files (
3192
    id CHAR(40) NOT NULL PRIMARY KEY,
3193
    filename TEXT NOT NULL,
3194
    dir TEXT NOT NULL
3195
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3196
3197
--
3187
-- Table structure for table linktracker
3198
-- Table structure for table linktracker
3188
-- This stores clicks to external links
3199
-- This stores clicks to external links
3189
--
3200
--
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "XXX";
7071
if ( CheckVersion($DBversion) ) {
7072
    $dbh->do("
7073
        CREATE TABLE uploaded_files (
7074
            id CHAR(40) NOT NULL PRIMARY KEY,
7075
            filename TEXT NOT NULL,
7076
            dir TEXT NOT NULL
7077
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7078
    ");
7079
7080
    print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
7081
    print "This plugin comes with a new config variable (upload_path) and a new table (uploaded_files)\n";
7082
    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";
7083
    SetVersion($DBversion);
7084
}
7085
7070
=head1 FUNCTIONS
7086
=head1 FUNCTIONS
7071
7087
7072
=head2 TableExists($table)
7088
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt (-10 / +70 lines)
Lines 120-126 function Changefwk(FwkList) { Link Here
120
                    <span class="subfield-label">&nbsp;
120
                    <span class="subfield-label">&nbsp;
121
                    [% UNLESS ( subfiel.hide_marc ) %][% subfiel.marc_subfield %][% END %]
121
                    [% UNLESS ( subfiel.hide_marc ) %][% subfiel.marc_subfield %][% END %]
122
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
122
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
123
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
123
                    [% IF ( subfiel.is_url ) %]
124
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
125
                    [% ELSIF ( subfiel.is_file ) %]
126
                        [% subfiel.marc_value %]
127
                    [% ELSE %]
128
                        [% subfiel.marc_value |html %]
129
                    [% END %]
124
                    [% IF ( subfiel.link ) %]
130
                    [% IF ( subfiel.link ) %]
125
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
131
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
126
                            <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 %]" />
132
                            <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 %]" />
Lines 150-156 function Changefwk(FwkList) { Link Here
150
                    <span class="subfield-label">&nbsp;
156
                    <span class="subfield-label">&nbsp;
151
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
157
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
152
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
158
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
153
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
159
                    [% IF ( subfiel.is_url ) %]
160
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
161
                    [% ELSIF ( subfiel.is_file ) %]
162
                        [% subfiel.marc_value %]
163
                    [% ELSE %]
164
                        [% subfiel.marc_value |html %]
165
                    [% END %]
154
                    [% IF ( subfiel.link ) %]
166
                    [% IF ( subfiel.link ) %]
155
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
167
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
156
                            <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 %]" />
168
                            <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 %]" />
Lines 180-186 function Changefwk(FwkList) { Link Here
180
                    <span class="subfield-label">&nbsp;
192
                    <span class="subfield-label">&nbsp;
181
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
193
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
182
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
194
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
183
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
195
                    [% IF ( subfiel.is_url ) %]
196
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
197
                    [% ELSIF ( subfiel.is_file ) %]
198
                        [% subfiel.marc_value %]
199
                    [% ELSE %]
200
                        [% subfiel.marc_value |html %]
201
                    [% END %]
184
                    [% IF ( subfiel.link ) %]
202
                    [% IF ( subfiel.link ) %]
185
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
203
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
186
                            <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 %]" />
204
                            <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 %]" />
Lines 210-216 function Changefwk(FwkList) { Link Here
210
                    <span class="subfield-label">&nbsp;
228
                    <span class="subfield-label">&nbsp;
211
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
229
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
212
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
230
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
213
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
231
                    [% IF ( subfiel.is_url ) %]
232
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
233
                    [% ELSIF ( subfiel.is_file ) %]
234
                        [% subfiel.marc_value %]
235
                    [% ELSE %]
236
                        [% subfiel.marc_value |html %]
237
                    [% END %]
214
                    [% IF ( subfiel.link ) %]
238
                    [% IF ( subfiel.link ) %]
215
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
239
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
216
                            <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
                            <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 %]" />
Lines 240-246 function Changefwk(FwkList) { Link Here
240
                    <span class="subfield-label">&nbsp;
264
                    <span class="subfield-label">&nbsp;
241
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
265
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
242
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
266
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
243
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
267
                    [% IF ( subfiel.is_url ) %]
268
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
269
                    [% ELSIF ( subfiel.is_file ) %]
270
                        [% subfiel.marc_value %]
271
                    [% ELSE %]
272
                        [% subfiel.marc_value |html %]
273
                    [% END %]
244
                    [% IF ( subfiel.link ) %]
274
                    [% IF ( subfiel.link ) %]
245
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
275
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
246
                            <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 %]" />
276
                            <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 %]" />
Lines 270-276 function Changefwk(FwkList) { Link Here
270
                    <span class="subfield-label">&nbsp;
300
                    <span class="subfield-label">&nbsp;
271
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
301
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
272
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
302
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
273
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
303
                    [% IF ( subfiel.is_url ) %]
304
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
305
                    [% ELSIF ( subfiel.is_file ) %]
306
                        [% subfiel.marc_value %]
307
                    [% ELSE %]
308
                        [% subfiel.marc_value |html %]
309
                    [% END %]
274
                    [% IF ( subfiel.link ) %]
310
                    [% IF ( subfiel.link ) %]
275
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
311
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
276
                            <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 %]" />
312
                            <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 %]" />
Lines 300-306 function Changefwk(FwkList) { Link Here
300
                    <span class="subfield-label">&nbsp;
336
                    <span class="subfield-label">&nbsp;
301
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
337
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
302
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
338
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
303
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
339
                    [% IF ( subfiel.is_url ) %]
340
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
341
                    [% ELSIF ( subfiel.is_file ) %]
342
                        [% subfiel.marc_value %]
343
                    [% ELSE %]
344
                        [% subfiel.marc_value |html %]
345
                    [% END %]
304
                    [% IF ( subfiel.link ) %]
346
                    [% IF ( subfiel.link ) %]
305
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
347
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
306
                            <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 %]" />
348
                            <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 %]" />
Lines 330-336 function Changefwk(FwkList) { Link Here
330
                    <span class="subfield-label">&nbsp;
372
                    <span class="subfield-label">&nbsp;
331
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
373
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
332
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
374
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
333
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
375
                    [% IF ( subfiel.is_url ) %]
376
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
377
                    [% ELSIF ( subfiel.is_file ) %]
378
                        [% subfiel.marc_value %]
379
                    [% ELSE %]
380
                        [% subfiel.marc_value |html %]
381
                    [% END %]
334
                    [% IF ( subfiel.link ) %]
382
                    [% IF ( subfiel.link ) %]
335
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
383
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
336
                            <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 %]" />
384
                            <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 %]" />
Lines 360-366 function Changefwk(FwkList) { Link Here
360
                    <span class="subfield-label">&nbsp;
408
                    <span class="subfield-label">&nbsp;
361
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
409
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
362
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
410
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
363
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
411
                    [% IF ( subfiel.is_url ) %]
412
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
413
                    [% ELSIF ( subfiel.is_file ) %]
414
                        [% subfiel.marc_value |html %]
415
                    [% ELSE %]
416
                        [% subfiel.marc_value |html %]
417
                    [% END %]
364
                    [% IF ( subfiel.link ) %]
418
                    [% IF ( subfiel.link ) %]
365
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
419
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
366
                            <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 %]" />
420
                            <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 %]" />
Lines 390-396 function Changefwk(FwkList) { Link Here
390
                    <span class="subfield-label">&nbsp;
444
                    <span class="subfield-label">&nbsp;
391
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
445
                    [% UNLESS ( subfiel.hide_marc ) %]<b>[% subfiel.marc_subfield %]</b>[% END %]
392
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
446
                    <span title="[% subfiel.long_desc %]">[% subfiel.short_desc %]</span></span>
393
                    [% IF ( subfiel.is_url ) %]<a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>[% ELSE %][% subfiel.marc_value |html %][% END %]
447
                    [% IF ( subfiel.is_url ) %]
448
                        <a href="[% subfiel.marc_value %]">[% subfiel.marc_value |html %]</a>
449
                    [% ELSIF ( subfiel.is_file ) %]
450
                        [% subfiel.marc_value %]
451
                    [% ELSE %]
452
                        [% subfiel.marc_value |html %]
453
                    [% END %]
394
                    [% IF ( subfiel.link ) %]
454
                    [% IF ( subfiel.link ) %]
395
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
455
                        <a href="/cgi-bin/koha/catalogue/search.pl?op=do_search&amp;idx=[% subfiel.link %],phr&amp;type=intranet&amp;q=[% subfiel.marc_value |url %]">
396
                            <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 %]" />
456
                            <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 %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/upload.tt (+77 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="[% interface %]/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
        [% IF (error_upload_path_not_configured) %]
58
            <h2>Configuration error</h2>
59
            <p>Configuration variable 'upload_path' is not configured.</p>
60
            <p>Please configure it in your koha-conf.xml</p>
61
        [% ELSE %]
62
            <h2>Please select the file to upload : </h2>
63
            <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl">
64
                [% filefield %]
65
                <h3>Choose where to upload file</h3>
66
                [% INCLUDE list_dirs dirs = dirs_tree %]
67
                <input type="hidden" name="plugin_name" value="upload.pl" />
68
                <input type="hidden" name="index" value="[% index %]" />
69
                <input type="submit">
70
            </form>
71
        [% END %]
72
    [% END %]
73
74
[% END %]
75
76
</body>
77
</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/misc/strip_value_from_tag.pl (+60 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This script takes every biblio record in the database,
4
# looks for a value beginning with $find in $fieldtag$$subfieldtag
5
# and strips $find from this value.
6
# This was originally made for the file upload plugin, but might
7
# be used for other purposes.
8
9
use Modern::Perl;
10
11
use Getopt::Long;
12
use C4::Context;
13
use C4::Biblio;
14
15
my $debug = 0;
16
17
# Which field are we processing?
18
my $fieldtag = "857";
19
my $subfieldtag = "u";
20
21
# Whichi beginning pattern are we looking to delete?
22
my $find = "http://myurl.tld/";
23
my $length = length($find);
24
my $pattern = qr|^$find|;
25
26
print "Field $fieldtag\$$subfieldtag\n";
27
28
# Getting db connection
29
my $dbh = C4::Context->dbh;
30
31
# Getting max bibnumber
32
my $query = "SELECT MAX(biblionumber) from biblio";
33
my $sth = $dbh->prepare($query);
34
$sth->execute();
35
my $bibliocount = $sth->fetchrow;
36
37
warn "unable to get biblio count" and exit -1 unless $bibliocount;
38
39
print "Biblio count : $bibliocount\n";
40
41
# Foreach each biblio
42
foreach (1..$bibliocount) {
43
    my $found = 0;
44
    my $record = GetMarcBiblio($_);
45
    $debug and warn "unable to get marc for record $_" unless $record;
46
    next unless $record;
47
    foreach my $field ($record->field($fieldtag)) {
48
        my $newfield = $field->clone();
49
        my $subfield = $newfield->subfield($subfieldtag);
50
        if ($subfield and $subfield =~ $pattern) {
51
            my $newsubfield = substr $subfield, $length;
52
             $newsubfield =~ s/\s+$//;
53
             $newfield->update($subfieldtag, $newsubfield);
54
             $field->replace_with($newfield);
55
             $found = 1;
56
         }
57
    }
58
    print "processing $_\n" if ($found == 1);
59
    ModBiblioMarc($record, $_, GetFrameworkCode($_)) if ($found == 1);
60
}
(-)a/opac/opac-basket.pl (-1 / +1 lines)
Lines 69-75 foreach my $biblionumber ( @bibs ) { Link Here
69
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
69
    my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
70
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
70
    my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
71
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
71
    my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
72
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
72
    my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour, GetFrameworkCode($biblionumber));
73
    my @items            = &GetItemsInfo( $biblionumber );
73
    my @items            = &GetItemsInfo( $biblionumber );
74
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
74
    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
75
75
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 634-640 my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); Link Here
634
my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
634
my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
635
my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
635
my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
636
my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
636
my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
637
my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
637
my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour, $dat->{'frameworkcode'});
638
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
638
my $marchostsarray  = GetMarcHosts($record,$marcflavour);
639
my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
639
my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
640
640
(-)a/opac/opac-retrieve-file.pl (+50 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
8
# under the terms of the GNU General Public License as published
9
# by the Free Software Foundation; either version 2 of the
10
# License, or (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public
18
# License along with Koha; if not, write to the
19
#    Free Software Foundation, Inc.
20
#    51 Franklin Street, Fifth Floor
21
#    Boston, MA 02110-1301 USA.
22
23
use Modern::Perl;
24
use CGI;
25
26
use C4::Context;
27
use C4::UploadedFiles;
28
29
my $input = new CGI;
30
31
my $id = $input->param('id');
32
my $file = C4::UploadedFiles::GetUploadedFile($id);
33
exit 1 if not $file;
34
35
my $file_path = $file->{filepath};
36
37
if( -f $file_path ) {
38
    open my $fh, '<', $file_path or die "Can't open file: $!";
39
    print $input->header(
40
        -type => "application/octet-stream",
41
        -attachment => $file->{filename}
42
    );
43
    while(<$fh>) {
44
        print $_;
45
    }
46
} else {
47
    exit 1;
48
}
49
50
exit 0;
(-)a/t/db_dependent/UploadedFiles.t (-1 / +42 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use File::Temp qw/ tempdir /;
5
use Test::CGI::Multipart;
6
use Test::More tests => 11;
7
8
use t::lib::Mocks;
9
10
use C4::Context;
11
use C4::UploadedFiles;
12
13
# This simulates a multipart POST request with a file upload.
14
my $tcm = new Test::CGI::Multipart;
15
$tcm->upload_file(
16
    name => 'testfile',
17
    file => 'testfilename.txt',
18
    value => "This is the content of testfilename.txt",
19
);
20
my $cgi = $tcm->create_cgi;
21
22
my $tempdir = tempdir(CLEANUP => 1);
23
t::lib::Mocks::mock_config('upload_path', $tempdir);
24
25
my $testfilename = $cgi->param('testfile');
26
my $testfile_fh = $cgi->upload('testfile');
27
my $id = C4::UploadedFiles::UploadFile($testfilename, '', $testfile_fh->handle);
28
ok($id, "File uploaded, id is $id");
29
30
my $file = C4::UploadedFiles::GetUploadedFile($id);
31
isa_ok($file, 'HASH', "GetUploadedFiles($id)");
32
foreach my $key (qw(id filename filepath dir)) {
33
    ok(exists $file->{$key}, "GetUploadedFile($id)->{$key} exists");
34
}
35
36
ok(-e $file->{filepath}, "File $file->{filepath} exists");
37
38
ok(C4::UploadedFiles::DelUploadedFile($id), "DelUploadedFile($id) returned true");
39
ok(! -e $file->{filepath}, "File $file->{filepath} does not exist anymore");
40
41
is(C4::UploadedFiles::UploadFile($testfilename, '../', $testfile_fh->handle), undef, 'UploadFile with $dir containing ".." return undef');
42
is(C4::UploadedFiles::GetUploadedFile(), undef, 'GetUploadedFile without parameters returns undef');

Return to bug 6874