Bug 15287: (follow-up) QA fix for position of user icon
[koha.git] / svc / config / systempreferences
blob675c1605cc376cdbd824cb3795d44b840861190a
1 #!/usr/bin/perl
3 # Copyright 2009 Jesse Weaver
5 # This file is part of Koha.
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>.
21 use Modern::Perl;
23 use C4::Context;
24 use C4::Service;
25 use C4::Log;
27 =head1 NAME
29 svc/config/systempreferences - Web service for setting system preferences
31 =head1 SYNOPSIS
33 POST /svc/config/systempreferences/
35 =head1 DESCRIPTION
37 This service is used to set system preferences, either one at a time or in
38 batches.
40 =head1 METHODS
42 =cut
44 our ( $query, $response ) = C4::Service->init( parameters => 'parameters_remaining_permissions' );
46 =head2 set_preference
48 =over 4
50 POST /svc/config/systempreferences/$preference
52 value=$value
54 =back
56 Used to set a single system preference.
58 =cut
60 sub set_preference {
61 my ( $preference ) = @_;
63 unless ( C4::Context->config('demo') ) {
64 my $value = join( ',', $query->param( 'value' ) );
65 C4::Context->set_preference( $preference, $value );
68 C4::Service->return_success( $response );
71 =head2 set_preferences
73 =over 4
75 POST /svc/config/systempreferences/
77 pref_$pref1=$value1&pref_$pref2=$value2
79 =back
81 Used to set several system preferences at once. Each preference you want to set
82 should be sent prefixed with pref. If you wanted to turn off the
83 virtualshelves syspref, for instance, you would POST the following:
85 pref_virtualshelves=0
87 =cut
89 sub set_preferences {
90 unless ( C4::Context->config( 'demo' ) ) {
91 foreach my $param ( $query->param() ) {
92 my ( $pref ) = ( $param =~ /pref_(.*)/ );
94 next if ( !defined( $pref ) );
96 my $value = join( ',', $query->multi_param( $param ) );
98 C4::Context->set_preference( $pref, $value );
102 C4::Service->return_success( $response );
105 C4::Service->dispatch(
106 [ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \&set_preference ],
107 [ 'POST /', [], \&set_preferences ],