Bug 22749: Make Koha::Item->hidden_in_opac respect hidelostitems
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 22 Apr 2019 15:02:02 +0000 (12:02 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 24 Apr 2019 10:39:55 +0000 (10:39 +0000)
This patch makes Koha::Item->hidden_in_opac take hidelostitems into
account when performing the calculation.

To test:
- Apply the regression tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/Item.t
=> FAIL: Tests fail because the code doesn't (yet) care about the
syspref
- Apply this patch
- Run:
 k$ prove t/db_dependent/Koha/Item.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Item.pm

index 66e0f9c..49ae8e1 100644 (file)
@@ -214,6 +214,10 @@ sub hidden_in_opac {
 
     my $rules = $params->{rules} // {};
 
+    return 1
+        if C4::Context->preference('hidelostitems') and
+           $self->itemlost > 0;
+
     my $hidden_in_opac = 0;
 
     foreach my $field ( keys %{$rules} ) {