3 # This file is part of Koha.
5 # Copyright 2020 Koha Development Team
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 by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use JSON qw( to_json );
25 use C4::Auth qw( check_cookie_auth );
26 use C4::Output qw(:DEFAULT :ajax);
27 use Koha::AuthorisedValues;
31 svc/authorised_values - Web service for adding authorised values
37 our ( $query, $response ) = C4::Service->init( parameters => 'manage_auth_values' );
39 sub add_authorised_value {
40 my $category = $query->param('category');
41 my $value = $query->param('value');
42 my $description = $query->param('description');
43 my $opac_description = $query->param('opac_description');
44 my $image_url = $query->param('image_url');
47 my $av = Koha::AuthorisedValue->new(
49 category => $category,
50 authorised_value => $value,
52 lib_opac => $opac_description,
53 imageurl => $image_url,
58 category => $av->category,
59 value => $av->authorised_value,
60 description => $av->lib,
61 opac_description => $av->lib_opac,
62 image_url => $av->imageurl,
65 C4::Service->return_error ( $@ ) if $@;
67 C4::Service->return_success( $response );
70 C4::Service->dispatch(
71 [ 'POST /', [ 'category', 'value', 'description', 'opac_description' ], \&add_authorised_value ],