BZ4104: Removes tagging in staff client
[koha.git] / svc / config / systempreferences
blob0a96c7574cae1999435a5053441c579a75d98fd8
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 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
10 # version.
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
21 use strict;
22 use warnings;
24 use C4::Context;
25 use C4::Service;
26 use C4::Log;
28 =head1 NAME
30 svc/config/systempreferences - Web service for setting system preferences
32 =head1 SYNOPSIS
34 POST /svc/config/systempreferences/insecure
35 POST /svc/config/systempreferences/
37 =head1 DESCRIPTION
39 This service is used to set system preferences, either one at a time or in
40 batches.
42 =head1 METHODS
44 =cut
46 our ( $query, $response ) = C4::Service->init( parameters => 1 );
48 =head2 set_preference
50 =over 4
52 POST /svc/config/systempreferences/$preference
54 value=$value
56 =back
58 Used to set a single system preference.
60 =cut
62 sub set_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
76 =over 4
78 POST /svc/config/systempreferences/
80 pref_$pref1=$value1&pref_$pref2=$value2
82 =back
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
90 =cut
92 sub set_preferences {
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 ],