Bugzilla – Attachment 92768 Details for
Bug 23272
Koha::AuthorisedValue should use Koha::Object::Limit::Library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23272: Make Koha::AuthorisedValue use Koha::Object::Limit::Library
Bug-23272-Make-KohaAuthorisedValue-use-KohaObjectL.patch (text/plain), 3.72 KB, created by
Marcel de Rooy
on 2019-09-13 06:03:56 UTC
(
hide
)
Description:
Bug 23272: Make Koha::AuthorisedValue use Koha::Object::Limit::Library
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-09-13 06:03:56 UTC
Size:
3.72 KB
patch
obsolete
>From 1054d695e9685e913bc416d260c50fc6ff37b886 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 5 Jul 2019 16:23:52 -0300 >Subject: [PATCH] Bug 23272: Make Koha::AuthorisedValue use > Koha::Object::Limit::Library >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/AuthorisedValue.pm | 123 +++++------------------------------------------- > 1 file changed, 13 insertions(+), 110 deletions(-) > >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index 898b630279..423a0308e9 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -23,7 +23,7 @@ use Carp; > > use Koha::Database; > >-use base qw(Koha::Object); >+use base qw(Koha::Object Koha::Object::Limit::Library); > > =head1 NAME > >@@ -31,106 +31,10 @@ Koha::AuthorisedValue - Koha Authorised value Object class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods > > =cut > >-=head3 branch_limitations >- >-my $limitations = $av->branch_limitations(); >- >-$av->branch_limitations( \@branchcodes ); >- >-=cut >- >-sub branch_limitations { >- my ( $self, $branchcodes ) = @_; >- >- if ($branchcodes) { >- return $self->replace_branch_limitations($branchcodes); >- } >- else { >- return $self->get_branch_limitations(); >- } >- >-} >- >-=head3 get_branch_limitations >- >-my $limitations = $av->get_branch_limitations(); >- >-=cut >- >-sub get_branch_limitations { >- my ($self) = @_; >- >- my @branchcodes = >- $self->_avb_resultset->search( { av_id => $self->id() } ) >- ->get_column('branchcode')->all(); >- >- return \@branchcodes; >-} >- >-=head3 add_branch_limitation >- >-$av->add_branch_limitation( $branchcode ); >- >-=cut >- >-sub add_branch_limitation { >- my ( $self, $branchcode ) = @_; >- >- croak("No branchcode passed in!") unless $branchcode; >- >- my $limitation = $self->_avb_resultset->update_or_create( >- { av_id => $self->id(), branchcode => $branchcode } ); >- >- return $limitation ? 1 : undef; >-} >- >-=head3 del_branch_limitation >- >-$av->del_branch_limitation( $branchcode ); >- >-=cut >- >-sub del_branch_limitation { >- my ( $self, $branchcode ) = @_; >- >- croak("No branchcode passed in!") unless $branchcode; >- >- my $limitation = >- $self->_avb_resultset->find( >- { av_id => $self->id(), branchcode => $branchcode } ); >- >- unless ($limitation) { >- my $id = $self->id(); >- carp( >-"No branch limit for branch $branchcode found for av_id $id to delete!" >- ); >- return; >- } >- >- return $limitation->delete(); >-} >- >-=head3 replace_branch_limitations >- >-$av->replace_branch_limitations( \@branchcodes ); >- >-=cut >- >-sub replace_branch_limitations { >- my ( $self, $branchcodes ) = @_; >- >- $self->_avb_resultset->search( { av_id => $self->id() } )->delete(); >- >- my @return_values = >- map { $self->add_branch_limitation($_) } @$branchcodes; >- >- return \@return_values; >-} >- > =head3 opac_description > > my $description = $av->opac_description(); >@@ -143,27 +47,26 @@ sub opac_description { > return $self->lib_opac() || $self->lib(); > } > >-=head3 _avb_resultset >+=head2 Internal methods > >-Returns the internal resultset or creates it if undefined >+=head3 _type > > =cut > >-sub _avb_resultset { >- my ($self) = @_; >- >- $self->{_avb_resultset} ||= >- Koha::Database->new()->schema()->resultset('AuthorisedValuesBranch'); >- >- $self->{_avb_resultset}; >+sub _type { >+ return 'AuthorisedValue'; > } > >-=head3 type >+=head3 _library_limits > > =cut > >-sub _type { >- return 'AuthorisedValue'; >+sub _library_limits { >+ return { >+ class => 'AuthorisedValuesBranch', >+ id => 'av_id', >+ library => 'branchcode' >+ }; > } > > =head1 AUTHOR >-- >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 23272
:
91368
|
91369
|
91462
|
91463
| 92768 |
92769
|
92775
|
93197