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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
30 svc/config/systempreferences - Web service for setting system preferences
34 POST /svc/config/systempreferences/insecure
35 POST /svc/config/systempreferences/
39 This service is used to set system preferences, either one at a time or in
46 our ( $query, $response ) = C4
::Service
->init( parameters
=> 1 );
52 POST /svc/config/systempreferences/$preference
58 Used to set a single system preference.
63 my ( $preference ) = @_;
65 unless ( C4
::Context
->config('demo') ) {
66 my $value = join( ',', $query->param( 'value' ) );
67 C4
::Context
->set_preference( $preference, $value );
68 logaction
( 'SYSTEMPREFERENCE', 'MODIFY', undef, $preference . " | " . $value );
71 C4
::Service
->return_success( $response );
74 =head2 set_preferences
78 POST /svc/config/systempreferences/
80 pref_$pref1=$value1&pref_$pref2=$value2
84 Used to set several system preferences at once. Each preference you want to set
85 should be sent prefixed with pref. If you wanted to turn off the
86 GranularPermissions syspref, for instance, you would POST the following:
88 pref_GranularPermissions=0
93 unless ( C4
::Context
->config( 'demo' ) ) {
94 foreach my $param ( $query->param() ) {
95 my ( $pref ) = ( $param =~ /pref_(.*)/ );
97 next if ( !defined( $pref ) );
99 my $value = join( ',', $query->param( $param ) );
101 C4
::Context
->set_preference( $pref, $value );
102 logaction
( 'SYSTEMPREFERENCE', 'MODIFY', undef, $pref . " | " . $value );
106 C4
::Service
->return_success( $response );
109 C4
::Service
->dispatch(
110 [ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \
&set_preference
],
111 [ 'POST /', [], \
&set_preferences
],