diff --git a/cataloguing/editor.pl b/cataloguing/editor.pl index b40d4c3ecc..ac41f240eb 100755 --- a/cataloguing/editor.pl +++ b/cataloguing/editor.pl @@ -30,6 +30,7 @@ use Koha::Database; use Koha::MarcSubfieldStructures; use Koha::BiblioFrameworks; use Koha::KeyboardShortcuts; +use Koha::Z3950Servers; my $input = CGI->new; @@ -76,14 +77,14 @@ $template->{VARS}->{authtags} = $authtags; my $frameworks = Koha::BiblioFrameworks->search( {}, { order_by => ['frameworktext'] } ); $template->{VARS}->{frameworks} = $frameworks; -# Z39.50 servers -my $dbh = C4::Context->dbh; -$template->{VARS}->{z3950_servers} = $dbh->selectall_arrayref( - q{ - SELECT * FROM z3950servers - WHERE recordtype != 'authority' AND servertype = 'zed' - ORDER BY `rank`,servername -}, { Slice => {} } +$template->param( + z3950_servers => Koha::Z3950Servers->search_with_library_limits( + { + recordtype => { '!=' => 'authority' }, + servertype => 'zed' + }, + { order_by => [ 'rank', 'servername' ] }, + ) ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/cataloguing/z3950_auth_search.pl b/cataloguing/z3950_auth_search.pl index 2bd0e2fbec..bbedc34d7c 100755 --- a/cataloguing/z3950_auth_search.pl +++ b/cataloguing/z3950_auth_search.pl @@ -27,6 +27,7 @@ use C4::Breeding qw( Z3950Search Z3950SearchAuth ); use MARC::Record; use Koha::Authorities; use Koha::Authority::Types; +use Koha::Z3950Servers; use C4::AuthoritiesMarc qw( GetAuthority ); my $input = CGI->new; @@ -97,13 +98,16 @@ $template->param( ); if ( $op ne "cud-do_search" ) { - my $sth = $dbh->prepare( - "SELECT id,host,servername,checked FROM z3950servers WHERE recordtype = 'authority' ORDER BY `rank`, servername" + my $servers = Koha::Z3950Servers->search_with_library_limits( + { + recordtype => 'authority', + }, + { + order_by => [ 'rank', 'servername' ], + }, ); - $sth->execute(); - my $serverloop = $sth->fetchall_arrayref( {} ); $template->param( - serverloop => $serverloop, + serverloop => $servers, opsearch => "cud-search", index => $index, ); diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl index a80cd12242..4293216226 100755 --- a/cataloguing/z3950_search.pl +++ b/cataloguing/z3950_search.pl @@ -26,6 +26,8 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Context; use C4::Breeding qw( Z3950Search ); +use Koha::Z3950Servers; + my $input = CGI->new; my $error = $input->param('error'); my $biblionumber = $input->param('biblionumber') || 0; @@ -74,19 +76,17 @@ $template->param( ); if ( $op ne "cud-do_search" ) { - my $schema = Koha::Database->new()->schema(); - my $rs = $schema->resultset('Z3950server')->search( + my $servers = Koha::Z3950Servers->search_with_library_limits( { recordtype => 'biblio', servertype => [ 'zed', 'sru' ], }, { - result_class => 'DBIx::Class::ResultClass::HashRefInflator', - order_by => [ 'rank', 'servername' ], + order_by => [ 'rank', 'servername' ], }, ); $template->param( - serverloop => [ $rs->all ], + serverloop => $servers, opsearch => "cud-search", ); output_html_with_http_headers $input, $cookie, $template->output;