Bugzilla – Attachment 188583 Details for
Bug 40481
The items table on koha/opac-MARCdetail.pl does not honor OPACHiddenItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40841: Add Z39.50 library limits
4b174a1.patch (text/plain), 4.33 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-29 18:06:07 UTC
(
hide
)
Description:
Bug 40841: Add Z39.50 library limits
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-29 18:06:07 UTC
Size:
4.33 KB
patch
obsolete
>From 4b174a1575f3f3fabf22445a326183aaa244471b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 29 Oct 2025 09:36:13 -0300 >Subject: [PATCH] Bug 40841: Add Z39.50 library limits > >This patch adds the library limits mixin to the Z39.50 classes following >a well established pattern in Koha. >--- > Koha/Z3950Server.pm | 16 +++++++- > Koha/Z3950Servers.pm | 2 +- > t/db_dependent/Koha/Z3950Servers.t | 65 +++++++++++++++++++++++++++++- > 3 files changed, 79 insertions(+), 4 deletions(-) > >diff --git a/Koha/Z3950Server.pm b/Koha/Z3950Server.pm >index f4296e30e4c..7c80c7a4bb7 100644 >--- a/Koha/Z3950Server.pm >+++ b/Koha/Z3950Server.pm >@@ -19,7 +19,7 @@ use Modern::Perl; > > use Koha::Database; > >-use base qw(Koha::Object); >+use base qw(Koha::Object Koha::Object::Limit::Library); > > =head1 NAME > >@@ -27,10 +27,22 @@ Koha::Z3950Server - Koha Z3950Server Object class > > =head1 API > >-=head2 Class Methods >+=head2 Internal methods >+ >+=head3 _library_limits >+ >+Configure library limits for Z39.50 servers > > =cut > >+sub _library_limits { >+ return { >+ class => "Z3950serversBranch", >+ id => "server_id", >+ library => "branchcode", >+ }; >+} >+ > =head3 _type > > Return type of Object relating to Schema ResultSet >diff --git a/Koha/Z3950Servers.pm b/Koha/Z3950Servers.pm >index 1cab6800137..968c7efcd19 100644 >--- a/Koha/Z3950Servers.pm >+++ b/Koha/Z3950Servers.pm >@@ -21,7 +21,7 @@ use Koha::Database; > > use Koha::Z3950Server; > >-use base qw(Koha::Objects); >+use base qw(Koha::Objects Koha::Objects::Limit::Library); > > =head1 NAME > >diff --git a/t/db_dependent/Koha/Z3950Servers.t b/t/db_dependent/Koha/Z3950Servers.t >index 6ae9f91fb19..66f1ef8a885 100755 >--- a/t/db_dependent/Koha/Z3950Servers.t >+++ b/t/db_dependent/Koha/Z3950Servers.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > use Test::NoWarnings; >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -105,3 +105,66 @@ subtest 'Host, syntax and encoding are NOT NULL now (BZ 30571)' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'library_limits' => sub { >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $server = $builder->build_object( >+ { >+ class => 'Koha::Z3950Servers', >+ value => { >+ host => 'test.example.com', >+ port => 210, >+ db => 'testdb' >+ } >+ } >+ ); >+ >+ # Test adding library limit >+ $server->add_library_limit( $library1->branchcode ); >+ my $limits = $server->library_limits(); >+ is( $limits->count, 1, 'One library limit added' ); >+ is( $limits->next->branchcode, $library1->branchcode, 'Correct library limit' ); >+ >+ # Test search with library limits >+ my $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $server->id }, >+ {}, >+ $library1->branchcode >+ ); >+ is( $servers->count, 1, 'Server found for authorized library' ); >+ >+ $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $server->id }, >+ {}, >+ $library2->branchcode >+ ); >+ is( $servers->count, 0, 'Server not found for unauthorized library' ); >+ >+ # Test replacing library limits >+ $server->library_limits( [ $library1->branchcode, $library2->branchcode ] ); >+ $limits = $server->library_limits(); >+ is( $limits->count, 2, 'Two library limits set' ); >+ >+ # Test removing library limit >+ $server->del_library_limit( $library1->branchcode ); >+ $limits = $server->library_limits(); >+ is( $limits->count, 1, 'One library limit remains' ); >+ is( $limits->next->branchcode, $library2->branchcode, 'Correct remaining limit' ); >+ >+ # Test server with no limits (available to all) >+ my $unrestricted_server = $builder->build_object( { class => 'Koha::Z3950Servers' } ); >+ $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $unrestricted_server->id }, >+ {}, >+ $library1->branchcode >+ ); >+ is( $servers->count, 1, 'Unrestricted server available to all libraries' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.51.2
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 40481
:
188582
|
188583
|
188584
|
188585
|
188586