Koha/svc/report
Jared Camins-Esakov 02a6d2b1d0 Bug 7249: Syspref to control number of rows in web service results
The original patches for bug 7249 had a hardcoded limit of ten rows in the
results returned by the web service. This patch adds a SvcMaxReportRows syspref
which allows the librarian to choose how many rows should be returned by the
web service.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
2012-05-11 10:26:33 +02:00

79 lines
2.2 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2011 Chris Cormack <chris@bigballofwax.co.nz>
#
# 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
use strict;
use warnings;
use C4::Auth;
use C4::Reports::Guided;
use JSON;
use CGI;
my $query = CGI->new();
my $report = $query->param('id');
my $cache;
my $usecache = C4::Context->ismemcached;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "intranet-main.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1, },
}
);
if ($usecache) {
require Koha::Cache;
Koha::Cache->import();
$cache = Koha::Cache->new(
{
'cache_type' => 'memcached',
'cache_servers' => $ENV{'MEMCACHED_SERVERS'}
}
);
my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha';
my $page = $cache->get_from_cache("$namespace:intranet:report:$report");
if ($page) {
print $query->header;
print $page;
exit;
}
}
print $query->header;
# $public isnt used for intranet
my ( $sql, $type, $name, $notes, $cache_expiry, $public ) =
get_saved_report($report);
my $offset = 0;
my $limit = C4::Context->preference("SvcMaxReportRows") || 10;
my ( $sth, $errors ) = execute_query( $sql, $offset, $limit );
my $lines = $sth->fetchall_arrayref;
my $json_text = to_json($lines);
print $json_text;
if ($usecache) {
my $namespace = $ENV{'MEMCACHED_NAMESPACE'} || 'koha';
$cache->set_in_cache( "$namespace:intranet:report:$report",
$json_text, $cache_expiry );
}