From 196f06f556af54de8fa89c0bb4d2ae794f4823f7 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 18 Jun 2013 17:00:58 -0600 Subject: [PATCH] Bug 10486 - Allow external Z39.50 targets to be searched from the OPAC (2/2) This adds a syspref to allow toggling this behavior. Signed-off-by: Chris Cormack --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 33 ++++++++++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++ .../opac-tmpl/prog/en/modules/opac-results.tt | 4 +-- opac/opac-search.pl | 1 + 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index fbd0387..4f9d831 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -427,3 +427,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACSearchExternalTargets','0','Whether to search external targets in the OPAC','','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8727951..059ad3f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7025,6 +7025,39 @@ if(CheckVersion($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if(CheckVersion($DBversion)) { + $dbh->do( +"INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACSearchExternalTargets','0','Whether to search external targets in the OPAC','','YesNo')" + ); + $dbh->do( q{ +CREATE TABLE `external_targets` ( + `target_id` int(11) NOT NULL AUTO_INCREMENT, + `host` varchar(128) NOT NULL, + `port` int(11) NOT NULL, + `db` varchar(64) NOT NULL, + `userid` varchar(64) DEFAULT '', + `password` varchar(64) DEFAULT '', + `name` varchar(64) NOT NULL, + `syntax` varchar(64) NOT NULL, + `encoding` varchar(16) DEFAULT 'MARC-8', + PRIMARY KEY (`target_id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 + } ); + $dbh->do( q{ +CREATE TABLE `external_target_restrictions` ( + `branchcode` varchar(10) NOT NULL, + `target_id` int(11) NOT NULL, + KEY `branchcode` (`branchcode`), + KEY `target_id` (`target_id`), + CONSTRAINT `external_target_restrictions_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE, + CONSTRAINT `external_target_restrictions_ibfk_2` FOREIGN KEY (`target_id`) REFERENCES `external_targets` (`target_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf + } ); + print "Upgrade to $DBversion done (Bug 10486 - Allow external Z39.50 targets to be searched from the OPAC)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 90295ef..81c7be1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -424,6 +424,13 @@ OPAC: yes: Allow no: Do not allow - users to add a note when placing a hold. + - + - pref: OPACSearchExternalTargets + default: 0 + choices: + yes: Search + no: "Don't search" + - external targets from the OPAC. Policy: - diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt index 6e78236..d2546f5 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -14,7 +14,7 @@ [% END %] [% IF ( OverDriveEnabled ) %][% END %] -[% IF ( 1 ) %] +[% IF ( OPACSearchExternalTargets ) %] [% END %] @@ -294,7 +294,7 @@ $(document).ready(function(){ } ); [% END %] - [% IF ( 1 ) %] + [% IF ( OPACSearchExternalTargets ) %] KOHA.ExternalSearch.targets = { [% FOREACH target IN external_search_targets %] '[% target.host %]:[% target.port %]/[% target.db %]': { diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 8e6d055..aa89905 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -903,6 +903,7 @@ $template->{VARS}->{IDreamBooksReviews} = C4::Context->preference('IDreamBooksRe $template->{VARS}->{IDreamBooksReadometer} = C4::Context->preference('IDreamBooksReadometer'); $template->{VARS}->{IDreamBooksResults} = C4::Context->preference('IDreamBooksResults'); +$template->{VARS}->{OPACSearchExternalTargets} = C4::Context->preference('OPACSearchExternalTargets'); $template->{VARS}->{external_search_targets} = GetExternalSearchTargets( C4::Context->userenv ? C4::Context->userenv->{branch} : '' ); $template->{VARS}->{OverDriveLibraryID} = C4::Context->preference('OverDriveLibraryID'); -- 1.7.10.4