Bugzilla – Attachment 29677 Details for
Bug 12571
Add ability to customize SIP2 screen messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12571 - Add ability to customize SIP2 screen messages
Bug-12571---Add-ability-to-customize-SIP2-screen-m.patch (text/plain), 8.74 KB, created by
Kyle M Hall (khall)
on 2014-07-14 13:55:05 UTC
(
hide
)
Description:
Bug 12571 - Add ability to customize SIP2 screen messages
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2014-07-14 13:55:05 UTC
Size:
8.74 KB
patch
obsolete
>From 71f04d9e1ff4f7e32f43c23694b7696b852256ef Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 14 Jul 2014 09:50:32 -0400 >Subject: [PATCH] Bug 12571 - Add ability to customize SIP2 screen messages > >We should add the ability to apply a regular expression to screen >messages for the SIP2 server. This would allow libraries to not only >customize the screen messages the patron sees, but can also allow screen >messages to be translated. > >Test Plan: >1) Apply this patch >2) Inspect etc/SIPconfig.xml, note the new screen_msg_regex tags > that can be nested inside a given login tag. >3) Add one or more screen_msg_regex tags to your own SIP config > Recommendation: s/Greetings from Koha./Welcome to your library!/g >4) Restart your SIP2 server >5) Test with a SIP2 machine, or use /misc/sip_cli_emulator.pl >6) Note your new AF fields! >--- > C4/SIP/Sip.pm | 16 ++++++++++++++-- > C4/SIP/Sip/MsgType.pm | 32 ++++++++++++++++---------------- > etc/SIPconfig.xml | 5 ++++- > 3 files changed, 34 insertions(+), 19 deletions(-) > >diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm >index b6f1916..0cd122f 100644 >--- a/C4/SIP/Sip.pm >+++ b/C4/SIP/Sip.pm >@@ -13,7 +13,7 @@ use POSIX qw(strftime); > use Socket qw(:crlf); > use IO::Handle; > >-use Sip::Constants qw(SIP_DATETIME); >+use Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG); > use Sip::Checksum qw(checksum); > > use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); >@@ -91,7 +91,19 @@ sub add_field { > # NOTE: if zero is a valid value for your field, don't use maybe_add! > # > sub maybe_add { >- my ($fid, $value) = @_; >+ my ($fid, $value, $server) = @_; >+ >+ if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} ) { >+ foreach my $regex ( map { $_->{value} } >+ ref $server->{account}->{screen_msg_regex} eq "ARRAY" >+ ? @{ $server->{account}->{screen_msg_regex} } >+ : $server->{account}->{screen_msg_regex} ) >+ { >+ eval '$value =~ ' . $regex; >+ warn $@ if $@; >+ } >+ } >+ > return (defined($value) && $value) ? add_field($fid, $value) : ''; > } > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 4bad2ea..6c9b82a 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -452,8 +452,8 @@ sub build_patron_status { > $resp .= maybe_add(FID_FEE_AMT, $patron->fee_amount); > } > >- $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg ); >- $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode} ) >+ $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server ); >+ $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server ) > if ( $server->{account}->{send_patron_home_library_in_af} ); > > $resp .= maybe_add(FID_PRINT_LINE, $patron->print_line); >@@ -556,7 +556,7 @@ sub handle_checkout { > $resp .= add_field(FID_DUE_DATE, q{}); > } > >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > if ($protocol_version >= 2) { >@@ -593,7 +593,7 @@ sub handle_checkout { > # it's not due, so leave the date blank > $resp .= add_field(FID_DUE_DATE, ''); > >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > if ($protocol_version >= 2) { >@@ -693,7 +693,7 @@ sub handle_checkin { > } > > $resp .= maybe_add(FID_ALERT_TYPE, $status->alert_type) if $status->alert; >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -997,8 +997,8 @@ sub handle_patron_info { > # Custom protocol extension to report patron internet privileges > $resp .= maybe_add(FID_INET_PROFILE, $patron->inet_privileges); > >- $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg ); >- $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode} ) >+ $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server ); >+ $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server ) > if ( $server->{account}->{send_patron_home_library_in_af} ); > > $resp .= maybe_add(FID_PRINT_LINE, $patron->print_line); >@@ -1043,7 +1043,7 @@ sub handle_end_patron_session { > $resp .= add_field(FID_INST_ID, $server->{ils}->institution); > $resp .= add_field(FID_PATRON_ID, $fields->{(FID_PATRON_ID)}); > >- $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1077,7 +1077,7 @@ sub handle_fee_paid { > $resp .= add_field(FID_INST_ID, $inst_id); > $resp .= add_field(FID_PATRON_ID, $patron_id); > $resp .= maybe_add(FID_TRANSACTION_ID, $status->transaction_id); >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1143,7 +1143,7 @@ sub handle_item_information { > $resp .= add_field(FID_HOLD_PICKUP_DATE, Sip::timestamp($i)); > } > >- $resp .= maybe_add(FID_SCREEN_MSG, $item->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $item->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $item->print_line); > } > >@@ -1193,7 +1193,7 @@ sub handle_item_status_update { > $resp .= maybe_add(FID_ITEM_PROPS, $item->sip_item_properties); > } > >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1241,7 +1241,7 @@ sub handle_patron_enable { > sipbool($patron->check_password($patron_pwd))); > } > $resp .= add_field(FID_VALID_PATRON, 'Y'); >- $resp .= maybe_add(FID_SCREEN_MSG, $patron->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $patron->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $patron->print_line); > } > >@@ -1310,7 +1310,7 @@ sub handle_hold { > } > > $resp .= add_field(FID_INST_ID, $ils->institution); >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1399,7 +1399,7 @@ sub handle_renew { > } > > $resp .= add_field(FID_INST_ID, $ils->institution); >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1449,7 +1449,7 @@ sub handle_renew_all { > $resp .= join('', map(add_field(FID_RENEWED_ITEMS , $_), @renewed )); > $resp .= join('', map(add_field(FID_UNRENEWED_ITEMS, $_), @unrenewed)); > >- $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg); >+ $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server); > $resp .= maybe_add(FID_PRINT_LINE, $status->print_line); > > $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding}); >@@ -1549,7 +1549,7 @@ sub send_acs_status { > $msg .= add_field(FID_SUPPORTED_MSGS, $supported_msgs); > } > >- $msg .= maybe_add(FID_SCREEN_MSG, $screen_msg); >+ $msg .= maybe_add(FID_SCREEN_MSG, $screen_msg, $server); > > if (defined($account->{print_width}) && defined($print_line) > && $account->{print_width} < length($print_line)) { >diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml >index bd8d49e..daadd99 100644 >--- a/etc/SIPconfig.xml >+++ b/etc/SIPconfig.xml >@@ -42,7 +42,10 @@ > <login id="lpl-sc" password="1234" institution="LPL" /> > <login id="lpl-sc-beacock" password="xyzzy" > delimiter="|" error-detect="enabled" institution="LPL" >- send_patron_home_library_in_af="1" /> >+ send_patron_home_library_in_af="1" > >+ <screen_msg_regex value="s/Greetings from Koha./Welcome to your library!/g" /> >+ <screen_msg_regex value="s/Invalid patron barcode./Barcode not found, are you sure this is your library card?/g" /> >+ </login> > </accounts> > > <!-- >-- >1.7.2.5
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 12571
:
29677
|
29678
|
29679
|
30293
|
32206