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

(-)a/C4/SIP/Sip.pm (-9 / +21 lines)
Lines 11-17 use Encode; Link Here
11
use POSIX qw(strftime);
11
use POSIX qw(strftime);
12
use Socket qw(:crlf);
12
use Socket qw(:crlf);
13
use IO::Handle;
13
use IO::Handle;
14
use List::Util qw(first);
14
use List::Util qw(first any);
15
15
16
use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG);
16
use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG);
17
use C4::SIP::Sip::Checksum qw(checksum);
17
use C4::SIP::Sip::Checksum qw(checksum);
Lines 60-69 sub timestamp { Link Here
60
sub add_field {
60
sub add_field {
61
    my ($field_id, $value, $server) = @_;
61
    my ($field_id, $value, $server) = @_;
62
62
63
    if ( my $hide_fields = $server->{account}->{hide_fields} ) {
63
    return q{} if should_hide( $field_id, $value, $server );
64
        my @fields = split( ',', $hide_fields );
65
        return q{} if first { $_ eq $field_id } @fields;
66
    }
67
64
68
    my ($i, $ent);
65
    my ($i, $ent);
69
66
Lines 94-103 sub add_field { Link Here
94
sub maybe_add {
91
sub maybe_add {
95
    my ($fid, $value, $server) = @_;
92
    my ($fid, $value, $server) = @_;
96
93
97
    if ( my $hide_fields = $server->{account}->{hide_fields} ) {
94
    return q{} if should_hide( $fid, $value, $server );
98
        my @fields = split( ',', $hide_fields );
99
        return q{} if first { $_ eq $fid } @fields;
100
    }
101
95
102
    if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} && defined($value)) {
96
    if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} && defined($value)) {
103
        foreach my $regex (
97
        foreach my $regex (
Lines 114-119 sub maybe_add { Link Here
114
      : '';
108
      : '';
115
}
109
}
116
110
111
sub should_hide {
112
    my ( $field_id, $value, $server ) = @_;
113
114
    my $allow_fields = $server->{account}->{allow_fields};
115
    if ($allow_fields) {
116
        my @fields = split( ',', $allow_fields );
117
        return 1 unless first { $_ eq $field_id } @fields;
118
    }
119
120
    my $hide_fields = $server->{account}->{hide_fields};
121
    if ($hide_fields) {
122
        my @fields = split( ',', $hide_fields );
123
        return 1 if first { $_ eq $field_id } @fields;
124
    }
125
126
    return 0;
127
}
128
117
#
129
#
118
# add_count()  produce fixed four-character count field,
130
# add_count()  produce fixed four-character count field,
119
# or a string of four spaces if the count is invalid for some
131
# or a string of four spaces if the count is invalid for some
(-)a/etc/SIPconfig.xml (-1 / +2 lines)
Lines 56-62 Link Here
56
      <login id="staff"  password="staff" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" disallow_overpayment="1" />
56
      <login id="staff"  password="staff" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii" checked_in_ok="1" payment_type_writeoff="06" disallow_overpayment="1" />
57
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
57
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="utf8" />
58
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
58
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
59
      <login id="lpl-sc" password="1234" institution="LPL" />
59
      <login id="lpl-sc" password="1234" institution="LPL" allow_fields="AO,AA,AE"/>
60
      <!-- allow_fields hides all fields not in the list, it is the inverse of hide_fields ( hide_fields takes precedence ) -->
60
      <login id="lpl-sc-beacock" password="xyzzy"
61
      <login id="lpl-sc-beacock" password="xyzzy"
61
             delimiter="|" error-detect="enabled" institution="LPL"
62
             delimiter="|" error-detect="enabled" institution="LPL"
62
             send_patron_home_library_in_af="1"
63
             send_patron_home_library_in_af="1"
(-)a/t/db_dependent/SIP/Message.t (-4 / +28 lines)
Lines 62-68 subtest 'Testing Patron Status Request V2' => sub { Link Here
62
subtest 'Testing Patron Info Request V2' => sub {
62
subtest 'Testing Patron Info Request V2' => sub {
63
    my $schema = Koha::Database->new->schema;
63
    my $schema = Koha::Database->new->schema;
64
    $schema->storage->txn_begin;
64
    $schema->storage->txn_begin;
65
    plan tests => 24;
65
    plan tests => 32;
66
    $C4::SIP::Sip::protocol_version = 2;
66
    $C4::SIP::Sip::protocol_version = 2;
67
    test_request_patron_info_v2();
67
    test_request_patron_info_v2();
68
    $schema->storage->txn_rollback;
68
    $schema->storage->txn_rollback;
Lines 706-720 sub test_request_patron_info_v2 { Link Here
706
    $respcode = substr( $response, 0, 2 );
706
    $respcode = substr( $response, 0, 2 );
707
    check_field( $respcode, $response, FID_PERSONAL_NAME, 'X' . $patron2->{surname} . 'Y', 'Check customized patron name' );
707
    check_field( $respcode, $response, FID_PERSONAL_NAME, 'X' . $patron2->{surname} . 'Y', 'Check customized patron name' );
708
708
709
    # Test hide_fields
709
    undef $response;
710
    undef $response;
710
    $server->{account}->{hide_fields} = "BD,BE,BF,PB";
711
    $server->{account}->{hide_fields} = join( ",", FID_HOME_ADDR, FID_EMAIL, FID_HOME_PHONE, FID_PATRON_BIRTHDATE );
711
    $msg->handle_patron_info( $server );
712
    $msg->handle_patron_info( $server );
712
    $respcode = substr( $response, 0, 2 );
713
    $respcode = substr( $response, 0, 2 );
713
    check_field( $respcode, $response, FID_HOME_ADDR, undef, 'Home address successfully stripped from response' );
714
    check_field( $respcode, $response, FID_HOME_ADDR, undef, 'Home address successfully stripped from response' );
714
    check_field( $respcode, $response, FID_EMAIL, undef, 'Email address successfully stripped from response' );
715
    check_field( $respcode, $response, FID_EMAIL, undef, 'Email address successfully stripped from response' );
715
    check_field( $respcode, $response, FID_HOME_PHONE, undef, 'Home phone successfully stripped from response' );
716
    check_field( $respcode, $response, FID_HOME_PHONE, undef, 'Home phone successfully stripped from response' );
716
    check_field( $respcode, $response, FID_PATRON_BIRTHDATE, undef, 'Date of birth successfully stripped from response' );
717
    check_field( $respcode, $response, FID_PATRON_BIRTHDATE, undef, 'Date of birth successfully stripped from response' );
717
    $server->{account}->{hide_fields} = "";
718
    delete $server->{account}->{hide_fields};
719
720
    # Test allow_fields
721
    undef $response;
722
    $server->{account}->{allow_fields} = join( ",", FID_EMAIL, FID_HOME_PHONE );
723
    $msg->handle_patron_info( $server );
724
    $respcode = substr( $response, 0, 2 );
725
    check_field( $respcode, $response, FID_HOME_ADDR, undef, 'Home address successfully stripped from response' );
726
    check_field( $respcode, $response, FID_EMAIL, $patron2->{email}, 'Email address successfully retained in response' );
727
    check_field( $respcode, $response, FID_HOME_PHONE, $patron2->{phone}, 'Home phone successfully retained in from response' );
728
    check_field( $respcode, $response, FID_PATRON_BIRTHDATE, undef, 'Date of birth successfully stripped from response' );
729
    delete $server->{account}->{allow_fields};
730
731
    # Test hide_fields should take precedence over allow_fields
732
    undef $response;
733
    $server->{account}->{hide_fields} = join( ",", FID_HOME_ADDR, FID_EMAIL, FID_PATRON_BIRTHDATE );
734
    $server->{account}->{allow_fields} = join( ",", FID_EMAIL, FID_HOME_PHONE );
735
    $msg->handle_patron_info( $server );
736
    $respcode = substr( $response, 0, 2 );
737
    check_field( $respcode, $response, FID_HOME_ADDR, undef, 'Home address successfully stripped from response' );
738
    check_field( $respcode, $response, FID_EMAIL, undef, 'Email address successfully stripped from response' );
739
    check_field( $respcode, $response, FID_HOME_PHONE, $patron2->{phone}, 'Home phone successfully retained in from response' );
740
    check_field( $respcode, $response, FID_PATRON_BIRTHDATE, undef, 'Date of birth successfully stripped from response' );
741
    delete $server->{account}->{hide_fields};
742
    delete $server->{account}->{allow_fields};
718
743
719
    # Check empty password and verify CQ again
744
    # Check empty password and verify CQ again
720
    $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y         '.
745
    $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y         '.
721
- 

Return to bug 33926