Lines 25-37
use C4::Auth;
Link Here
|
25 |
use C4::Output; |
25 |
use C4::Output; |
26 |
use Koha::Upload; |
26 |
use Koha::Upload; |
27 |
|
27 |
|
28 |
my $input = CGI::->new; |
28 |
my $input = CGI::->new; |
29 |
my $op = $input->param('op') // 'new'; |
29 |
my $op = $input->param('op') // 'new'; |
30 |
my $plugin = $input->param('plugin'); |
30 |
my $plugin = $input->param('plugin'); |
31 |
my $index = $input->param('index'); # MARC editor input field id |
31 |
my $index = $input->param('index'); # MARC editor input field id |
32 |
my $term = $input->param('term'); |
32 |
my $term = $input->param('term'); |
33 |
my $id = $input->param('id'); |
33 |
my $id = $input->param('id'); |
34 |
my $msg = $input->param('msg'); |
34 |
my $msg = $input->param('msg'); |
35 |
|
35 |
|
36 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
36 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
37 |
{ template_name => "tools/upload.tt", |
37 |
{ template_name => "tools/upload.tt", |
Lines 47-96
$template->param(
Link Here
|
47 |
index => $index, |
47 |
index => $index, |
48 |
); |
48 |
); |
49 |
|
49 |
|
50 |
my $upar = $plugin? { public => 1 }: {}; |
50 |
my $upar = $plugin ? { public => 1 } : {}; |
51 |
if( $op eq 'new' ) { |
51 |
if ( $op eq 'new' ) { |
52 |
$template->param( |
52 |
$template->param( |
53 |
mode => 'new', |
53 |
mode => 'new', |
54 |
uploadcategories => Koha::Upload->getCategories, |
54 |
uploadcategories => Koha::Upload->getCategories, |
55 |
); |
55 |
); |
56 |
output_html_with_http_headers $input, $cookie, $template->output; |
56 |
output_html_with_http_headers $input, $cookie, $template->output; |
57 |
} elsif( $op eq 'search' ) { |
57 |
} elsif ( $op eq 'search' ) { |
58 |
my $h = $id? { id => $id }: { term => $term }; |
58 |
my $h = $id ? { id => $id } : { term => $term }; |
59 |
my @uploads = Koha::Upload->new( $upar )->get( $h ); |
59 |
my @uploads = Koha::Upload->new($upar)->get($h); |
60 |
$template->param( |
60 |
$template->param( |
61 |
mode => 'report', |
61 |
mode => 'report', |
62 |
msg => $msg, |
62 |
msg => $msg, |
63 |
uploads => \@uploads, |
63 |
uploads => \@uploads, |
64 |
); |
64 |
); |
65 |
output_html_with_http_headers $input, $cookie, $template->output; |
65 |
output_html_with_http_headers $input, $cookie, $template->output; |
66 |
} elsif( $op eq 'delete' ) { |
66 |
} elsif ( $op eq 'delete' ) { |
|
|
67 |
|
67 |
# delete only takes the id parameter |
68 |
# delete only takes the id parameter |
68 |
my $upl = Koha::Upload->new( $upar ); |
69 |
my $upl = Koha::Upload->new($upar); |
69 |
my ( $fn ) = $upl->delete({ id => $id }); |
70 |
my ($fn) = $upl->delete( { id => $id } ); |
70 |
my $e = $upl->err; |
71 |
my $e = $upl->err; |
71 |
my $msg = $fn? JSON::to_json({ $fn => 6 }): |
72 |
my $msg = |
72 |
$e? JSON::to_json( $e ): undef; |
73 |
$fn ? JSON::to_json( { $fn => 6 } ) |
|
|
74 |
: $e ? JSON::to_json($e) |
75 |
: undef; |
73 |
$template->param( |
76 |
$template->param( |
74 |
mode => 'deleted', |
77 |
mode => 'deleted', |
75 |
msg => $msg, |
78 |
msg => $msg, |
76 |
uploadcategories => $upl->getCategories, |
79 |
uploadcategories => $upl->getCategories, |
77 |
); |
80 |
); |
78 |
output_html_with_http_headers $input, $cookie, $template->output; |
81 |
output_html_with_http_headers $input, $cookie, $template->output; |
79 |
} elsif( $op eq 'download' ) { |
82 |
} elsif ( $op eq 'download' ) { |
80 |
my $upl = Koha::Upload->new( $upar ); |
83 |
my $upl = Koha::Upload->new($upar); |
81 |
my $rec = $upl->get({ id => $id, filehandle => 1 }); |
84 |
my $rec = $upl->get( { id => $id, filehandle => 1 } ); |
82 |
my $fh = $rec->{fh}; |
85 |
my $fh = $rec->{fh}; |
83 |
if( !$rec || !$fh ) { |
86 |
if ( !$rec || !$fh ) { |
84 |
$template->param( |
87 |
$template->param( |
85 |
mode => 'new', |
88 |
mode => 'new', |
86 |
msg => JSON::to_json({ $id => 5 }), |
89 |
msg => JSON::to_json( { $id => 5 } ), |
87 |
uploadcategories => $upl->getCategories, |
90 |
uploadcategories => $upl->getCategories, |
88 |
); |
91 |
); |
89 |
output_html_with_http_headers $input, $cookie, $template->output; |
92 |
output_html_with_http_headers $input, $cookie, $template->output; |
90 |
} else { |
93 |
} else { |
91 |
my @hdr = $upl->httpheaders( $rec->{name} ); |
94 |
my @hdr = $upl->httpheaders( $rec->{name} ); |
92 |
print Encode::encode_utf8( $input->header( @hdr ) ); |
95 |
print Encode::encode_utf8( $input->header(@hdr) ); |
93 |
while( <$fh> ) { |
96 |
while (<$fh>) { |
94 |
print $_; |
97 |
print $_; |
95 |
} |
98 |
} |
96 |
$fh->close; |
99 |
$fh->close; |
97 |
- |
|
|