Bugzilla – Attachment 86062 Details for
Bug 22454
Add Koha::Item::hidden_in_opac method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22454: Add Koha::Item::hidden_in_opac method
Bug-22454-Add-KohaItemhiddeninopac-method.patch (text/plain), 1.88 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-03-05 12:47:52 UTC
(
hide
)
Description:
Bug 22454: Add Koha::Item::hidden_in_opac method
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-03-05 12:47:52 UTC
Size:
1.88 KB
patch
obsolete
>From 8844cbe3ff50f0350a45a15cde755996138635c6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 5 Mar 2019 09:44:59 -0300 >Subject: [PATCH] Bug 22454: Add Koha::Item::hidden_in_opac method > >This patch adds a hidden_in_opac method that does the same calculation >done in GetHiddenItemnumbers, but for a single item, and doesn't get the >OpacHiddenItems syspref, but expects them to be passed as parameters (to >avoid multiple reads). > >To test: >- Apply this patches >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Item.t >=> SUCCESS: Tests pass! >--- > Koha/Item.pm | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index f3799eff20..66e0f9c73b 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -20,6 +20,7 @@ package Koha::Item; > use Modern::Perl; > > use Carp; >+use List::MoreUtils qw(any); > > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >@@ -192,6 +193,40 @@ sub can_article_request { > return q{}; > } > >+=head3 hidden_in_opac >+ >+my $bool = $item->hidden_in_opac({ [ rules => $rules ] }) >+ >+Returns true if item fields match the hidding criteria defined in $rules. >+Returns false otherwise. >+ >+Takes HASHref that can have the following parameters: >+ OPTIONAL PARAMETERS: >+ $rules : { <field> => [ value_1, ... ], ... } >+ >+Note: $rules inherits its structure from the parsed YAML from reading >+the I<OpacHiddenItems> system preference. >+ >+=cut >+ >+sub hidden_in_opac { >+ my ( $self, $params ) = @_; >+ >+ my $rules = $params->{rules} // {}; >+ >+ my $hidden_in_opac = 0; >+ >+ foreach my $field ( keys %{$rules} ) { >+ >+ if ( any { $self->$field eq $_ } @{ $rules->{$field} } ) { >+ $hidden_in_opac = 1; >+ last; >+ } >+ } >+ >+ return $hidden_in_opac; >+} >+ > =head3 can_be_transferred > > $item->can_be_transferred({ to => $to_library, from => $from_library }) >-- >2.21.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 22454
:
86061
|
86062
|
86501
|
86509
|
86510