Bugzilla – Attachment 189525 Details for
Bug 40841
Limit z39.50 targets to specific branches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40841: Implement library limits on Z39.50 searches
Bug-40841-Implement-library-limits-on-Z3950-search.patch (text/plain), 5.58 KB, created by
David Nind
on 2025-11-12 19:28:13 UTC
(
hide
)
Description:
Bug 40841: Implement library limits on Z39.50 searches
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-11-12 19:28:13 UTC
Size:
5.58 KB
patch
obsolete
>From 5bd1efede0e78c5fa6dc681f23068df5836bb1e4 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 29 Oct 2025 17:05:52 -0300 >Subject: [PATCH] Bug 40841: Implement library limits on Z39.50 searches >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patchset implements Z39.50/SRU limits by branch in Koha. > >Key implementation notes: >- Follows Koha's established pattern for library limits >- A new table linking to library limits is added >- The admin UI is adjusted so the form includes library limit selection >- Z39.50/SRU search controllers use the `search_with_library_limits` > methods to correctly constraint the offered servers. > >To test: >1. Apply this patches >2. Run: > $ ktd --shell > k$ updatedatabase >=> SUCCESS: Database upgrade goes well >3. Re-run: > k$ updatedatabase >=> SUCCESS: No explosions, DB update idempotent >4. Restart everything: > k$ restart_all >5. POint your browser to the admin page: > http://kohadev-intra.localhost/cgi-bin/koha/admin/z3950servers.pl >=> SUCCESS: A new column is displayed for library limits brief >6. Edit `LIBRARY OF CONGRESS` >=> SUCCESS: The form includes the usual library limit selection UI >7. Choose some branches, excluding your current one (KTD's default is > 'Centerville'). >8. Save >=> SUCCESS: It is saved correctly >=> SUCCESS: The table shows the edited library has the library limits >set >9. Edit again >=> SUCCESS: The selected limits are preserved when editing >10. Pick some authorities Z39.50 target, and exclude your current branch > for testing purposes. >11. Go to Cataloguing, and choose 'New from Z39.50/SRU' >=> SUCCESS: Limits are respected! >12. Go to Authorities, and choose 'New from Z39.50/SRU' >=> SUCCESS: Limits are respected! >13. Same as 11 but with the advanced editor >=> SUCCESS: Limits are respected! >14. Sign off :-D > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > cataloguing/editor.pl | 17 +++++++++-------- > cataloguing/z3950_auth_search.pl | 14 +++++++++----- > cataloguing/z3950_search.pl | 10 +++++----- > 3 files changed, 23 insertions(+), 18 deletions(-) > >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; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40841
:
188587
|
188588
|
188589
|
188590
|
188591
|
188597
|
188598
|
188599
|
188600
|
188601
|
188602
|
188603
|
188604
|
188605
|
188606
|
189497
|
189498
|
189499
|
189500
|
189501
|
189521
|
189522
|
189523
|
189524
| 189525