From 02a6d2b1d016b5d6e93d01e9ab62aa9bbb8e7d3c Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Sun, 29 Apr 2012 15:41:30 -0400 Subject: [PATCH] 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 Signed-off-by: Paul Poulain --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../prog/en/modules/admin/preferences/web_services.pref | 8 +++++++- opac/svc/report | 2 +- svc/report | 4 ++-- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 49debd2da0..1edf08e0f3 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -362,3 +362,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 72e7eb2274..9d0171b3c0 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5232,6 +5232,13 @@ saved_reports table.)\n"; SetVersion($DBversion); } +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');"); + print "Upgrade to $DBversion done (Added SvcMaxReportRows syspref)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index fae1fa9829..72446751be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -1,4 +1,4 @@ -Web Services: +Web services: OAI-PMH: - - pref: OAI-PMH @@ -38,3 +38,9 @@ Web Services: - pref: ILS-DI:AuthorizedIPs class: Text - allowed IPs to use the ILS-DI services + Reporting: + - + - Only return + - pref: SvcMaxReportRows + class: integer + - rows of a report requested via the reports web service. diff --git a/opac/svc/report b/opac/svc/report index e60e9244c7..4fd8183127 100755 --- a/opac/svc/report +++ b/opac/svc/report @@ -55,7 +55,7 @@ if ($usecache) { print $query->header; my $offset = 0; -my $limit = 10; +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); diff --git a/svc/report b/svc/report index dd8f8dcee3..476475cfcc 100755 --- a/svc/report +++ b/svc/report @@ -30,7 +30,7 @@ my $query = CGI->new(); my $report = $query->param('id'); my $cache; -my $usecache = C4::Context->preference('usecache'); +my $usecache = C4::Context->ismemcached; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -66,7 +66,7 @@ print $query->header; my ( $sql, $type, $name, $notes, $cache_expiry, $public ) = get_saved_report($report); my $offset = 0; -my $limit = 10; +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); -- 2.39.5