Jonathan Druart
7f3feacfe3
This patch is a follow-up of bug 16154. It removes the warning "CGI::param called in list context" in the following scripts: admin/branches.pl admin/categories.pl admin/patron-attr-types.pl admin/preferences.pl catalogue/image.pl circ/circulation.pl patroncards/add_user_search.pl serials/add_user_search.pl tools/marc_modification_templates.pl virtualshelves/shelves.pl Note that the warning from catalogue/itemsearch.pl still exists (the call to CGI->param is done from the template). Test plan: - Add/modify a library, patron category, patron attr type - Update a syspref - Set localcoverimage and call catalogue/image.pl?biblionumber=XXX - Search for patrons in the patron cards or serials module - Add a marc modification templates - Add a list (shelves) You should not get the warning in the log after all these actions. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
109 lines
2.4 KiB
Perl
Executable file
109 lines
2.4 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Copyright 2009 Jesse Weaver
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
#
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use C4::Context;
|
|
use C4::Service;
|
|
use C4::Log;
|
|
|
|
=head1 NAME
|
|
|
|
svc/config/systempreferences - Web service for setting system preferences
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
POST /svc/config/systempreferences/
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This service is used to set system preferences, either one at a time or in
|
|
batches.
|
|
|
|
=head1 METHODS
|
|
|
|
=cut
|
|
|
|
our ( $query, $response ) = C4::Service->init( parameters => 1 );
|
|
|
|
=head2 set_preference
|
|
|
|
=over 4
|
|
|
|
POST /svc/config/systempreferences/$preference
|
|
|
|
value=$value
|
|
|
|
=back
|
|
|
|
Used to set a single system preference.
|
|
|
|
=cut
|
|
|
|
sub set_preference {
|
|
my ( $preference ) = @_;
|
|
|
|
unless ( C4::Context->config('demo') ) {
|
|
my $value = join( ',', $query->param( 'value' ) );
|
|
C4::Context->set_preference( $preference, $value );
|
|
}
|
|
|
|
C4::Service->return_success( $response );
|
|
}
|
|
|
|
=head2 set_preferences
|
|
|
|
=over 4
|
|
|
|
POST /svc/config/systempreferences/
|
|
|
|
pref_$pref1=$value1&pref_$pref2=$value2
|
|
|
|
=back
|
|
|
|
Used to set several system preferences at once. Each preference you want to set
|
|
should be sent prefixed with pref. If you wanted to turn off the
|
|
virtualshelves syspref, for instance, you would POST the following:
|
|
|
|
pref_virtualshelves=0
|
|
|
|
=cut
|
|
|
|
sub set_preferences {
|
|
unless ( C4::Context->config( 'demo' ) ) {
|
|
foreach my $param ( $query->param() ) {
|
|
my ( $pref ) = ( $param =~ /pref_(.*)/ );
|
|
|
|
next if ( !defined( $pref ) );
|
|
|
|
my $value = join( ',', $query->multi_param( $param ) );
|
|
|
|
C4::Context->set_preference( $pref, $value );
|
|
}
|
|
}
|
|
|
|
C4::Service->return_success( $response );
|
|
}
|
|
|
|
C4::Service->dispatch(
|
|
[ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \&set_preference ],
|
|
[ 'POST /', [], \&set_preferences ],
|
|
);
|