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

(-)a/C4/SIP/Sip.pm (-2 / +13 lines)
Lines 13-19 use POSIX qw(strftime); Link Here
13
use Socket qw(:crlf);
13
use Socket qw(:crlf);
14
use IO::Handle;
14
use IO::Handle;
15
15
16
use Sip::Constants qw(SIP_DATETIME);
16
use Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG);
17
use Sip::Checksum qw(checksum);
17
use Sip::Checksum qw(checksum);
18
18
19
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
19
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
Lines 91-97 sub add_field { Link Here
91
#    NOTE: if zero is a valid value for your field, don't use maybe_add!
91
#    NOTE: if zero is a valid value for your field, don't use maybe_add!
92
#
92
#
93
sub maybe_add {
93
sub maybe_add {
94
    my ($fid, $value) = @_;
94
    my ($fid, $value, $server) = @_;
95
96
    if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} ) {
97
        foreach my $regex (
98
            ref $server->{account}->{screen_msg_regex} eq "ARRAY"
99
            ? @{ $server->{account}->{screen_msg_regex} }
100
            : $server->{account}->{screen_msg_regex} )
101
        {
102
            $value =~ s/$regex->{find}/$regex->{replace}/g;
103
        }
104
    }
105
95
    return (defined($value) && $value) ? add_field($fid, $value) : '';
106
    return (defined($value) && $value) ? add_field($fid, $value) : '';
96
}
107
}
97
108
(-)a/C4/SIP/Sip/MsgType.pm (-16 / +16 lines)
Lines 452-459 sub build_patron_status { Link Here
452
	    $resp .= maybe_add(FID_FEE_AMT, $patron->fee_amount);
452
	    $resp .= maybe_add(FID_FEE_AMT, $patron->fee_amount);
453
	}
453
	}
454
454
455
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg );
455
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
456
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode} )
456
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
457
      if ( $server->{account}->{send_patron_home_library_in_af} );
457
      if ( $server->{account}->{send_patron_home_library_in_af} );
458
458
459
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
459
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
Lines 556-562 sub handle_checkout { Link Here
556
        $resp .= add_field(FID_DUE_DATE, q{});
556
        $resp .= add_field(FID_DUE_DATE, q{});
557
    }
557
    }
558
558
559
	$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
559
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
560
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
560
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
561
561
562
	if ($protocol_version >= 2) {
562
	if ($protocol_version >= 2) {
Lines 593-599 sub handle_checkout { Link Here
593
	# it's not due, so leave the date blank
593
	# it's not due, so leave the date blank
594
	$resp .= add_field(FID_DUE_DATE, '');
594
	$resp .= add_field(FID_DUE_DATE, '');
595
595
596
	$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
596
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
597
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
597
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
598
598
599
	if ($protocol_version >= 2) {
599
	if ($protocol_version >= 2) {
Lines 693-699 sub handle_checkin { Link Here
693
    }
693
    }
694
694
695
    $resp .= maybe_add(FID_ALERT_TYPE, $status->alert_type) if $status->alert;
695
    $resp .= maybe_add(FID_ALERT_TYPE, $status->alert_type) if $status->alert;
696
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
696
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
697
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
697
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
698
698
699
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
699
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 997-1004 sub handle_patron_info { Link Here
997
        # Custom protocol extension to report patron internet privileges
997
        # Custom protocol extension to report patron internet privileges
998
        $resp .= maybe_add(FID_INET_PROFILE,     $patron->inet_privileges);
998
        $resp .= maybe_add(FID_INET_PROFILE,     $patron->inet_privileges);
999
999
1000
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg );
1000
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
1001
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode} )
1001
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
1002
          if ( $server->{account}->{send_patron_home_library_in_af} );
1002
          if ( $server->{account}->{send_patron_home_library_in_af} );
1003
1003
1004
        $resp .= maybe_add(FID_PRINT_LINE,       $patron->print_line);
1004
        $resp .= maybe_add(FID_PRINT_LINE,       $patron->print_line);
Lines 1043-1049 sub handle_end_patron_session { Link Here
1043
    $resp .= add_field(FID_INST_ID, $server->{ils}->institution);
1043
    $resp .= add_field(FID_INST_ID, $server->{ils}->institution);
1044
    $resp .= add_field(FID_PATRON_ID, $fields->{(FID_PATRON_ID)});
1044
    $resp .= add_field(FID_PATRON_ID, $fields->{(FID_PATRON_ID)});
1045
1045
1046
    $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg);
1046
    $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg, $server);
1047
    $resp .= maybe_add(FID_PRINT_LINE, $print_line);
1047
    $resp .= maybe_add(FID_PRINT_LINE, $print_line);
1048
1048
1049
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1049
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1077-1083 sub handle_fee_paid { Link Here
1077
    $resp .= add_field(FID_INST_ID, $inst_id);
1077
    $resp .= add_field(FID_INST_ID, $inst_id);
1078
    $resp .= add_field(FID_PATRON_ID, $patron_id);
1078
    $resp .= add_field(FID_PATRON_ID, $patron_id);
1079
    $resp .= maybe_add(FID_TRANSACTION_ID, $status->transaction_id);
1079
    $resp .= maybe_add(FID_TRANSACTION_ID, $status->transaction_id);
1080
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1080
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
1081
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1081
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1082
1082
1083
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1083
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1143-1149 sub handle_item_information { Link Here
1143
	    $resp .= add_field(FID_HOLD_PICKUP_DATE, Sip::timestamp($i));
1143
	    $resp .= add_field(FID_HOLD_PICKUP_DATE, Sip::timestamp($i));
1144
	}
1144
	}
1145
1145
1146
	$resp .= maybe_add(FID_SCREEN_MSG, $item->screen_msg);
1146
    $resp .= maybe_add(FID_SCREEN_MSG, $item->screen_msg, $server);
1147
	$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
1147
	$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
1148
    }
1148
    }
1149
1149
Lines 1193-1199 sub handle_item_status_update { Link Here
1193
	$resp .= maybe_add(FID_ITEM_PROPS, $item->sip_item_properties);
1193
	$resp .= maybe_add(FID_ITEM_PROPS, $item->sip_item_properties);
1194
    }
1194
    }
1195
1195
1196
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1196
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
1197
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1197
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1198
1198
1199
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1199
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1241-1247 sub handle_patron_enable { Link Here
1241
			       sipbool($patron->check_password($patron_pwd)));
1241
			       sipbool($patron->check_password($patron_pwd)));
1242
	}
1242
	}
1243
	$resp .= add_field(FID_VALID_PATRON, 'Y');
1243
	$resp .= add_field(FID_VALID_PATRON, 'Y');
1244
	$resp .= maybe_add(FID_SCREEN_MSG, $patron->screen_msg);
1244
    $resp .= maybe_add(FID_SCREEN_MSG, $patron->screen_msg, $server);
1245
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
1245
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
1246
    }
1246
    }
1247
1247
Lines 1310-1316 sub handle_hold { Link Here
1310
    }
1310
    }
1311
1311
1312
    $resp .= add_field(FID_INST_ID,     $ils->institution);
1312
    $resp .= add_field(FID_INST_ID,     $ils->institution);
1313
    $resp .= maybe_add(FID_SCREEN_MSG,  $status->screen_msg);
1313
    $resp .= maybe_add(FID_SCREEN_MSG,  $status->screen_msg, $server);
1314
    $resp .= maybe_add(FID_PRINT_LINE,  $status->print_line);
1314
    $resp .= maybe_add(FID_PRINT_LINE,  $status->print_line);
1315
1315
1316
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1316
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1399-1405 sub handle_renew { Link Here
1399
    }
1399
    }
1400
1400
1401
    $resp .= add_field(FID_INST_ID, $ils->institution);
1401
    $resp .= add_field(FID_INST_ID, $ils->institution);
1402
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1402
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
1403
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1403
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1404
1404
1405
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1405
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1449-1455 sub handle_renew_all { Link Here
1449
    $resp .= join('', map(add_field(FID_RENEWED_ITEMS  , $_), @renewed  ));
1449
    $resp .= join('', map(add_field(FID_RENEWED_ITEMS  , $_), @renewed  ));
1450
    $resp .= join('', map(add_field(FID_UNRENEWED_ITEMS, $_), @unrenewed));
1450
    $resp .= join('', map(add_field(FID_UNRENEWED_ITEMS, $_), @unrenewed));
1451
1451
1452
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1452
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
1453
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1453
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1454
1454
1455
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1455
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
Lines 1549-1555 sub send_acs_status { Link Here
1549
	$msg .= add_field(FID_SUPPORTED_MSGS, $supported_msgs);
1549
	$msg .= add_field(FID_SUPPORTED_MSGS, $supported_msgs);
1550
    }
1550
    }
1551
1551
1552
    $msg .= maybe_add(FID_SCREEN_MSG, $screen_msg);
1552
    $msg .= maybe_add(FID_SCREEN_MSG, $screen_msg, $server);
1553
1553
1554
    if (defined($account->{print_width}) && defined($print_line)
1554
    if (defined($account->{print_width}) && defined($print_line)
1555
	&& $account->{print_width} < length($print_line)) {
1555
	&& $account->{print_width} < length($print_line)) {
(-)a/etc/SIPconfig.xml (-2 / +4 lines)
Lines 42-48 Link Here
42
      <login id="lpl-sc" password="1234" institution="LPL" />
42
      <login id="lpl-sc" password="1234" institution="LPL" />
43
      <login id="lpl-sc-beacock" password="xyzzy"
43
      <login id="lpl-sc-beacock" password="xyzzy"
44
             delimiter="|" error-detect="enabled" institution="LPL"
44
             delimiter="|" error-detect="enabled" institution="LPL"
45
             send_patron_home_library_in_af="1" />
45
             send_patron_home_library_in_af="1" >
46
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
47
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
48
      </login>
46
  </accounts>
49
  </accounts>
47
50
48
<!--
51
<!--
49
- 

Return to bug 12571