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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 svc/config/systempreferences - Web service for setting system preferences
34 POST /svc/config/systempreferences/
38 This service is used to set system preferences, either one at a time or in
45 our ( $query, $response ) = C4
::Service
->init( parameters
=> 1 );
51 POST /svc/config/systempreferences/$preference
57 Used to set a single system preference.
62 my ( $preference ) = @_;
64 unless ( C4
::Context
->config('demo') ) {
65 my $value = join( ',', $query->param( 'value' ) );
66 C4
::Context
->set_preference( $preference, $value );
67 logaction
( 'SYSTEMPREFERENCE', 'MODIFY', undef, $preference . " | " . $value );
70 C4
::Service
->return_success( $response );
73 =head2 set_preferences
77 POST /svc/config/systempreferences/
79 pref_$pref1=$value1&pref_$pref2=$value2
83 Used to set several system preferences at once. Each preference you want to set
84 should be sent prefixed with pref. If you wanted to turn off the
85 virtualshelves syspref, for instance, you would POST the following:
92 unless ( C4
::Context
->config( 'demo' ) ) {
93 foreach my $param ( $query->param() ) {
94 my ( $pref ) = ( $param =~ /pref_(.*)/ );
96 next if ( !defined( $pref ) );
98 my $value = join( ',', $query->param( $param ) );
100 C4
::Context
->set_preference( $pref, $value );
101 logaction
( 'SYSTEMPREFERENCE', 'MODIFY', undef, $pref . " | " . $value );
105 C4
::Service
->return_success( $response );
108 C4
::Service
->dispatch(
109 [ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \
&set_preference
],
110 [ 'POST /', [], \
&set_preferences
],