Bugzilla – Attachment 92337 Details for
Bug 23281
Add Koha::Objects::Limit::Library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23281: Add Koha::Objects::Limit::Library
Bug-23281-Add-KohaObjectsLimitLibrary.patch (text/plain), 3.23 KB, created by
Katrin Fischer
on 2019-08-17 19:23:05 UTC
(
hide
)
Description:
Bug 23281: Add Koha::Objects::Limit::Library
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-08-17 19:23:05 UTC
Size:
3.23 KB
patch
obsolete
>From 8ccdefd955f9162d47970f49477e64e8a4f98d16 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 8 Jul 2019 14:13:12 -0300 >Subject: [PATCH] Bug 23281: Add Koha::Objects::Limit::Library > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Objects/Limit/Library.pm | 86 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > create mode 100644 Koha/Objects/Limit/Library.pm > >diff --git a/Koha/Objects/Limit/Library.pm b/Koha/Objects/Limit/Library.pm >new file mode 100644 >index 0000000000..2b54370d23 >--- /dev/null >+++ b/Koha/Objects/Limit/Library.pm >@@ -0,0 +1,86 @@ >+package Koha::Objects::Limit::Library; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+=head1 NAME >+ >+Koha::Objects::Limit::Library - Generic library limit handling class >+ >+=head1 SYNOPSIS >+ >+ use base qw(Koha::Objects Koha::Object::Limit::Library); >+ my $objects = Koha::Objects->search_with_library_limits( $params, $attributes, $library_id ); >+ >+=head1 DESCRIPTION >+ >+This class is provided as a generic way of handling library limits for Koha::Objects-based classes >+in Koha. >+ >+This class must always be subclassed. >+ >+=head1 API >+ >+=head2 Class methods >+ >+=cut >+ >+=head3 search_with_library_limits >+ >+my $results = $objects->search_with_library_limits( $params, $attributes, $library_id ); >+ >+Wrapper method for searching objects with library limits, respecting those >+limits >+ >+=cut >+ >+sub search_with_library_limits { >+ my ( $self, $params, $attributes, $library_id ) = @_; >+ >+ return $self->SUPER::search( $params, $attributes ) unless $library_id; >+ >+ my $library_limits = $self->object_class()->_library_limits; >+ my $library_limits_table >+ = Koha::Database->new->schema->resultset( $library_limits->{class} )->result_source->name; >+ my $library_field = $library_limits->{library}; >+ >+ my $where = { >+ '-or' => [ >+ "$library_limits_table.$library_field" => undef, >+ "$library_limits_table.$library_field" => $library_id, >+ ] >+ }; >+ >+ $attributes //= {}; >+ if ( exists $attributes->{join} ) { >+ if ( ref $attributes->{join} eq 'ARRAY' ) { >+ push @{ $attributes->{join} }, "$library_limits_table"; >+ } >+ else { >+ $attributes->{join} = [ $attributes->{join}, "$library_limits_table" ]; >+ } >+ } >+ else { >+ $attributes->{join} = $library_limits_table; >+ } >+ >+ return $self->search( { %$params, %$where, }, $attributes ); >+} >+ >+1; >-- >2.11.0
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 23281
:
91415
|
91416
|
91417
|
91459
|
91460
|
91461
| 92337 |
92338
|
92339