5 # Routines for handling Z39.50 lookups
7 # Koha library project www.koha.org
9 # Licensed under the GPL
12 # Copyright 2000-2002 Katipo Communications
14 # This file is part of Koha.
16 # Koha is free software; you can redistribute it and/or modify it under the
17 # terms of the GNU General Public License as published by the Free Software
18 # Foundation; either version 2 of the License, or (at your option) any later
21 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License along with
26 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
27 # Suite 330, Boston, MA 02111-1307 USA
31 # standard or CPAN modules used
42 use vars qw($VERSION @ISA @EXPORT);
44 # set the version for version checking
49 C4::Z3950 - Functions dealing with Z39.50 queries
57 This module contains functions for looking up Z39.50 servers, and for
58 entering Z39.50 lookup requests.
72 #------------------------------------------------
75 @servers= &getz3950servers(checked);
77 Returns the list of declared z3950 servers
79 C<$checked> should always be true (1) => returns only active servers.
80 If 0 => returns all servers
85 my $dbh = C4::Context->dbh;
88 $sth = $dbh->prepare("select * from z3950servers where checked=1");
90 $sth = $dbh->prepare("select * from z3950servers");
93 while ( my ($host, $port, $db, $userid, $password,$servername) = $sth->fetchrow ) {
94 push @result, "$servername/$host\:$port/$db/$userid/$password";
101 $name = &z3950servername($dbh, $server_id, $default_name);
103 Looks up a Z39.50 server by ID number, and returns its full name. If
104 the server is not found, returns C<$default_name>.
106 C<$server_id> is the Z39.50 server ID to look up.
113 sub z3950servername {
115 my ($srvid, # server id number
121 my $dbh = C4::Context->dbh;
123 my $sti=$dbh->prepare("select name from z3950servers where id=?");
125 $sti->execute($srvid);
127 ($longname)=$sti->fetchrow;
130 $longname="$default";
133 } # sub z3950servername
135 #---------------------------------------
146 Koha Developement team <info@koha.org>
150 #--------------------------------------
151 ##No more deamon to start. Z3950 now handled by ZOOM asynch mode-TG
153 # Revision 1.12 2006/09/01 22:16:00 tgarip1957
155 # Event & Net::Z3950 dependency removed
156 # HTML::Template::Pro dependency added
158 # Revision 1.10 2003/10/01 15:08:14 tipaul
159 # fix fog bug #622 : processz3950queue fails
161 # Revision 1.9 2003/04/29 16:50:51 tipaul
162 # really proud of this commit :-)
163 # z3950 search and import seems to works fine.
164 # Let me explain how :
165 # * a "search z3950" button is added in the addbiblio template.
166 # * when clicked, a popup appears and z3950/search.pl is called
167 # * z3950/search.pl calls addz3950search in the DB
168 # * the z3950 daemon retrieve the records and stores them in z3950results AND in marc_breeding table.
169 # * as long as there as searches pending, the popup auto refresh every 2 seconds, and says how many searches are pending.
170 # * when the user clicks on a z3950 result => the parent popup is called with the requested biblio, and auto-filled
173 # * character encoding support : (It's a nightmare...) In the z3950servers table, a "encoding" column has been added. You can put "UNIMARC" or "USMARC" in this column. Depending on this, the char_decode in C4::Biblio.pm replaces marc-char-encode by an iso 8859-1 encoding. Note that in the breeding import this value has been added too, for a better support.
174 # * the marc_breeding and z3950* tables have been modified : they have an encoding column and the random z3950 number is stored too for convenience => it's the key I use to list only requested biblios in the popup.
176 # Revision 1.8 2003/04/29 08:09:45 tipaul
177 # z3950 support is coming...
178 # * adding a syntax column in z3950 table = this column will say wether the z3950 must be called with PerferedRecordsyntax => USMARC or PerferedRecordsyntax => UNIMARC. I tried some french UNIMARC z3950 servers, and some only send USMARC, some only UNIMARC, some can answer with both.
179 # Note this is a 1st draft. More to follow (today ? I hope).
181 # Revision 1.7 2003/02/19 01:01:06 wolfpac444
182 # Removed the unecessary $dbh argument from being passed.
183 # Resolved a few minor FIXMEs.
185 # Revision 1.6 2002/10/13 08:30:53 arensb
186 # Deleted unused variables.
187 # Removed trailing whitespace.
189 # Revision 1.5 2002/10/13 06:13:23 arensb
190 # Removed bogus #! line (this isn't a script!)
191 # Removed unused global variables.
193 # Added some explanatory comments.
194 # Added some FIXME comments.
196 # Revision 1.4 2002/10/11 12:35:35 arensb
197 # Replaced &requireDBI with C4::Context->dbh
199 # Revision 1.3 2002/08/14 18:12:52 tonnesen
200 # Added copyright statement to all .pl and .pm files
202 # Revision 1.2 2002/07/02 20:31:33 tonnesen
203 # module added from rel-1-2 branch
205 # Revision 1.1.2.5 2002/06/29 17:33:47 amillar
206 # Allow DEFAULT as input to addz3950search.
207 # Check for existence of pid file (cat crashed otherwise).
208 # Return error messages in addz3950search.
210 # Revision 1.1.2.4 2002/06/28 18:07:27 tonnesen
211 # marcimport.pl will print an error message if it can not signal the
212 # processz3950queue program. The message contains instructions for starting the
215 # Revision 1.1.2.3 2002/06/28 17:45:39 tonnesen
216 # z3950queue now listens for a -HUP signal before processing the queue. Z3950.pm
217 # sends the -HUP signal when queries are added to the queue.
219 # Revision 1.1.2.2 2002/06/26 20:54:31 tonnesen
220 # use warnings breaks on perl 5.005...
222 # Revision 1.1.2.1 2002/06/26 07:26:41 amillar
223 # New module for Z39.50 searching