View | Details | Raw Unified | Return to bug 36996
Collapse All | Expand All

(-)a/Koha/Item.pm (+60 lines)
Lines 2602-2607 sub location_update_trigger { Link Here
2602
    return $messages;
2602
    return $messages;
2603
}
2603
}
2604
2604
2605
2606
=head3 z3950_status
2607
2608
    my $statuses = $item->z3950_statuses( $status_strings );
2609
2610
Returns an array of statuses for use in z3950 results. Takes a hashref listing the display strings for the
2611
various statuses. Availability is determined by item statuses and the system preference z3950Status.
2612
2613
Status strings are defined in authorised values in the Z3950_STATUS category.
2614
2615
=cut
2616
2617
sub z3950_status {
2618
    my ( $self, $status_strings ) = @_;
2619
2620
    my @statuses;
2621
2622
    if ( $self->onloan() ) {
2623
        push @statuses, $status_strings->{CHECKED_OUT};
2624
    }
2625
2626
    if ( $self->itemlost() ) {
2627
        push @statuses, $status_strings->{LOST};
2628
    }
2629
2630
    if ( $self->notforloan() ) {
2631
        push @statuses, $status_strings->{NOT_FOR_LOAN};
2632
    }
2633
2634
    if ( $self->damaged() ) {
2635
        push @statuses, $status_strings->{DAMAGED};
2636
    }
2637
2638
    if ( $self->withdrawn() ) {
2639
        push @statuses, $status_strings->{WITHDRAWN};
2640
    }
2641
2642
    if ( my $transfer = $self->get_transfer ) {
2643
        push @statuses, $status_strings->{IN_TRANSIT} if $transfer->in_transit;
2644
    }
2645
2646
    if ( C4::Reserves::GetReserveStatus( $self->itemnumber ) ne '' ) {
2647
        push @statuses, $status_strings->{ON_HOLD};
2648
    }
2649
    my $rules = C4::Context->yaml_preference('Z3950Status');
2650
    if ($rules) {
2651
        foreach my $field ( keys %$rules ) {
2652
            foreach my $value ( @{ $rules->{$field} } ) {
2653
                if ( $self->$field eq $value ) {
2654
                    push @statuses, $status_strings->{"SYSPREF"};
2655
                    last;
2656
                }
2657
            }
2658
        }
2659
    }
2660
2661
    return \@statuses;
2662
2663
}
2664
2605
=head3 _type
2665
=head3 _type
2606
2666
2607
=cut
2667
=cut
(-)a/Koha/Z3950Responder/Session.pm (-32 / +3 lines)
Lines 20-26 package Koha::Z3950Responder::Session; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use C4::Context;
22
use C4::Context;
23
use C4::Reserves qw( GetReserveStatus );
24
use C4::Search qw( new_record_from_zebra );
23
use C4::Search qw( new_record_from_zebra );
25
24
26
use Koha::Items;
25
use Koha::Items;
Lines 263-302 sub add_item_status { Link Here
263
    my $item = Koha::Items->find( $itemnumber );
262
    my $item = Koha::Items->find( $itemnumber );
264
    return unless $item;
263
    return unless $item;
265
264
266
    my @statuses;
265
    my $statuses = $item->z3950_status($status_strings);
267
268
    if ( $item->onloan() ) {
269
        push @statuses, $status_strings->{CHECKED_OUT};
270
    }
271
272
    if ( $item->itemlost() ) {
273
        push @statuses, $status_strings->{LOST};
274
    }
275
276
    if ( $item->notforloan() ) {
277
        push @statuses, $status_strings->{NOT_FOR_LOAN};
278
    }
279
280
    if ( $item->damaged() ) {
281
        push @statuses, $status_strings->{DAMAGED};
282
    }
283
284
    if ( $item->withdrawn() ) {
285
        push @statuses, $status_strings->{WITHDRAWN};
286
    }
287
288
    if ( my $transfer = $item->get_transfer ) {
289
        push @statuses, $status_strings->{IN_TRANSIT} if $transfer->in_transit;
290
    }
291
292
    if ( GetReserveStatus( $itemnumber ) ne '' ) {
293
        push @statuses, $status_strings->{ON_HOLD};
294
    }
295
266
296
    if ( $server->{add_status_multi_subfield} ) {
267
    if ( $server->{add_status_multi_subfield} ) {
297
        $field->add_subfields( map { ( $add_subfield, $_ ) } ( @statuses ? @statuses : $status_strings->{AVAILABLE} ) );
268
        $field->add_subfields( map { ( $add_subfield, $_ ) } ( @$statuses ? @$statuses : $status_strings->{AVAILABLE} ) );
298
    } else {
269
    } else {
299
        $field->add_subfields( $add_subfield, @statuses ? join( ', ', @statuses ) : $status_strings->{AVAILABLE} );
270
        $field->add_subfields( $add_subfield, @$statuses ? join( ', ', @$statuses ) : $status_strings->{AVAILABLE} );
300
    }
271
    }
301
}
272
}
302
273
(-)a/installer/data/mysql/atomicupdate/add_z3950status_syspref.pl (+21 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "36996",
6
    description => "Add z3950Status system preference",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Do you stuffs here
12
        $dbh->do(
13
            q{
14
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
15
            ('z3950Status','','','This syspref allows to define custom rules for marking items unavailable in z3950 results. See http://wiki.koha-community.org/wiki/Z3950Status for more information.','Textarea')
16
        }
17
        );
18
19
        say $out "Added new system preference 'Z3950Status'";
20
    },
21
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +2 lines)
Lines 852-856 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
852
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
852
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
853
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
853
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
854
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
854
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
855
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo')
855
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
856
('z3950Status','','','This syspref allows to define custom rules for marking items unavailable in z3950 results. See http://wiki.koha-community.org/wiki/Z3950Status for more information.','Textarea')
856
;
857
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-1 / +6 lines)
Lines 99-104 Searching: Link Here
99
            - "List of search fields (separated by | or ,) that should not be autotruncated by Elasticsearch even if <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=QueryAutoTruncate'>QueryAutoTruncate</a> is set to 'Yes':"
99
            - "List of search fields (separated by | or ,) that should not be autotruncated by Elasticsearch even if <a href='/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=QueryAutoTruncate'>QueryAutoTruncate</a> is set to 'Yes':"
100
            - pref: ESPreventAutoTruncate
100
            - pref: ESPreventAutoTruncate
101
              class: long
101
              class: long
102
        -
103
            - pref: z3950Status
104
              type: textarea
105
              syntax: text/x-yaml
106
              class: code
107
            - Define custom rules to show specific items as not available in Z3950. How to write these rules is documented on the <a href="http://wiki.koha-community.org/wiki/OpacHiddenItems" target="_blank">Koha wiki</a>.
102
    Search form:
108
    Search form:
103
        -
109
        -
104
            - pref: LoadSearchHistoryToTheFirstLoggedUser
110
            - pref: LoadSearchHistoryToTheFirstLoggedUser
105
- 

Return to bug 36996