3 # Copyright 2013 Universidad Nacional de Cordoba
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use C4::Auth qw/check_cookie_auth/;
31 my ( $auth_status, $sessionID ) =
33 $input->cookie('CGISESSID'),
34 { tools => 'upload_local_cover_images' } );
36 if ( $auth_status ne "ok" ) {
40 my $action = $input->param('action');
41 my $biblionumber = $input->param('biblionumber');
42 my @imagenumbers = $input->param('imagenumber');
44 # Array to store the reponse JSON
47 if ( $action eq "delete" ) {
48 # Build a hash of valid imagenumbers fr the given biblionumber
49 my %valid_imagenumbers = map {$_ => 1} ListImagesForBiblio($biblionumber);
51 foreach my $imagenumber ( @imagenumbers ) {
52 if ( exists( $valid_imagenumbers{ $imagenumber } ) ) {
53 DelImage($imagenumber);
55 imagenumber => $imagenumber,
60 imagenumber => $imagenumber,
62 error => "MSG_INVALID_IMAGENUMBER"
71 binmode STDOUT, ":encoding(UTF-8)";
73 -type => 'application/json',
77 print to_json( $response );